예제 #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 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;
            }
        }