Ejemplo n.º 1
0
        // Using a DependencyProperty as the backing store for MassMzImage.  This enables animation, styling, binding, etc...


        private void CreatePlots()
        {
            if (AlignmentData == null || AlignmentData.AlignmentData == null)
            {
                return;
            }

            var alignmentData = AlignmentData.AlignmentData;

            var heatmap       = HeatmapFactory.CreateAlignedHeatmap(alignmentData.HeatScores, alignmentData.BaselineIsAmtDB);
            var feature       = ScatterPlotFactory.CreateFeatureMassScatterPlot(AlignmentData.AligneeFeatures);
            var netHistogram  = HistogramFactory.CreateHistogram(alignmentData.NetErrorHistogram, "NET Error", "NET Error");
            var massHistogram = HistogramFactory.CreateHistogram(alignmentData.NetErrorHistogram, "Mass Error", "Mass Error (ppm)");

            var residuals = alignmentData.ResidualData;

            var netResidual = ScatterPlotFactory.CreateResidualPlot(residuals.Net, residuals.LinearCustomNet,
                                                                    residuals.LinearNet, "NET Residuals", "Scans", "NET");

            var massMzResidual = ScatterPlotFactory.CreateResidualPlot(residuals.Mz, residuals.MzMassError,
                                                                       residuals.MzMassErrorCorrected, "Mass Residuals", "m/z", "Mass Errors");

            var massScanResidual = ScatterPlotFactory.CreateResidualPlot(residuals.Net, residuals.MzMassError,
                                                                         residuals.MzMassErrorCorrected, "Mass Residuals", "Scan", "Mass Errors");

            NetScanImage     = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(netResidual));
            MassHistogram    = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(massHistogram));
            NetHistogram     = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(netHistogram));
            HeatmapImage     = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(heatmap));
            MassMzImage      = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(massMzResidual));
            MassScanImage    = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(massScanResidual));
            FeaturePlotImage = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(feature));
        }
Ejemplo n.º 2
0
        public FeaturesViewModel(IEnumerable <UMCLight> features, string text)
        {
            Text   = text;
            Height = 800;
            Width  = 800;

            FeaturesModel = ScatterPlotFactory.CreateFeatureMassScatterPlot(features);
        }
Ejemplo n.º 3
0
        private void CreateMassTagPlots()
        {
            var data = MassTagsData;

            PlotName = string.Format("Mass Tag Database");
            var plot = ScatterPlotFactory.CreateFeatureMassScatterPlot(data.MassTags);

            plot.Model.Title = PlotName;
            FeaturesImage    = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(plot));
        }
Ejemplo n.º 4
0
        public void CreateMassTagPlot(MassTagsLoadedEventArgs e)
        {
            Logger.PrintMessage("Creating Mass Tag Plot.");

            if (e.Database == null)
            {
                return;
            }

            if (e.MassTags == null)
            {
                return;
            }

            var feature   = ScatterPlotFactory.CreateFeatureMassScatterPlot(e.MassTags);
            var name      = e.Database.Name;
            var directory = Path.Combine(Config.AnalysisPath, name);

            PlotImageUtility.SaveImage(feature, directory + "_mtdb.png");
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Creates images for the HTML output for baseline data
        /// </summary>
        /// <param name="e"></param>
        public void CreateBaselinePlots(BaselineFeaturesLoadedEventArgs e)
        {
            var baselineInfo = e.DatasetInformation;

            if (baselineInfo == null)
            {
                return;
            }

            var feature   = ScatterPlotFactory.CreateFeatureMassScatterPlot(e.Features);
            var name      = e.DatasetInformation.DatasetName;
            var directory = Path.Combine(Config.AnalysisPath, PlotPath, name);

            var report = Config.Report;

            report.PushTextHeader("Baseline Features");
            report.PushStartTableRow();
            Config.Report.PushImageColumn(directory + "_features.png", WIDTH, HEIGHT);
            PlotImageUtility.SaveImage(feature, directory + "_features.png");
            report.PushEndTableRow();
        }
Ejemplo n.º 6
0
        ///
        private void CreatePlots()
        {
            var data = BaselineData;
            var name = "";

            if (data.DatasetInformation == null)
            {
                if (data.Database != null)
                {
                    name = data.Database.Name;
                }
            }
            else
            {
                name = data.DatasetInformation.DatasetName;
            }

            PlotName = string.Format("Baseline: {0}", name);
            var plot = ScatterPlotFactory.CreateFeatureMassScatterPlot(data.Features);

            FeaturesImage = ImageConverter.ConvertImage(PlotImageUtility.CreateImage(plot));
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     Creates alignment plots for the HTML output.
        /// </summary>
        public void CreateAlignmentPlots(FeaturesAlignedEventArgs e)
        {
            var name          = e.AligneeDatasetInformation.DatasetName;
            var alignmentData = e.AlignmentData;

            if (alignmentData == null)
            {
                return;
            }

            var directory     = Path.Combine(Config.AnalysisPath, PlotPath, name);
            var heatmap       = HeatmapFactory.CreateAlignedHeatmap(alignmentData.HeatScores, alignmentData.BaselineIsAmtDB);
            var feature       = ScatterPlotFactory.CreateFeatureMassScatterPlot(e.AligneeFeatures);
            var netHistogram  = HistogramFactory.CreateHistogram(alignmentData.NetErrorHistogram, "NET Error", "NET Error");
            var massHistogram = HistogramFactory.CreateHistogram(alignmentData.MassErrorHistogram, "Mass Error", "Mass Error (ppm)");
            var residuals     = alignmentData.ResidualData;

            var netResidual = ScatterPlotFactory.CreateResidualPlot(residuals.Net, residuals.LinearCustomNet,
                                                                    residuals.LinearNet, "NET Residuals", "Scans", "NET");
            var massMzResidual = ScatterPlotFactory.CreateResidualPlot(residuals.Mz, residuals.MzMassError,
                                                                       residuals.MzMassErrorCorrected, "Mass Residuals", "m/z", "Mass Errors");

            var massScanResidual = ScatterPlotFactory.CreateResidualPlot(residuals.Net, residuals.MzMassError,
                                                                         residuals.MzMassErrorCorrected, "Mass Residuals", "Scan", "Mass Errors");

            var report = Config.Report;

            report.PushLargeText(string.Format("Alignee Statistics - {0}", name));
            report.PushStartTable();

            // Features
            report.PushStartTableRow();
            report.PushTextHeader("Features");
            report.PushEndTableRow();
            report.PushStartTableRow();

            Config.Report.PushImageColumn(directory + "_features.png", WIDTH, HEIGHT);
            Config.Report.PushImageColumn(directory + "_heatmap.png", WIDTH, HEIGHT);
            PlotImageUtility.SaveImage(feature, directory + "_features.png");
            PlotImageUtility.SaveImage(heatmap, directory + "_heatmap.png");
            report.PushEndTableRow();

            // Histograms
            report.PushStartTableRow();
            report.PushTextHeader("Histograms");
            report.PushEndTableRow();
            report.PushStartTableRow();

            Config.Report.PushImageColumn(directory + "_netHistogram.png");
            Config.Report.PushImageColumn(directory + "_massHistogram.png");
            PlotImageUtility.SaveImage(netHistogram, directory + "_netHistogram.png");
            PlotImageUtility.SaveImage(massHistogram, directory + "_massHistogram.png");
            report.PushEndTableRow();

            // Residuals
            report.PushStartTableRow();
            report.PushTextHeader("Histograms");
            report.PushEndTableRow();
            report.PushStartTableRow();

            Config.Report.PushImageColumn(directory + "_netResidual.png");
            Config.Report.PushImageColumn(directory + "_massMzResidual.png");
            Config.Report.PushImageColumn(directory + "_massScanResidual.png");

            PlotImageUtility.SaveImage(netResidual, directory + "_netResidual.png");
            PlotImageUtility.SaveImage(massMzResidual, directory + "_massMzResidual.png");
            PlotImageUtility.SaveImage(massScanResidual, directory + "_massScanResidual.png");
            report.PushEndTableRow();

            report.PushEndTable();
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Updates the plots with data stored in the cache.
        /// </summary>
        private void UpdatePlotsWithClusterData(UMCClusterLightMatched matchedCluster)
        {
            //TODO: Make this select mass!
            ClusterMassPlot = ScatterPlotFactory.CreateFeatureMassScatterPlot(matchedCluster.Cluster.Features);

            //TODO: Make this select drift time!
            ClusterDriftPlot = ScatterPlotFactory.CreateFeatureDriftTimeScatterPlot(matchedCluster.Cluster.Features);

            var cluster = matchedCluster.Cluster;

            // Then we find all the nearby clusters
            var massPpm = ClusterTolerances.Mass;
            var net     = ClusterTolerances.Net;


            //TODO: Add other clusters back
            // var minMass = FeatureLight.ComputeDaDifferenceFromPPM(cluster.MassMonoisotopic, massPpm);
            //var maxMass = FeatureLight.ComputeDaDifferenceFromPPM(cluster.MassMonoisotopic, -massPpm);
            //var minNet = cluster.Net - net;
            //var maxNet = cluster.Net + net;

            //var otherClusters
            //    = SingletonDataProviders.Providers.ClusterCache.FindNearby(minMass, maxMass, minNet, maxNet);

            //// Remove self from the list
            //var index = otherClusters.FindIndex(x => x.Id == cluster.Id);

            //if (index > -1)
            //{
            //    otherClusters.RemoveAt(index);
            //}


            //// Then find the matching clusters and map them back to previously matched (to mass tag data)
            //var otherClusterMatches = new List<UMCClusterLightMatched>();
            //otherClusters.ForEach(x => otherClusterMatches.Add(FeatureCacheManager<UMCClusterLightMatched>.FindById(x.Id)));

            //foreach (var matchedOtherCluster in otherClusterMatches)
            //{
            //    matchedOtherCluster.Cluster.Features.Clear();
            //    matchedOtherCluster.Cluster.ReconstructUMCCluster(SingletonDataProviders.Providers, false, false);
            //}


            // Map out the MS/MS spectra.
            var msmsFeatures = new List <MSFeatureMsMs>();

            foreach (var feature in cluster.Features)
            {
                foreach (var msFeature in feature.MsFeatures)
                {
                    msmsFeatures.AddRange(msFeature.MSnSpectra.Select(spectrum => new MSFeatureMsMs
                    {
                        FeatureID               = msFeature.Id,
                        FeatureGroupID          = msFeature.GroupId,
                        Mz                      = msFeature.Mz,
                        PrecursorMZ             = spectrum.PrecursorMz,
                        FeatureScan             = msFeature.Scan,
                        MsMsScan                = spectrum.Scan,
                        MassMonoisotopicAligned = msFeature.MassMonoisotopicAligned,
                        ChargeState             = msFeature.ChargeState,
                        Sequence                = "",
                        PeptideSequence         = ""
                    }));
                }
            }


            var features = new List <UMCLight>();

            features.AddRange(matchedCluster.Cluster.Features);

            Features.Clear();
            features.ForEach(x => Features.Add(new UMCTreeViewModel(x)));
            SelectedFeature = Features[0];
        }