public void TestSinglePointExternalCalibrationWithIsConcentration() { const double internalStandardConcentration = 80.0; var srmDocument = LoadTestDocument(); srmDocument = ChangeStandardConcentrationCount(srmDocument, 1); srmDocument = ChangeQuantificationSettings(srmDocument, QuantificationSettings.DEFAULT .ChangeRegressionFit(RegressionFit.LINEAR_THROUGH_ZERO) .ChangeNormalizationMethod(NormalizationMethod.GetNormalizationMethod(IsotopeLabelType.heavy))); PeptideGroupDocNode protein = srmDocument.MoleculeGroups.First(); PeptideDocNode peptide = protein.Peptides.First(); peptide = peptide.ChangeInternalStandardConcentration(internalStandardConcentration); PeptideQuantifier peptideQuantifier = PeptideQuantifier.GetPeptideQuantifier(srmDocument.Settings, protein, peptide); CalibrationCurveFitter curveFitter = new CalibrationCurveFitter(peptideQuantifier, srmDocument.Settings); Assert.AreEqual(CalibrationCurveFitter.ConcentrationRatioText(IsotopeLabelType.light, IsotopeLabelType.heavy), curveFitter.GetXAxisTitle()); Assert.AreEqual(CalibrationCurveFitter.PeakAreaRatioText(IsotopeLabelType.light, IsotopeLabelType.heavy), curveFitter.GetYAxisTitle()); var chromatograms = srmDocument.Settings.MeasuredResults.Chromatograms; for (int iReplicate = 0; iReplicate < chromatograms.Count; iReplicate++) { string msg = string.Format("Replicate {0}", iReplicate); var expectedY = peptide.Results[iReplicate].First().LabelRatios.First().Ratio.Ratio; double?actualY = curveFitter.GetYValue(iReplicate).Value; Assert.IsNotNull(actualY); Assert.AreEqual(expectedY, actualY.Value, epsilon, msg); var calibrationCurve = curveFitter.GetCalibrationCurve(); Assert.AreEqual(1, calibrationCurve.PointCount); var expectedConcentration = expectedY * internalStandardConcentration / calibrationCurve.Slope.Value; Assert.AreEqual(expectedConcentration / internalStandardConcentration, curveFitter.GetCalculatedXValue(calibrationCurve, iReplicate).GetValueOrDefault(double.NaN), epsilon, msg); Assert.AreEqual(expectedConcentration, curveFitter.GetCalculatedConcentration(calibrationCurve, iReplicate).GetValueOrDefault(double.NaN), epsilon, msg); var chromatogramSet = chromatograms[iReplicate]; if (Equals(chromatogramSet.SampleType, SampleType.STANDARD) && chromatogramSet.AnalyteConcentration.HasValue) { // Since there was only one standard, the regression line goes exactly through this sample. Assert.AreEqual(expectedConcentration, chromatogramSet.AnalyteConcentration.Value * peptide.ConcentrationMultiplier.GetValueOrDefault(1.0), epsilon); } } }
public void TestMultipointExternalCalibrationWithoutNormalization() { var srmDocument = LoadTestDocument(); srmDocument = ChangeQuantificationSettings(srmDocument, QuantificationSettings.DEFAULT .ChangeNormalizationMethod(NormalizationMethod.NONE) .ChangeRegressionFit(RegressionFit.LINEAR) .ChangeUnits("ng/mL")); PeptideGroupDocNode protein = srmDocument.MoleculeGroups.First(); PeptideDocNode peptide = srmDocument.Peptides.First(); peptide = peptide.ChangeInternalStandardConcentration(null); CalibrationCurveFitter curveFitter = CalibrationCurveFitter.GetCalibrationCurveFitter(srmDocument.Settings, protein, peptide); string expectedXAxis = CalibrationCurveFitter.AppendUnits(QuantificationStrings.Analyte_Concentration, "ng/mL"); Assert.AreEqual(expectedXAxis, curveFitter.GetXAxisTitle()); string expectedYAxis = QuantificationStrings.CalibrationCurveFitter_GetYAxisTitle_Peak_Area; Assert.AreEqual(expectedYAxis, curveFitter.GetYAxisTitle()); var chromatograms = srmDocument.Settings.MeasuredResults.Chromatograms; var lightPrecursor = peptide.TransitionGroups .First(tg => IsotopeLabelType.light.Equals(tg.TransitionGroup.LabelType)); for (int iReplicate = 0; iReplicate < chromatograms.Count; iReplicate++) { string msg = string.Format("Replicate {0}", iReplicate); var expectedY = lightPrecursor.Results[iReplicate].First().Area.Value; Assert.AreEqual(expectedY, curveFitter.GetYValue(iReplicate).Value, .01, msg); var calibrationCurve = curveFitter.GetCalibrationCurve(); Assert.IsNotNull(calibrationCurve.Slope); Assert.IsNotNull(calibrationCurve.RSquared); double expectedConcentration = calibrationCurve.GetX(expectedY).Value; Assert.AreEqual(expectedConcentration, curveFitter.GetCalculatedXValue(calibrationCurve, iReplicate).GetValueOrDefault(double.NaN), epsilon, msg); Assert.AreEqual(expectedConcentration, curveFitter.GetCalculatedConcentration(calibrationCurve, iReplicate).GetValueOrDefault(double.NaN), epsilon, msg); } }
public void TestInternalCalibration() { const double internalStandardConcentration = 80.0; var srmDocument = LoadTestDocument(); AssertEx.IsDocumentState(srmDocument, null, 1, 1, 2, 10); srmDocument = ChangeStandardConcentrationCount(srmDocument, 0); srmDocument = ChangeQuantificationSettings(srmDocument, QuantificationSettings.DEFAULT .ChangeRegressionFit(RegressionFit.NONE) .ChangeNormalizationMethod(NormalizationMethod.GetNormalizationMethod(IsotopeLabelType.heavy)) .ChangeUnits("ng/mL")); PeptideGroupDocNode protein = srmDocument.MoleculeGroups.First(); PeptideDocNode peptide = protein.Peptides.First(); peptide = peptide.ChangeInternalStandardConcentration(internalStandardConcentration); CalibrationCurveFitter curveFitter = CalibrationCurveFitter.GetCalibrationCurveFitter(srmDocument.Settings, protein, peptide); string expectedXAxis = CalibrationCurveFitter.AppendUnits(QuantificationStrings.Analyte_Concentration, "ng/mL"); Assert.AreEqual(expectedXAxis, curveFitter.GetXAxisTitle()); string expectedYAxis = CalibrationCurveFitter.PeakAreaRatioText(IsotopeLabelType.light, IsotopeLabelType.heavy); Assert.AreEqual(expectedYAxis, curveFitter.GetYAxisTitle()); var chromatograms = srmDocument.Settings.MeasuredResults.Chromatograms; for (int iReplicate = 0; iReplicate < chromatograms.Count; iReplicate++) { string msg = string.Format("Replicate {0}", iReplicate); var expectedY = peptide.Results[iReplicate].First().LabelRatios.First().Ratio.Ratio; Assert.AreEqual(expectedY, curveFitter.GetYValue(iReplicate).Value, epsilon, msg); var calibrationCurve = curveFitter.GetCalibrationCurve(); Assert.AreEqual(1 / internalStandardConcentration, calibrationCurve.Slope); Assert.IsNull(calibrationCurve.RSquared); Assert.AreEqual(expectedY * internalStandardConcentration, curveFitter.GetCalculatedXValue(calibrationCurve, iReplicate).GetValueOrDefault(double.NaN), epsilon, msg); Assert.AreEqual(expectedY * internalStandardConcentration, curveFitter.GetCalculatedConcentration(calibrationCurve, iReplicate).GetValueOrDefault(double.NaN), epsilon, msg); } }