public void TestDilutionFactor() { var baseDocument = LoadTestDocument(); baseDocument = ChangeQuantificationSettings(baseDocument, QuantificationSettings.DEFAULT .ChangeNormalizationMethod(NormalizationMethod.GetNormalizationMethod(IsotopeLabelType.heavy)) .ChangeRegressionFit(RegressionFit.LINEAR) .ChangeUnits("ng/mL")); var baseCurveFitter = CalibrationCurveFitter.GetCalibrationCurveFitter(baseDocument.Settings, baseDocument.MoleculeGroups.First(), baseDocument.Molecules.First()); var baseCurve = baseCurveFitter.GetCalibrationCurve(); // Set the dilution factor of each external standard to 2.0, and each unknown to 3.0 var docWithDilutionFactor = baseDocument.ChangeMeasuredResults( baseDocument.MeasuredResults.ChangeChromatograms(baseDocument.MeasuredResults.Chromatograms.Select( chrom => Equals(chrom.SampleType, SampleType.STANDARD) ? chrom.ChangeDilutionFactor(2.0) : chrom.ChangeDilutionFactor(3.0)).ToArray())); var dilutionFactorCurveFitter = CalibrationCurveFitter.GetCalibrationCurveFitter( docWithDilutionFactor.Settings, docWithDilutionFactor.MoleculeGroups.First(), docWithDilutionFactor.Molecules.First()); var dilutionFactorCurve = dilutionFactorCurveFitter.GetCalibrationCurve(); Assert.AreEqual(2.0 * baseCurve.Slope, dilutionFactorCurve.Slope); Assert.AreEqual(baseCurve.Intercept, dilutionFactorCurve.Intercept); for (int replicateIndex = 0; replicateIndex < baseDocument.MeasuredResults.Chromatograms.Count; replicateIndex++) { var sampleType = baseDocument.MeasuredResults.Chromatograms[replicateIndex].SampleType; var baseConcentration = baseCurveFitter.GetCalculatedConcentration(baseCurve, replicateIndex); Assert.IsNotNull(baseConcentration); var dilutionFactorConcentration = dilutionFactorCurveFitter.GetCalculatedConcentration(dilutionFactorCurve, replicateIndex); Assert.IsNotNull(dilutionFactorConcentration); if (Equals(sampleType, SampleType.STANDARD)) { Assert.AreEqual(baseConcentration.Value, dilutionFactorConcentration.Value, epsilon); } else { Assert.AreEqual(1.5 * baseConcentration.Value, dilutionFactorConcentration.Value, epsilon); } } AssertEx.ValidatesAgainstSchema(docWithDilutionFactor); }
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); } }