コード例 #1
0
ファイル: IonUtils.cs プロジェクト: devicepros/LCMS-Spectator
        /// <summary>
        /// Get a smoothed XIC.
        /// </summary>
        /// <param name="smoother">Smoother to smooth XIC.</param>
        /// <param name="xic">XIC to smooth.</param>
        /// <returns>Array of smoothed XIC points.</returns>
        public static XicPoint[] SmoothXic(SavitzkyGolaySmoother smoother, IList <XicPoint> xic)
        {
            var xicP = new double[xic.Count];

            for (var i = 0; i < xic.Count; i++)
            {
                xicP[i] = xic[i].Intensity;
            }

            double[] smoothedPoints;
            try
            {
                smoothedPoints = smoother.Smooth(xicP);
            }
            catch (IndexOutOfRangeException)
            {
                smoothedPoints = xicP;
            }

            var smoothedXic = new XicPoint[xicP.Length];

            for (var i = 0; i < xicP.Length; i++)
            {
                smoothedXic[i] = new XicPoint(xic[i].ScanNum, xic[i].Mz, smoothedPoints[i]);
            }

            return(smoothedXic);
        }
コード例 #2
0
        /// <summary>
        /// Smooth and snip tails off a single XIC.
        /// </summary>
        /// <param name="xic">The XIC to refine.</param>
        /// <returns>Refined XIC.</returns>
        public Xic RefineXic(Xic xic)
        {
            // Here we smooth the points...and remove any features with from and trailing zero points
            if (xic.Count == 0)
            {
                return(xic);
            }

            var unsmoothedPoints = xic.Select(xicp => new XYData(xicp.ScanNum, xicp.Intensity))
                                   .OrderBy(p => p.X).ToList();
            var points = smoother.Smooth(unsmoothedPoints);

            // Find the biggest peak...
            var    maxScanIndex = 0;
            double maxAbundance = 0;

            for (var i = 0; i < xic.Count; i++)
            {
                if (maxAbundance < xic[i].Intensity)
                {
                    maxScanIndex = i;
                    maxAbundance = xic[i].Intensity;
                }
            }

            // Then find when the feature goes to zero
            // Start from max to left
            var startIndex = maxScanIndex;

            // If we hit zero, then keep
            for (; startIndex > 0; startIndex--)
            {
                if ((xic[startIndex].Intensity / maxAbundance) < this.relativeIntensityThreshold)
                {
                    break;
                }
            }

            // Start from max to right
            var stopIndex = maxScanIndex;

            for (; stopIndex < xic.Count - 1; stopIndex++)
            {
                if ((xic[stopIndex].Intensity / maxAbundance) < this.relativeIntensityThreshold)
                {
                    break;
                }
            }

            // Add the features back
            for (var i = startIndex; i <= stopIndex; i++)
            {
                xic[i] = new XicPoint(Convert.ToInt32(xic[i].ScanNum), xic[i].Mz, Convert.ToInt64(points[i].Y));
            }

            return(xic);
        }
コード例 #3
0
ファイル: DiaLcMsRun.cs プロジェクト: javamng/GitHUB
        public new Xic GetFullProductExtractedIonChromatogram(double minMz, double maxMz, double precursorIonMz)
        {
            var xic = GetProductExtractedIonChromatogram(minMz, maxMz, precursorIonMz);
            var scanToXicPoint = new XicPoint[MaxLcScan - MinLcScan + 1];
            foreach (var xicPoint in xic) scanToXicPoint[xicPoint.ScanNum - MinLcScan] = xicPoint;

            var newXic = new Xic();
            newXic.AddRange(GetFragmentationSpectraScanNums(precursorIonMz).Select(scanNum => scanToXicPoint[scanNum - MinLcScan] ?? new XicPoint(scanNum, 0, 0)));
            return newXic;
        }
コード例 #4
0
        public new Xic GetFullProductExtractedIonChromatogram(double minMz, double maxMz, double precursorIonMz)
        {
            var xic            = GetProductExtractedIonChromatogram(minMz, maxMz, precursorIonMz);
            var scanToXicPoint = new XicPoint[MaxLcScan - MinLcScan + 1];

            foreach (var xicPoint in xic)
            {
                scanToXicPoint[xicPoint.ScanNum - MinLcScan] = xicPoint;
            }

            var newXic = new Xic();

            newXic.AddRange(GetFragmentationSpectraScanNums(precursorIonMz).Select(scanNum => scanToXicPoint[scanNum - MinLcScan] ?? new XicPoint(scanNum, 0, 0)));
            return(newXic);
        }