public ZedGraphITraqSpectrum(ZedGraphControl zgcGraph, Graphics g, string title)
        {
            this.zgcGraph = zgcGraph;

            zgcGraph.InitMasterPanel(g, 2, title, PaneLayout.SingleColumn);

            scanItraq       = new ZedGraphScanITraq(zgcGraph, zgcGraph.MasterPane[0], false);
            isolationWindow = new ZedGraphScanIsolationWindow(zgcGraph, zgcGraph.MasterPane[1]);

            ZedGraphicExtension.UpdateGraph(zgcGraph);
        }
Esempio n. 2
0
        public MatchImageBuilder(string mgfFile, string targetDir)
        {
            var mgfReader = new Mascot.MascotGenericFormatReader <MatchedPeak>();
            var spectra   = mgfReader.ReadFromFile(mgfFile);

            spectra.ForEach(m => m.Experimental = m.Experimental.Substring(0, m.Experimental.Length - 4));
            mgfMap = spectra.ToDictionary(m => string.Format("{0}_{1}", m.Experimental, m.ScanTimes[0].Scan));

            var mods = new Dictionary <char, double>();

            mods['&'] = 7.017166;
            mods['#'] = 3.010071;
            mods['@'] = 6.013809;
            mods['*'] = 15.994919;
            mods['C'] = 57.021464 + aas['C'].MonoMass; // 160.16523;
            mods['K'] = 8.014206 + aas['K'].MonoMass;
            mods['R'] = 10.008270 + aas['R'].MonoMass;

            aas.SetModification(mods);

            yBuilder = new CIDPeptideYSeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            bBuilder = new CIDPeptideBSeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            y2Builder = new CIDPeptideY2SeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };
            b2Builder = new CIDPeptideB2SeriesBuilder <MatchedPeak>()
            {
                CurAminoacids = aas
            };

            zgcPeaks        = new ZedGraphControl();
            zgcPeaks.Width  = 1600;
            zgcPeaks.Height = 1200;
            zgcPeaks.MasterPane.Border.IsVisible = false;

            zgcPeaks.InitMasterPanel(Graphics.FromImage(zgcPeaks.GetImage()), 2, "");
            zgcPeaks.IsSynchronizeXAxes = true;

            if (!Directory.Exists(targetDir))
            {
                Directory.CreateDirectory(targetDir);
            }
            this.targetDir = targetDir;
        }
Esempio n. 3
0
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            var spectra = e.Item as IEnumerable <IIdentifiedSpectrum>;

            if (spectra == null)
            {
                throw new ArgumentException("e.Item should be IEnumerable<IIdentifiedSpectrum>");
            }

            var validItems = (from spectrum in spectra
                              let item = spectrum.FindIsobaricItem()
                                         where null != item
                                         select item).ToList();

            zgcGraph.InitMasterPanel(g, validItems.Count, title, this.pl);
            for (int i = 0; i < validItems.Count; i++)
            {
                new ZedGraphScanITraq(zgcGraph, zgcGraph.MasterPane[i], false).Update(sender, new UpdateQuantificationItemEventArgs(null, validItems[i]));
            }

            ZedGraphicExtension.UpdateGraph(zgcGraph);
        }
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            ITraqProteinStatisticOption option = e.Option as ITraqProteinStatisticOption;

            IIdentifiedProteinGroup protein = null;

            if (e.Item is IEnumerable <IIdentifiedSpectrum> )
            {
                var spectra = e.Item as IEnumerable <IIdentifiedSpectrum>;
                protein = new IdentifiedProteinGroup();
                protein.Add(new IdentifiedProtein());
                protein[0].Peptides.AddRange(from s in spectra select s.Peptide);
            }
            else if (e.Item is IIdentifiedProteinGroup)
            {
                protein = e.Item as IIdentifiedProteinGroup;
            }

            if (protein == null)
            {
                throw new ArgumentException("e.Item should be IIdentifiedProteinGroup or IEnumerable<IIdentifiedSpectrum>");
            }

            var validItem = protein[0].Peptides.FirstOrDefault(m =>
            {
                var item = m.Spectrum.FindIsobaricItem();
                return(null != item && item.Valid);
            });

            if (null == validItem)
            {
                zgcGraph.ClearData(true);
                return;
            }

            var masterPane = zgcGraph.InitMasterPanel(g, 1, title, this.pl);

            var panel = masterPane[0];

            var samples = option.GetSamples(validItem.Spectrum.FindIsobaricItem().PlexType);

            var dsNames = option.DatasetMap.Keys.OrderBy(m => m).ToList();

            var ratioCalc = option.GetRatioCalculator();

            xlabels.Clear();

            double index      = 0.0;
            string outlierStr = "Outlier";
            string proteinStr = "Protein Ratio";

            foreach (var dsName in dsNames)
            {
                var expNames = new HashSet <string>(option.DatasetMap[dsName]);
                foreach (var sample in samples)
                {
                    index += 1.0;

                    ratioCalc.GetSample   = sample.GetValue;
                    ratioCalc.DatasetName = dsName;
                    ratioCalc.ChannelName = sample.ChannelRatioName;
                    ratioCalc.Filter      = m => expNames.Contains(m.Query.FileScan.Experimental);
                    var ratios = ratioCalc.Calculate(protein);

                    xlabels.Add(dsName + ":" + sample.Name);

                    if (ratios.Count > 0)
                    {
                        var ratio = protein[0].FindITraqChannelItem(dsName, sample.ChannelRatioName).Ratio;

                        PointPairList pplNormal       = new PointPairList();
                        PointPairList pplOutlier      = new PointPairList();
                        PointPairList pplProteinRatio = new PointPairList();
                        foreach (var r in ratios)
                        {
                            if (r.IsOutlier)
                            {
                                pplOutlier.Add(new PointPair(index, Math.Log(r.Ratio)));
                            }
                            else
                            {
                                pplNormal.Add(new PointPair(index, Math.Log(r.Ratio)));
                            }
                        }
                        pplProteinRatio.Add(new PointPair(index, Math.Log(ratio)));

                        panel.AddPoints(pplProteinRatio, Color.Red, proteinStr);
                        if (pplOutlier.Count > 0)
                        {
                            panel.AddPoints(pplOutlier, Color.Green, outlierStr);
                            outlierStr = string.Empty;
                        }

                        panel.AddPoints(pplNormal, Color.Black);
                        proteinStr = string.Empty;
                    }
                }
            }

            panel.XAxis.ScaleFormatEvent    += new Axis.ScaleFormatHandler(XAxis_ScaleFormatEvent);
            panel.XAxis.Scale.Min            = 0.0;
            panel.XAxis.Scale.Max            = index + 1.0;
            panel.XAxis.Scale.FontSpec.Angle = 90;
            panel.YAxis.Title.Text           = "log(Ratio)";

            ZedGraphicExtension.UpdateGraph(zgcGraph);
        }
Esempio n. 5
0
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            ITraqProteinStatisticOption option = e.Option as ITraqProteinStatisticOption;

            IIdentifiedProteinGroup protein = null;

            if (e.Item is IEnumerable <IIdentifiedSpectrum> )
            {
                var spectra = e.Item as IEnumerable <IIdentifiedSpectrum>;
                protein = new IdentifiedProteinGroup();
                protein.Add(new IdentifiedProtein());
                protein[0].Peptides.AddRange(from s in spectra select s.Peptide);
            }
            else if (e.Item is IIdentifiedProteinGroup)
            {
                protein = e.Item as IIdentifiedProteinGroup;
            }

            if (protein == null)
            {
                throw new ArgumentException("e.Item should be IIdentifiedProteinGroup or IEnumerable<IIdentifiedSpectrum>");
            }

            var validItem = protein[0].Peptides.FirstOrDefault(m =>
            {
                var item = m.Spectrum.FindIsobaricItem();
                return(null != item && item.Valid);
            });

            if (null == validItem)
            {
                zgcGraph.ClearData(true);
                return;
            }

            var masterPane = zgcGraph.InitMasterPanel(g, 1, title, this.pl);

            var panel = masterPane[0];

            var samples = option.GetSamples(validItem.Spectrum.FindIsobaricItem().PlexType);

            var dsNames = option.DatasetMap.Keys.OrderBy(m => m).ToList();

            var ratioCalc = option.GetRatioCalculator();

            List <string> xlabels = new List <string>();

            List <PointPairList> outliers = new List <PointPairList>();
            List <PointPairList> normals  = new List <PointPairList>();
            PointPairList        proteins = new PointPairList();

            //按照数据集循环
            foreach (var dsName in dsNames)
            {
                var expNames = new HashSet <string>(option.DatasetMap[dsName]);
                //按照样品循环
                foreach (var sample in samples)
                {
                    ratioCalc.GetSample   = sample.GetValue;
                    ratioCalc.DatasetName = dsName;
                    ratioCalc.ChannelName = sample.ChannelRatioName;
                    ratioCalc.Filter      = m => expNames.Contains(m.Query.FileScan.Experimental);
                    var ratios = ratioCalc.Calculate(protein);

                    //添加相应的分类名
                    xlabels.Add(dsName + ":" + sample.Name);

                    //每个分类有三种数据:outlier,normal和proteinratio
                    var outlier = new PointPairList();
                    outliers.Add(outlier);
                    var normal = new PointPairList();
                    normals.Add(normal);

                    if (ratios.Count > 0)
                    {
                        var ratio = protein[0].FindITraqChannelItem(dsName, sample.ChannelRatioName).Ratio;
                        proteins.Add(new PointPair()
                        {
                            Y = Math.Log(ratio)
                        });

                        ratios.ForEach(m =>
                        {
                            if (m.IsOutlier)
                            {
                                outlier.Add(new PointPair()
                                {
                                    Y = Math.Log(m.Ratio)
                                });
                            }
                            else
                            {
                                normal.Add(new PointPair()
                                {
                                    Y = Math.Log(m.Ratio)
                                });
                            }
                        });
                    }
                    else
                    {
                        //缺失值用missing表示。
                        proteins.Add(new PointPair()
                        {
                            Y = PointPair.Missing
                        });
                    }
                }
            }
            panel.AddPoints(proteins, Color.Red, "Ratio");
            AddOrdinalPoints(outliers, panel, Color.Green, "Outlier");
            AddOrdinalPoints(normals, panel, Color.Black, "");

            panel.XAxis.Type = AxisType.Text;
            panel.XAxis.Scale.FontSpec.Angle = 90;
            panel.XAxis.Scale.TextLabels     = xlabels.ToArray();
            panel.YAxis.Title.Text           = "log(Ratio)";

            ZedGraphicExtension.UpdateGraph(zgcGraph);
        }