/// <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); }
/// <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)); }
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); }