Esempio n. 1
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);
        }