示例#1
0
        /// <summary>
        /// Uses a list of MassTagLights as a baseline for aligning a list of UMCLights to it, using
        /// the passed in options for processor options as well as a boolean for whether to align based on
        /// Drift Times as well.
        /// Creates an LCMS Alignment processor to do the alignment, does the alignment, and then passes
        /// back the alignment data to the caller.
        /// </summary>
        /// <param name="massTags"></param>
        /// <param name="aligneeFeatures"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        private LcmsWarpAlignmentData AlignFeatures(List <MassTagLight> massTags, List <UMCLight> aligneeFeatures,
                                                    LcmsWarpAlignmentOptions options)
        {
            var alignmentProcessor = new LcmsWarpAlignmentProcessor
            {
                Options = options
            };

            alignmentProcessor.ApplyAlignmentOptions();
            alignmentProcessor.Progress += alignmentProcessor_Progress;

            var featureTest = aligneeFeatures.Find(x => x.DriftTime > 0);
            var massTagTest = massTags.Find(x => x.DriftTime > 0);

            if (featureTest != null && massTagTest == null)
            {
                Console.WriteLine("Warning! Data has drift time info, but the mass tags do not.");
            }

            alignmentProcessor.SetReferenceDatasetFeatures(massTags);

            var data = AlignFeatures(alignmentProcessor, aligneeFeatures, options);

            return(data);
        }
示例#2
0
        /// <summary>
        /// Public constructor for the LCMS Alignment Processor
        /// Initializes a new LCMSWarp object using the LCMS Alignment options
        /// which were passed into the Processor
        /// </summary>
        public LcmsWarpAlignmentProcessor()
        {
            m_lcmsWarp = new LcmsWarp();
            Options    = new LcmsWarpAlignmentOptions();

            ApplyAlignmentOptions();

            AligningToMassTagDb = false;
        }
示例#3
0
 public LcmsWarpAdapter(LcmsWarpAlignmentOptions options)
 {
     m_options = options;
 }
示例#4
0
        private static IEnumerable <UMCLight> FilterFeaturesByAbundance(List <UMCLight> features, LcmsWarpAlignmentOptions options)
        {
            // Sort by abundance to ease filtering process. Options look at the percentage of abundance
            // so threshhold needs to be converted to what the abundance sum would be.
            features.Sort((x, y) => x.AbundanceSum.CompareTo(y.AbundanceSum));

            var percent    = 1 - (options.TopFeatureAbundancePercent / 100);
            var total      = features.Count - Convert.ToInt32(features.Count * percent);
            var threshhold = features[Math.Min(features.Count - 1, Math.Max(0, total))].AbundanceSum;

            // Re-sort with regards to monoisotopic mass for accurate application of NET-Mass function
            // to the dataset we need to align.
            features.Sort((x, y) => x.MassMonoisotopic.CompareTo(y.MassMonoisotopic));

            if (threshhold <= 0)
            {
                return(features);
            }

            //Filters features below the threshold
            var filteredFeatures = features.Where(feature => feature.AbundanceSum >= threshhold);

            return(filteredFeatures);
        }
示例#5
0
        private LcmsWarpAlignmentData AlignFeatures(LcmsWarpAlignmentProcessor processor, List <UMCLight> aligneeFeatures, LcmsWarpAlignmentOptions options)
        {
            var alignmentFunctions = new List <LcmsWarpAlignmentFunction>();

            var heatScores = new List <double[, ]>();
            var xIntervals = new List <double[]>();
            var yIntervals = new List <double[]>();

            double minMtdbNet;
            double maxMtdbNet;

            processor.GetReferenceNetRange(out minMtdbNet, out maxMtdbNet);

            var filteredFeatures = FilterFeaturesByAbundance(aligneeFeatures, options).ToList();

            // Set features
            processor.SetAligneeDatasetFeatures(filteredFeatures);

            // Find alignment
            processor.PerformAlignmentToMsFeatures();

            // Extract alignment function
            var alignmentFunction = processor.GetAlignmentFunction();

            alignmentFunctions.Add(alignmentFunction);

            // Correct the features
            processor.ApplyNetMassFunctionToAligneeDatasetFeatures(ref aligneeFeatures);

            // Get the heat maps
            double[,] heatScore;
            double[] xInterval;
            double[] yInterval;

            processor.GetAlignmentHeatMap(out heatScore, out xInterval, out yInterval);
            xIntervals.Add(xInterval);
            yIntervals.Add(yInterval);
            heatScores.Add(heatScore);

            // Get the histograms
            double[,] massErrorHistogram;
            double[,] netErrorHistogram;
            double[,] driftErrorHistogram;

            processor.GetErrorHistograms(options.MassBinSize, options.NetBinSize, options.DriftTimeBinSize,
                                         out massErrorHistogram, out netErrorHistogram, out driftErrorHistogram);

            // Get the residual data
            var residualData = processor.GetResidualData();

            var data = new LcmsWarpAlignmentData
            {
                MassErrorHistogram    = massErrorHistogram,
                DriftErrorHistogram   = driftErrorHistogram,
                NetErrorHistogram     = netErrorHistogram,
                AlignmentFunction     = alignmentFunction,
                HeatScores            = heatScore,
                NetIntercept          = processor.NetIntercept,
                NetRsquared           = processor.NetRsquared,
                NetSlope              = processor.NetSlope,
                ResidualData          = residualData,
                MassMean              = processor.MassMu,
                MassStandardDeviation = processor.MassStd,
                NetMean = processor.NetMu,
                NetStandardDeviation = processor.NetStd
            };

            return(data);
        }
示例#6
0
        /// <summary>
        /// Uses a list of UMCLights as a baseline for aligning a second list of UMCLights to it, using
        /// the passed in options for processor options
        /// Creates an LCMS Alignment processor to do the alignment, does the alignment, and then passes
        /// back the alignment data to the caller.
        /// </summary>
        /// <param name="baseline"></param>
        /// <param name="aligneeFeatures"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        private LcmsWarpAlignmentData AlignFeatures(List <UMCLight> baseline, List <UMCLight> aligneeFeatures, LcmsWarpAlignmentOptions options)
        {
            var alignmentProcessor = new LcmsWarpAlignmentProcessor
            {
                Options = options
            };

            alignmentProcessor.ApplyAlignmentOptions();
            alignmentProcessor.Progress += alignmentProcessor_Progress;

            var filteredBaselineFeatures = FilterFeaturesByAbundance(baseline, options) as List <UMCLight>;

            alignmentProcessor.SetReferenceDatasetFeatures(filteredBaselineFeatures);

            return(AlignFeatures(alignmentProcessor, aligneeFeatures, options));
        }