Esempio n. 1
0
        public void ApplyViperMassAlignmentDataFromViperTest1()
        {
            var testFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW";
            var run      = new RunFactory().CreateRun(testFile);

            var calibrationData = new ViperMassCalibrationData();

            calibrationData.MassError = -3.6;

            var massAlignmentInfo = new MassAlignmentInfoLcmsWarp();

            massAlignmentInfo.SetMassAlignmentData(calibrationData);

            run.MassAlignmentInfo = massAlignmentInfo;

            var testMZ    = 974.504343924692;
            var alignedMZ = run.GetAlignedMZ(testMZ);
            var ppmDiff   = (testMZ - alignedMZ) / testMZ * 1e6;

            Console.WriteLine("input m/z= " + testMZ);
            Console.WriteLine("aligned m/z= " + alignedMZ);
            Console.WriteLine("ppmDiff= " + ppmDiff);

            Assert.AreEqual(-3.6, (decimal)Math.Round(ppmDiff, 1));
        }
        public void ensureAlignment_was_executed()
        {
            var run = new RunFactory().CreateRun(DeconTools.UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            var alignmentFeaturesFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\AlignmentInfo\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_READONLY_alignedFeatures.txt";

            var importer = new UnlabelledTargetedResultFromTextImporter(alignmentFeaturesFile);
            var repo     = importer.Import();

            var massTagFile =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\Unlabelled\Targets\QCShew_Formic_MassTags_Bin10_all.txt";

            var mtc        = new TargetCollection();
            var mtimporter = new MassTagFromTextFileImporter(massTagFile);

            mtc = mtimporter.Import();


            var parameters = new NETAndMassAlignerParameters();
            var aligner    = new NETAndMassAligner();

            aligner.SetFeaturesToBeAligned(repo.Results);
            aligner.SetReferenceMassTags(mtc.TargetList);

            var scan    = 7835;
            var theorMZ = 780.08485;    //massTagID = 24701 (+3)

            var obsMZ = 780.0824;

            var netBeforeAlignment = run.NetAlignmentInfo.GetNETValueForScan(scan);
            var mzBeforeAlignment  = run.GetAlignedMZ(obsMZ);

            aligner.Execute(run);

            var netAfterAlignment = run.NetAlignmentInfo.GetNETValueForScan(scan);
            var mzAfterAlignment  = run.GetAlignedMZ(obsMZ);

            Console.WriteLine("NET before alignment = " + netBeforeAlignment);
            Console.WriteLine("NET after alignment = " + netAfterAlignment);

            Console.WriteLine("Theor MZ =  " + theorMZ);
            Console.WriteLine("MZ before alignment = " + mzBeforeAlignment);
            Console.WriteLine("MZ after alignment =  " + mzAfterAlignment);
            Console.WriteLine("PPMDiff before alignment = " + (theorMZ - mzBeforeAlignment) / theorMZ * 1e6);
            Console.WriteLine("PPMDiff after alignment =  " + (theorMZ - mzAfterAlignment) / theorMZ * 1e6);
        }
Esempio n. 3
0
        public void LoadAndApplyMassAlignmentFromViperDataTest1()
        {
            var testFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW";
            var run      = new RunFactory().CreateRun(testFile);

            var viperMassAlignmentFile =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\AlignmentInfo\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_MassAndGANETErrors_BeforeRefinement.txt";
            var loader = new ViperMassCalibrationLoader(viperMassAlignmentFile);

            /*
             * From unit test: targetedWorkflow_alignUsingDataFromFiles
             *      TargetID =  24702
             *      ChargeState =   3
             *      theor monomass=     2920.5319802
             *      theor m/z=  974.517936556667
             *      obs monomass=   2920.49120230408
             *      obs m/z=    974.504343924692
             *      ppmError before=    13.9597398284934
             *      ppmError after=     10.8899784905986
             *      calibrated mass=    2920.50017566955
             *      calibrated mass2=   2920.50017566955
             *      Database NET= 0.4197696
             *      Result NET= 0.42916464805603
             *      Result NET Error= -0.00934833288192749
             *      NumChromPeaksWithinTol= 3
             *
             *
             */


            var calibrationData = loader.ImportMassCalibrationData();

            var massAlignmentInfo = new MassAlignmentInfoLcmsWarp();

            massAlignmentInfo.SetMassAlignmentData(calibrationData);

            run.MassAlignmentInfo = massAlignmentInfo;

            var testMZ    = 974.504343924692;
            var alignedMZ = run.GetAlignedMZ(testMZ);
            var ppmDiff   = (testMZ - alignedMZ) / testMZ * 1e6;

            Console.WriteLine("input m/z= " + testMZ);
            Console.WriteLine("aligned m/z= " + alignedMZ);
            Console.WriteLine("ppmDiff= " + ppmDiff);

            Assert.AreEqual(-3.6, (decimal)Math.Round(ppmDiff, 1));
        }
Esempio n. 4
0
        public void GetCalibratedMass1()
        {
            //see  https://jira.pnnl.gov/jira/browse/OMCS-870

            var testFile =
                @"\\protoapps\DataPkgs\Public\2013\743_Mycobacterium_tuberculosis_Cys_and_Ser_ABP\IQ_Analysis\Testing\LNA_A_Stat_Sample_SC_28_LNA_ExpA_Expo_Stat_SeattleBioMed_15Feb13_Cougar_12-12-36.raw";
            var run = new RunFactory().CreateRun(testFile);

            var calibrationData = new ViperMassCalibrationData();

            calibrationData.MassError = 4.8;

            var massAlignmentInfo = new MassAlignmentInfoLcmsWarp();

            massAlignmentInfo.SetMassAlignmentData(calibrationData);

            run.MassAlignmentInfo = massAlignmentInfo;

            var observedMZ = 440.5887078;
            var theorMZ    = 440.5858315;

            var calibratedMZ = run.GetAlignedMZ(observedMZ);

            Assert.AreEqual(440.5866m, (decimal)Math.Round(calibratedMZ, 4));

            var ppmDiffBefore = (observedMZ - theorMZ) / theorMZ * 1e6;
            var ppmDiffAfter  = (calibratedMZ - theorMZ) / theorMZ * 1e6;

            Console.WriteLine("input m/z= " + observedMZ);
            Console.WriteLine("calibrated m/z= " + calibratedMZ);
            Console.WriteLine("ppmDiffBeforeCalibration= " + ppmDiffBefore);
            Console.WriteLine("ppmDiffAftereCalibration= " + ppmDiffAfter);

            var theorMZToLookForInRawData = run.GetTargetMZAligned(theorMZ);
            var ppmDiffTheor = (theorMZToLookForInRawData - theorMZ) / theorMZ * 1e6;

            Console.WriteLine();
            Console.WriteLine("Theor m/z = " + theorMZ);
            Console.WriteLine("Theor m/z to look for = " + theorMZToLookForInRawData);
            Console.WriteLine("ppmDiff = " + ppmDiffTheor);

            Assert.AreEqual(4.8m, (decimal)Math.Round(ppmDiffTheor, 1));
        }
        public void AlignmentParameterTesting2()
        {
            var run = new RunFactory().CreateRun(@"D:\Data\Orbitrap\Subissue01\QC_Shew_10_01-pt5-1_8Feb10_Doc_09-12-24.RAW");

            var alignmentFeaturesFile = @"\\protoapps\UserData\Slysz\Data\QCShew_MassiveTargeted\AlignmentInfo\QC_Shew_10_01-pt5-1_8Feb10_Doc_09-12-24_alignedFeatures.txt";

            var importer = new UnlabelledTargetedResultFromTextImporter(alignmentFeaturesFile);
            var repo = importer.Import();

            var massTagFile =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\Unlabelled\Targets\QCShew_Formic_MassTags_Bin10_all.txt";

            var mtc = new TargetCollection();
            var mtimporter = new MassTagFromTextFileImporter(massTagFile);
            mtc = mtimporter.Import();


            var parameters = new NETAndMassAlignerParameters();
            var aligner = new NETAndMassAligner();

            aligner.SetFeaturesToBeAligned(repo.Results);
            aligner.SetReferenceMassTags(mtc.TargetList);




            var sb = new StringBuilder();
            sb.Append("mtid\tscanLC\ttheorMZ\tobsMZ\talignedMZ\tppmErrorBefore\tppmErrorAfter\n");


            parameters.MassCalibrationWindow = 20;
            parameters.MassCalibrationNumMassDeltaBins = 100;

           // int[] massCalXSliceValues = { 3, 6, 9, 12, 15 };

            int[] massCalXSliceValues = { 15 };



            foreach (var xsliceVal in massCalXSliceValues)
            {
                var ppmErrorsBefore = new List<double>();
                var ppmErrorsAfter = new List<double>();

                parameters.MassCalibrationNumXSlices = (short)xsliceVal;
                aligner.AlignerParameters = parameters;
                aligner.Execute(run);

                foreach (var result in repo.Results)
                {
                    var mt = mtc.TargetList.Where(p => p.ID == result.TargetID).Where(p => p.ChargeState == result.ChargeState).First();
                    var theorMZ = mt.MZ;
                    var obsMZ = result.MonoMZ;
                    double scan = result.ScanLC;
                    var alignedMZ = run.GetAlignedMZ(obsMZ, scan);
                    var ppmErrorBefore = (theorMZ - obsMZ) / theorMZ * 1e6;
                    var ppmErrorAfter = (theorMZ - alignedMZ) / theorMZ * 1e6;


                    sb.Append(result.TargetID + "\t" + result.ScanLC + "\t" + theorMZ.ToString("0.00000") + "\t" + obsMZ.ToString("0.00000") + "\t" + alignedMZ.ToString("0.00000") + "\t" + ppmErrorBefore.ToString("0.0") + "\t" + ppmErrorAfter.ToString("0.0"));
                    sb.Append(Environment.NewLine);
                    

                    ppmErrorsAfter.Add(ppmErrorAfter);
                    ppmErrorsBefore.Add(ppmErrorBefore);
                }

                Console.WriteLine(sb.ToString());
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Average ppm error before alignment = " + ppmErrorsBefore.Average().ToString("0.00"));
                Console.WriteLine("Average ppm error after alignment = " + ppmErrorsAfter.Average().ToString("0.00"));
                Console.WriteLine();
                Console.WriteLine();

                Console.WriteLine(xsliceVal + "\t" + ppmErrorsBefore.Average().ToString("0.00") + "\t" + ppmErrorsAfter.Average().ToString("0.00"));

              


            }




        }
        public void Issue0725_AlignmentProblemsTest1()
        {
            var run = new RunFactory().CreateRun(@"D:\Data\Orbitrap\Issue0725_badAlignment\QC_Shew_10_03-2_100min_06May10_Tiger_10-04-08.RAW");

            var alignmentFeaturesFile = run.Filename.Replace(".RAW", "_alignedFeatures.txt");


            var importer = new UnlabelledTargetedResultFromTextImporter(alignmentFeaturesFile);
            var repo = importer.Import();

            var massTagFile = @"\\protoapps\UserData\Slysz\Data\QCShew_MassiveTargeted\MassTags\QCShew_Formic_MassTags_for_alignment.txt";

            var mtc = new TargetCollection();
            var mtimporter = new MassTagFromTextFileImporter(massTagFile);
            mtc = mtimporter.Import();



            var parameters = new NETAndMassAlignerParameters();
            var aligner = new NETAndMassAligner();

            aligner.SetFeaturesToBeAligned(repo.Results);
            aligner.SetReferenceMassTags(mtc.TargetList);




            var sb = new StringBuilder();
            sb.Append("mtid\tscanLC\ttheorMZ\tobsMZ\talignedMZ\tppmErrorBefore\tppmErrorAfter\n");


            parameters.MassCalibrationWindow = 50;
            parameters.MassCalibrationNumMassDeltaBins = 100;
            

            int[] massCalXSliceValues = { 3, 6, 9, 10, 12, 15,18,20 };

            //int[] massCalXSliceValues = { 6 };



            foreach (var xsliceVal in massCalXSliceValues)
            {
                var ppmErrorsBefore = new List<double>();
                var ppmErrorsAfter = new List<double>();

                parameters.MassCalibrationNumXSlices = (short)xsliceVal;
                aligner.AlignerParameters = parameters;
                aligner.Execute(run);

                foreach (var result in repo.Results)
                {
                    var mt = mtc.TargetList.Where(p => p.ID == result.TargetID).Where(p => p.ChargeState == result.ChargeState).First();
                    var theorMZ = mt.MZ;
                    var obsMZ = result.MonoMZ;
                    double scan = result.ScanLC;
                    var alignedMZ = run.GetAlignedMZ(obsMZ, scan);
                    var ppmErrorBefore = (theorMZ - obsMZ) / theorMZ * 1e6;
                    var ppmErrorAfter = (theorMZ - alignedMZ) / theorMZ * 1e6;
                    double theorNET = mt.NormalizedElutionTime;
                    double obsNET = result.NET;
                    var alignedNET = run.NetAlignmentInfo.GetNETValueForScan((int) scan);

                    sb.Append(result.TargetID + "\t" + result.ScanLC + "\t" + theorMZ.ToString("0.00000") + "\t" + obsMZ.ToString("0.00000") + "\t" + alignedMZ.ToString("0.00000") + "\t" + ppmErrorBefore.ToString("0.0") + "\t" + ppmErrorAfter.ToString("0.0") + "\t" + theorNET.ToString("0.0000") + "\t" + obsNET.ToString("0.0000") + "\t" + alignedNET.ToString("0.0000"));

                    //sb.Append(result.MassTagID + "\t" + result.ScanLC + "\t" + theo
                    sb.Append(Environment.NewLine);
                    ppmErrorsAfter.Add(ppmErrorAfter);
                    ppmErrorsBefore.Add(ppmErrorBefore);
                }

               // Console.WriteLine(sb.ToString());
                //Console.WriteLine();
                //Console.WriteLine();
                //Console.WriteLine("Average ppm error before alignment = " + filterWithGrubbsApplied(ppmErrorsBefore).Average().ToString("0.00"));
                //Console.WriteLine("Average ppm error after alignment = " + filterWithGrubbsApplied(ppmErrorsAfter).Average().ToString("0.00"));
                //Console.WriteLine();
                //Console.WriteLine();

                Console.WriteLine(xsliceVal + "\t" + filterWithGrubbsApplied(ppmErrorsBefore).Average().ToString("0.00") + "\t" + filterWithGrubbsApplied(ppmErrorsAfter).Average().ToString("0.00"));




            }

        }
        public void AlignmentParameterTesting1()
        {
            var run = new RunFactory().CreateRun(DeconTools.UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            var alignmentFeaturesFile = @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_READONLY_alignedFeatures.txt";

            var importer = new UnlabelledTargetedResultFromTextImporter(alignmentFeaturesFile);
            var repo = importer.Import();

            var massTagFile =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\Unlabelled\Targets\QCShew_Formic_MassTags_Bin10_all.txt";

            var mtc = new TargetCollection();
            var mtimporter = new MassTagFromTextFileImporter(massTagFile);
            mtc = mtimporter.Import();


            var parameters = new NETAndMassAlignerParameters();
            var aligner = new NETAndMassAligner();

            aligner.SetFeaturesToBeAligned(repo.Results);
            aligner.SetReferenceMassTags(mtc.TargetList);

       


            var sb = new StringBuilder();
            sb.Append("theorMZ\tobsMZ\talignedMZ\tppmErrorBefore\tppmErrorAfter\n");


            parameters.MassCalibrationWindow = 50;
            parameters.MassCalibrationNumMassDeltaBins = 100;

            int[]massCalXSliceValues = {3,6,9,12,15,20,30,50};

            foreach (var xsliceVal in massCalXSliceValues)
            {
                var ppmErrorsBefore = new List<double>();
                var ppmErrorsAfter = new List<double>();

                parameters.MassCalibrationNumXSlices =(short)xsliceVal;
                aligner.AlignerParameters = parameters;
                aligner.Execute(run);

                foreach (var result in repo.Results)
                {
                    var mt = mtc.TargetList.Where(p => p.ID == result.TargetID).Where(p => p.ChargeState == result.ChargeState).First();
                    var theorMZ = mt.MZ;
                    var obsMZ = result.MonoMZ;
                    double scan = result.ScanLC;
                    var alignedMZ = run.GetAlignedMZ(obsMZ, scan);
                    var ppmErrorBefore = (theorMZ - obsMZ) / theorMZ * 1e6;
                    var ppmErrorAfter = (theorMZ - alignedMZ) / theorMZ * 1e6;


                    sb.Append(result.TargetID + "\t" + result.ScanLC + "\t" + theorMZ.ToString("0.00000") + "\t" + obsMZ.ToString("0.00000") + "\t" + alignedMZ.ToString("0.00000") + "\t" + ppmErrorBefore.ToString("0.0") + "\t" + ppmErrorAfter.ToString("0.0"));
                    sb.Append(Environment.NewLine);
                    

                    ppmErrorsAfter.Add(ppmErrorAfter);
                    ppmErrorsBefore.Add(ppmErrorBefore);
                }

                Console.WriteLine(xsliceVal + "\t" + ppmErrorsBefore.Average().ToString("0.00") + "\t"+ ppmErrorsAfter.Average().ToString("0.00"));

                //Console.WriteLine(sb.ToString());
                //Console.WriteLine();
                //Console.WriteLine();
                //Console.WriteLine("Average ppm error before alignment = " + ppmErrorsBefore.Average().ToString("0.00"));
                //Console.WriteLine("Average ppm error after alignment = " + ppmErrorsAfter.Average().ToString("0.00"));

           
            }

      


        }