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 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); } }
protected override void DoTest() { RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("p180test_calibration_DukeApril2016.sky"))); var surrogateStandards = new Dictionary <string, string> { { "Leu", "Ile" }, { "Lys", "Orn" }, { "Ac-Orn", "Orn" }, { "SDMA", "ADMA" }, { "alpha-AAA", "Orn" }, { "Carnosine", "His" }, { "Histamine", "His" }, { "Kynurenine", "Tyr" }, { "Met-SO", "Met" }, { "Nitro-Tyr", "Tyr" }, { "c4-OH-Pro", "Pro" }, { "t4-OH-Pro", "Pro" }, }; // Set the standard type of the surrogate standards to StandardType.SURROGATE_STANDARD RunUI(() => { List <IdentityPath> pathsToSelect = SkylineWindow.SequenceTree.Nodes.OfType <PeptideGroupTreeNode>() .SelectMany(peptideGroup => peptideGroup.Nodes.OfType <PeptideTreeNode>()) .Where(peptideTreeNode => surrogateStandards.Values.Contains(peptideTreeNode.DocNode.RawTextId)) .Select(treeNode => treeNode.Path) .ToList(); SkylineWindow.SequenceTree.SelectedPaths = pathsToSelect; SkylineWindow.SetStandardType(StandardType.SURROGATE_STANDARD); }); // Use the document grid to set the Normalization Method of the molecules that have surrogate standards var documentGrid = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true)); RunUI(() => documentGrid.ChooseView(Resources.Resources_ReportSpecList_GetDefaults_Peptide_Quantification)); IDataGridViewEditingControl editingControl = null; DataGridViewEditingControlShowingEventHandler onEditingControlShowing = (sender, args) => editingControl = args.Control as IDataGridViewEditingControl; documentGrid.DataGridView.EditingControlShowing += onEditingControlShowing; // ReSharper disable AccessToForEachVariableInClosure foreach (var entry in surrogateStandards) { WaitForConditionUI(() => documentGrid.IsComplete); RunUI(() => { var colPeptide = documentGrid.FindColumn(PropertyPath.Root); for (int iRow = 0; iRow < documentGrid.RowCount; iRow++) { var row = documentGrid.DataGridView.Rows[iRow]; if (!entry.Key.Equals(row.Cells[colPeptide.Index].FormattedValue)) { continue; } var colNormalizationMethod = documentGrid.FindColumn(PropertyPath.Root.Property("NormalizationMethod")); documentGrid.DataGridView.CurrentCell = row.Cells[colNormalizationMethod.Index]; documentGrid.DataGridView.BeginEdit(false); editingControl.EditingControlFormattedValue = string.Format(Resources.RatioToSurrogate_ToString_Ratio_to_surrogate__0____1__, entry.Value, "Heavy"); documentGrid.DataGridView.EndEdit(); } }); } // Make sure that the Y-Axis on the CalibrationForm reflects the normalization method of the selected molecule var calibrationForm = ShowDialog <CalibrationForm>(() => SkylineWindow.ShowCalibrationForm()); foreach (var peptideGroupTreeNode in SkylineWindow.SequenceTree.Nodes.OfType <PeptideGroupTreeNode>()) { foreach (var peptideTreeNode in peptideGroupTreeNode.Nodes.OfType <PeptideTreeNode>()) { RunUI(() => SkylineWindow.SequenceTree.SelectedPath = peptideTreeNode.Path); WaitForGraphs(); string yAxisText = calibrationForm.ZedGraphControl.GraphPane.YAxis.Title.Text; if (null != peptideTreeNode.DocNode.NormalizationMethod) { Assert.IsInstanceOfType(peptideTreeNode.DocNode.NormalizationMethod, typeof(NormalizationMethod.RatioToSurrogate)); Assert.AreEqual(QuantificationStrings.CalibrationCurveFitter_GetYAxisTitle_Normalized_Peak_Area, yAxisText); } else { Assert.IsInstanceOfType(SkylineWindow.Document.Settings.PeptideSettings.Quantification.NormalizationMethod, typeof(NormalizationMethod.RatioToLabel)); string expectedTitle = CalibrationCurveFitter.PeakAreaRatioText(IsotopeLabelType.light, IsotopeLabelType.heavy); Assert.AreEqual(expectedTitle, yAxisText); } } } }