コード例 #1
0
        private void GetChromatogramCorrelationData(SipperLcmsTargetedResult result)
        {
            _chromScanWindowWidth = result.ChromPeakSelected.Width * 2;

            var startScan = result.ScanSet.PrimaryScanNumber - (int)Math.Round(_chromScanWindowWidth / 2, 0);
            var stopScan  = result.ScanSet.PrimaryScanNumber + (int)Math.Round(_chromScanWindowWidth / 2, 0);

            result.ChromCorrelationData = _chromatogramCorrelatorTask.CorrelatePeaksWithinIsotopicProfile(result.Run,
                                                                                                          NormalizedIso,
                                                                                                          startScan,
                                                                                                          stopScan);

            ChromatogramRSquaredVals.AddRange(
                result.ChromCorrelationData.CorrelationDataItems.Select(p => p.CorrelationRSquaredVal.GetValueOrDefault(-1)).
                ToList());

            //trim off zeros
            for (var i = ChromatogramRSquaredVals.Count - 1; i >= 0; i--)
            {
                if (ChromatogramRSquaredVals[i] <= 0)
                {
                    ChromatogramRSquaredVals.RemoveAt(i);
                }
                else
                {
                    break;
                }
            }

            result.ChromCorrelationMin = ChromatogramRSquaredVals.Min();

            if (ChromatogramRSquaredVals.Count > 1)
            {
                //get the best rsquared value other than the base peak's rsquared value (which is always 1)
                result.ChromCorrelationMax =
                    (from n in ChromatogramRSquaredVals orderby n descending select n).ToList().ElementAt(1);

                result.ChromCorrelationMedian  = MathUtils.GetMedian(ChromatogramRSquaredVals);
                result.ChromCorrelationAverage = ChromatogramRSquaredVals.Average();

                if (ChromatogramRSquaredVals.Count > 2)
                {
                    result.ChromCorrelationStdev = MathUtils.GetStDev(ChromatogramRSquaredVals);
                }
                else
                {
                    result.ChromCorrelationStdev = -1;
                }
            }
            else
            {
                result.ChromCorrelationMax = 1;
            }
        }
コード例 #2
0
        private void GetLinearRegressionData(SipperLcmsTargetedResult result, List <double> xvals, List <double> yvals)
        {
            var logRatioXVals = new List <double>();
            var logRatioYVals = new List <double>();

            var foundYvalAboveZero = false;

            for (var i = 0; i < xvals.Count; i++)
            {
                if (yvals[i] > 0)
                {
                    foundYvalAboveZero = true;
                    logRatioXVals.Add(xvals[i]);
                    logRatioYVals.Add(Math.Log(yvals[i]));
                }
                else
                {
                    //if we have already found a yval above 0, and then we found one below 0, this
                    //indicates a problem which we will penalize.
                    //if (foundYvalAboveZero)
                    //{
                    //    logRatioXVals.Add(xvals[i]);
                    //    logRatioYVals.Add(0);
                    //}
                }
            }

            double slope       = -9999;
            double intercept   = -9999;
            double rsquaredVal = -1;


            RatioLogVals.Xvalues = logRatioXVals.ToArray();
            RatioLogVals.Yvalues = logRatioYVals.ToArray();


            if (logRatioYVals.Count > 2)
            {
                try
                {
                    MathUtils.GetLinearRegression(RatioLogVals.Xvalues, RatioLogVals.Yvalues, out slope, out intercept,
                                                  out rsquaredVal);
                }
                catch (Exception)
                {
                    Console.WriteLine(result.Target.ID + "; Error getting linear regression in Sipper quantifier");
                }
            }
            else
            {
                rsquaredVal = 0;
            }
        }
コード例 #3
0
        public TargetedResultBase CreateMassTagResult(TargetBase massTag)
        {
            TargetedResultBase result;

            switch (ResultType)
            {
            case Globals.ResultType.BASIC_TARGETED_RESULT:
                result = new MassTagResult(massTag);
                break;

            case Globals.ResultType.N14N15_TARGETED_RESULT:
                result = new N14N15_TResult(massTag);
                break;

            case Globals.ResultType.O16O18_TARGETED_RESULT:
                result = new O16O18TargetedResultObject(massTag);
                break;

            case Globals.ResultType.SIPPER_TARGETED_RESULT:
                result = new SipperLcmsTargetedResult(massTag);
                break;

            case Globals.ResultType.TOPDOWN_TARGETED_RESULT:
                result = new TopDownTargetedResult(massTag);
                break;

            case Globals.ResultType.DEUTERATED_TARGETED_RESULT:
                result = new DeuteratedTargetedResultObject(massTag);
                break;

            default:
                result = new MassTagResult(massTag);
                break;
            }

            this.MassTagResultList.Add(massTag, result);
            result.MSFeatureID = MSFeatureCounter;
            result.Score       = 1;
            result.Run         = this.Run;

            this.MSFeatureCounter++;
            return(result);
        }
コード例 #4
0
        private static void addAdditionalInfo(TargetedResultDTO tr, SipperLcmsTargetedResult result)
        {
            var r = (SipperLcmsFeatureTargetedResultDTO)tr;

            r.MatchedMassTagID           = ((LcmsFeatureTarget)result.Target).FeatureToMassTagID;
            r.AreaUnderDifferenceCurve   = result.AreaUnderDifferenceCurve;
            r.AreaUnderRatioCurve        = result.AreaUnderRatioCurve;
            r.AreaUnderRatioCurveRevised = result.AreaUnderRatioCurveRevised;
            r.ChromCorrelationMin        = result.ChromCorrelationMin;
            r.ChromCorrelationMax        = result.ChromCorrelationMax;
            r.ChromCorrelationAverage    = result.ChromCorrelationAverage;
            r.ChromCorrelationMedian     = result.ChromCorrelationMedian;
            r.ChromCorrelationStdev      = result.ChromCorrelationStdev;
            r.NumCarbonsLabelled         = result.NumCarbonsLabelled;
            r.PercentPeptideLabelled     = result.PercentPeptideLabelled;
            r.PercentCarbonsLabelled     = result.PercentCarbonsLabelled;
            r.NumHighQualityProfilePeaks = result.NumHighQualityProfilePeaks;
            r.LabelDistributionVals      = result.LabelDistributionVals == null ? null : result.LabelDistributionVals.ToArray();
            r.FitScoreLabeledProfile     = result.FitScoreLabeledProfile;
            r.ContiguousnessScore        = result.ContiguousnessScore;
            r.RSquaredValForRatioCurve   = result.RSquaredValForRatioCurve;
        }
コード例 #5
0
        private void OutputMassSpectrum(string outputFolder, XYData massSpectrumXYData, TargetBase target, SipperLcmsTargetedResult sipperLcmsTargetedResult)
        {
            var msGraphGenerator = new MSGraphControl();

            msGraphGenerator.SymbolType = SymbolType.None;

            if (massSpectrumXYData == null)
            {
                massSpectrumXYData         = new XYData();
                massSpectrumXYData.Xvalues = new double[] { 0, 1, 2, 3, 4, 5 };
                massSpectrumXYData.Yvalues = new double[] { 0, 1, 2, 3, 4, 5 };
            }


            msGraphGenerator.GenerateGraph(massSpectrumXYData.Xvalues, massSpectrumXYData.Yvalues, target.MZ - 2,
                                           target.MZ + 6);

            var annotation = "fractionC13= " + sipperLcmsTargetedResult.PercentCarbonsLabelled.ToString("0.000") + "\n" +
                             "populationFraction= " + sipperLcmsTargetedResult.PercentPeptideLabelled.ToString("0.000");


            msGraphGenerator.AddAnnotationRelativeAxis(annotation, 0.45, 0.05);

            var outputFilename = Path.Combine(outputFolder, target.ID + "_MS.png");

            msGraphGenerator.SaveGraph(outputFilename);
        }
コード例 #6
0
        private void GetChromatogramCorrelationData(SipperLcmsTargetedResult result)
        {
            //NOTE: this is a very important step. If too wide, correlation data will be poor
            //and may lead to overly strict treatment of the data
            _chromScanWindowWidth = result.ChromPeakSelected.Width / 2.35 * 4;

            //TODO: change this!
            //_chromScanWindowWidth = 19;

            var startScan = result.ScanSet.PrimaryScanNumber - (int)Math.Round(_chromScanWindowWidth / 2, 0);
            var stopScan  = result.ScanSet.PrimaryScanNumber + (int)Math.Round(_chromScanWindowWidth / 2, 0);

            result.ChromCorrelationData = _chromatogramCorrelatorTask.CorrelatePeaksWithinIsotopicProfile(result.Run, NormalizedIso, startScan, stopScan);

            if (result.ChromCorrelationData.CorrelationDataItems.Count > 0)
            {
                ChromatogramRSquaredVals.AddRange(result.ChromCorrelationData.CorrelationDataItems.Select(p => p.CorrelationRSquaredVal.GetValueOrDefault(-1)).ToList());
            }


            //GORD: remove this console code later
            //Console.WriteLine();
            //Console.WriteLine(result.Target.ID);
            //foreach (var item in result.ChromCorrelationData.CorrelationDataItems)
            //{
            //    Console.WriteLine(item.CorrelationRSquaredVal);
            //}


            //trim off zeros
            for (var i = ChromatogramRSquaredVals.Count - 1; i >= 1; i--)
            {
                if (ChromatogramRSquaredVals[i] <= 0)
                {
                    ChromatogramRSquaredVals.RemoveAt(i);
                }
                else
                {
                    break;
                }
            }



            if (ChromatogramRSquaredVals.Count > 1)
            {
                result.ChromCorrelationMin = ChromatogramRSquaredVals.Min();
                //get the best rsquared value other than the base peak's rsquared value (which is always 1)
                result.ChromCorrelationMax =
                    (from n in ChromatogramRSquaredVals orderby n descending select n).ToList().ElementAt(1);

                result.ChromCorrelationMedian  = MathUtils.GetMedian(ChromatogramRSquaredVals);
                result.ChromCorrelationAverage = ChromatogramRSquaredVals.Average();

                if (ChromatogramRSquaredVals.Count > 2)
                {
                    result.ChromCorrelationStdev = MathUtils.GetStDev(ChromatogramRSquaredVals);
                }
                else
                {
                    result.ChromCorrelationStdev = -1;
                }
            }
            else
            {
                result.ChromCorrelationMin = -1;
                result.ChromCorrelationMax = -1;
            }
        }