public void CompareAveragingWithMSstats()
        {
            var srmDocument       = LoadRatPlasmaDocument();
            var documentContainer = new MemoryDocumentContainer();

            documentContainer.SetDocument(documentContainer.Document, srmDocument);
            GroupComparisonModel model = new GroupComparisonModel(documentContainer, null);

            model.GroupComparisonDef = GroupComparisonDef.EMPTY.ChangeControlAnnotation("Condition")
                                       .ChangeControlValue("Healthy")
                                       .ChangeIdentityAnnotation("BioReplicate")
                                       .ChangeSummarizationMethod(SummarizationMethod.AVERAGING)
                                       .ChangePerProtein(false);
            var expectedValues = MsStatsTestUtil.ReadExpectedResults(typeof(MSstatsAveragingTest),
                                                                     "RatPlasmaTestingResult.csv");
            var groupComparer = new GroupComparer(model.GroupComparisonDef, srmDocument, new QrFactorizationCache());

            foreach (var protein in srmDocument.PeptideGroups)
            {
                foreach (var peptide in protein.Peptides)
                {
                    var result         = groupComparer.CalculateFoldChange(new GroupComparisonSelector(protein, peptide, IsotopeLabelType.light, null, new GroupIdentifier("Diseased")), null);
                    var expectedResult = expectedValues[peptide.Peptide.Sequence];
                    Assert.AreEqual(expectedResult.EstimatedValue, result.LinearFitResult.EstimatedValue,
                                    (expectedResult.StandardError + result.LinearFitResult.StandardError) * 2, peptide.Peptide.Sequence);
                }
            }
        }
 public void CompareAveragingWithMSstats()
 {
     var srmDocument = LoadRatPlasmaDocument();
     var documentContainer = new MemoryDocumentContainer();
     documentContainer.SetDocument(documentContainer.Document, srmDocument);
     GroupComparisonModel model = new GroupComparisonModel(documentContainer, null);
     model.GroupComparisonDef = GroupComparisonDef.EMPTY.ChangeControlAnnotation("Condition")
         .ChangeControlValue("Healthy")
         .ChangeIdentityAnnotation("BioReplicate")
         .ChangeSummarizationMethod(SummarizationMethod.AVERAGING)
         .ChangePerProtein(false);
     var expectedValues = MsStatsTestUtil.ReadExpectedResults(typeof (MSstatsAveragingTest),
         "RatPlasmaTestingResult.csv");
     var groupComparer = new GroupComparer(model.GroupComparisonDef, srmDocument, new QrFactorizationCache());
     foreach (var protein in srmDocument.PeptideGroups)
     {
         foreach (var peptide in protein.Peptides)
         {
             var result = groupComparer.CalculateFoldChange(new GroupComparisonSelector(protein, peptide, IsotopeLabelType.light, null, new GroupIdentifier("Diseased")), null);
             var expectedResult = expectedValues[peptide.Peptide.Sequence];
             Assert.AreEqual(expectedResult.EstimatedValue, result.LinearFitResult.EstimatedValue,
                 (expectedResult.StandardError + result.LinearFitResult.StandardError) * 2, peptide.Peptide.Sequence);
         }
     }
 }
Exemple #3
0
        public void TestProteinAbundance()
        {
            var srmDocument       = LoadRatPlasmaDocument();
            var documentContainer = new MemoryDocumentContainer();

            documentContainer.SetDocument(srmDocument, documentContainer.Document);
            var skylineDataSchema      = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
            GroupComparisonModel model = new GroupComparisonModel(documentContainer, null);

            model.GroupComparisonDef = GroupComparisonDef.EMPTY.ChangeControlAnnotation("Condition")
                                       .ChangeControlValue("Healthy")
                                       .ChangeSummarizationMethod(SummarizationMethod.AVERAGING)
                                       .ChangePerProtein(true);
            var groupComparer = new GroupComparer(model.GroupComparisonDef, srmDocument, new QrFactorizationCache());

            foreach (var moleculeGroup in srmDocument.MoleculeGroups)
            {
                if (moleculeGroup.Molecules.Any(mol => null != mol.GlobalStandardType))
                {
                    continue;
                }
                var foldChangeResult = groupComparer.CalculateFoldChange(new GroupComparisonSelector(moleculeGroup, null, IsotopeLabelType.light, null, new GroupIdentifier("Diseased")), null);
                var xValues          = new List <double>();
                var yValues          = new List <double>();
                var protein          = new Protein(skylineDataSchema, new IdentityPath(moleculeGroup.PeptideGroup));
                foreach (var proteinResult in protein.Results.Values)
                {
                    var abundance = proteinResult.Abundance;
                    if (!abundance.HasValue)
                    {
                        continue;
                    }

                    var condition = proteinResult.Replicate.ChromatogramSet.Annotations.GetAnnotation("Condition");
                    if (condition == "Healthy")
                    {
                        xValues.Add(0);
                    }
                    else if (condition == "Diseased")
                    {
                        xValues.Add(1);
                    }
                    yValues.Add(Math.Log(abundance.Value));
                }
                Assert.AreEqual(xValues.Count, foldChangeResult.ReplicateCount);

                if (!xValues.Any())
                {
                    continue;
                }
                var yStatistics        = new Statistics(yValues);
                var xStatistics        = new Statistics(xValues);
                var slope              = yStatistics.Slope(xStatistics);
                var actualFoldChange   = Math.Exp(slope);
                var expectedFoldChange = Math.Pow(2.0, foldChangeResult.LinearFitResult.EstimatedValue);

                AssertEx.AreEqual(expectedFoldChange, actualFoldChange, .01);
            }
        }