public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            panel.ClearData();
            var summary = e.Item as IsobaricItem;

            if (null != summary)
            {
                if (summary.PeakInIsolationWindow.Count > 0)
                {
                    var pplWinPrecursor = new PointPairList();
                    foreach (var peak in summary.PeakInIsolationWindow)
                    {
                        if (peak.Tag > 0)
                        {
                            pplWinPrecursor.Add(new PointPair(peak.Mz, peak.Intensity, string.Format("{0:0.00000}", peak.Mz)));
                        }
                        else
                        {
                            pplWinPrecursor.Add(new PointPair(peak.Mz, peak.Intensity));
                        }
                    }

                    panel.AddIndividualLine("", pplWinPrecursor, Color.Black, Color.Blue);

                    panel.Title.Text = string.Format("Isolation Window (Specifity = {0:0.00}%)", summary.PrecursorPercentage * 100);
                }
            }

            ZedGraphicExtension.UpdateGraph(zgcGraph);
        }
 protected void OnUpdateSpectrum(UpdateQuantificationItemEventArgs e)
 {
     if (UpdateSpectrum != null)
     {
         UpdateSpectrum(this, e);
     }
 }
    public void Update(object sender, UpdateQuantificationItemEventArgs e)
    {
      var summary = e.Item as O18QuantificationSummaryItem;
      if (summary == null)
      {
        throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null");
      }

      panel.ClearData();
      try
      {
        int firstScan = summary.ObservedEnvelopes.First().Scan;
        int lastScan = summary.ObservedEnvelopes.Last().Scan;

        var ppms = summary.GetPPMList();

        var O16PPMs = GetPoints(firstScan, lastScan, ppms, m => m.O16);
        var O181PPMs = GetPoints(firstScan, lastScan, ppms, m => m.O181);
        var O182PPMs = GetPoints(firstScan, lastScan, ppms, m => m.O182);

        panel.AddCurve("O16", O16PPMs, O18QuantificationConstants.COLOR_O16, SymbolType.None);
        panel.AddCurve("O18(1)", O181PPMs, O18QuantificationConstants.COLOR_O18_1, SymbolType.None);
        panel.AddCurve("O18(2)", O182PPMs, O18QuantificationConstants.COLOR_O18_2, SymbolType.None);
      }
      finally
      {
        ZedGraphicExtension.UpdateGraph(this.zgcGraph);
      }
    }
Example #4
0
        private void DoUpdateItem()
        {
            foreach (ListViewItem item in lvExperimentalScans.Items)
            {
                (item.Tag as QuanEnvelope).IsSelected = item.Selected;
            }

            var e = new UpdateQuantificationItemEventArgs(options, summary);

            OnUpdateItem(e);
        }
        private void DoUpdateProtein(TreeNode node, bool forceRefresh = false)
        {
            if (proteinNode != node || forceRefresh)
            {
                proteinNode = node;

                var args = new UpdateQuantificationItemEventArgs(option, node.Tag);

                new ZedGraphITraqProtein2(zgcProtein, this.CreateGraphics(), "Protein").Update(null, args);
            }
        }
        private void DoUpdateUniquePeptide(TreeNode node, bool forceRefresh = false)
        {
            if (uniquePeptideNode != node || forceRefresh)
            {
                var args = new UpdateQuantificationItemEventArgs(option, node.Tag);

                new ZedGraphITraqProtein2(zgcUniquePeptide, this.CreateGraphics(), "Unique Peptide").Update(null, args);

                uniquePeptideNode = node;

                DoUpdateProtein(node.Parent);
            }
        }
        private void DoUpdateSpectrum(TreeNode node)
        {
            var spectrum = node.Tag as IIdentifiedSpectrum;

            var itraqItem = spectrum.FindIsobaricItem();

            var args = new UpdateQuantificationItemEventArgs(null, itraqItem);

            OnUpdateSpectrum(args);

            DoUpdateUniquePeptide(node.Parent);

            DoUpdateProtein(node.Parent.Parent);
        }
Example #8
0
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            var summary = e.Item as SilacQuantificationSummaryItem;

            if (summary == null)
            {
                throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null");
            }

            var pplRed   = new PointPairList();
            var pplGreen = new PointPairList();

            var enabled = summary.ObservedEnvelopes.FindAll(m => m.Enabled);

            enabled.ForEach(m =>
            {
                PointPairList ppl = m.IsSelected ? pplGreen : pplRed;
                if (summary.SampleIsLight)
                {
                    ppl.Add(new PointPair(m.HeavyIntensity, m.LightIntensity, 0.0, m));
                }
                else
                {
                    ppl.Add(new PointPair(m.LightIntensity, m.HeavyIntensity, 0.0, m));
                }
            });

            ZedGraphicExtension.ClearData(this.zgcGraph, false);

            AddCurve(pplGreen, SilacQuantificationConstants.REFERENCE_COLOR);
            AddCurve(pplRed, SilacQuantificationConstants.SAMPLE_COLOR);

            var pplTotal = new PointPairList();

            pplTotal.AddRange(pplRed);
            pplTotal.AddRange(pplGreen);

            if (pplTotal.Count > 0)
            {
                PointPairList line = ZedGraphicExtension.GetRegressionLine(pplTotal, summary.Ratio);

                ZedGraphicExtension.AddDataToLine(this.zgcGraph, MyConvert.Format("Ratio = {0:0.0000}, Correlation = {1:0.0000}", summary.Ratio,
                                                                                  summary.RegressionCorrelation), line, SilacQuantificationConstants.IDENTIFIED_COLOR, false);
            }

            ZedGraphicExtension.UpdateGraph(this.zgcGraph);
        }
Example #9
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)
        {
            panel.ClearData();

            var summary = e.Item as IsobaricItem;

            if (null != summary)
            {
                var pplData = new PointPairList();
                if (summary.RawPeaks.Count > 0)
                {
                    foreach (var peak in summary.RawPeaks)
                    {
                        pplData.Add(new PointPair(peak.Mz, peak.Intensity));
                    }
                }
                else
                {
                    var definitions = summary.Definition.Items;
                    foreach (var def in definitions)
                    {
                        pplData.Add(new PointPair(def.Index, summary[def.Index]));
                    }
                }
                panel.AddIndividualLine("", pplData, Color.Black);

                panel.XAxis.Scale.Min = summary.Definition.MinIndex - 1;
                panel.XAxis.Scale.Max = summary.Definition.MaxIndex + 1;

                panel.Title.Text = string.Format("{0},{1}", summary.Experimental, summary.Scan);
            }

            if (updateGraph)
            {
                ZedGraphicExtension.UpdateGraph(zgcGraph);
            }
        }
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            var summary = e.Item as SilacQuantificationSummaryItem;

            if (summary == null)
            {
                throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null");
            }

            panel.ClearData();
            try
            {
                var lightCorrel = new PointPairList();
                foreach (var entry in summary.ObservedEnvelopes)
                {
                    lightCorrel.Add(new PointPair(entry.Scan, entry.LightCorrelation));
                }

                var heavyCorrel = new PointPairList();
                foreach (var entry in summary.ObservedEnvelopes)
                {
                    heavyCorrel.Add(new PointPair(entry.Scan, entry.HeavyCorrelation));
                }

                var sampleCorrel = summary.SampleIsLight ? lightCorrel : heavyCorrel;
                var refCorrel    = summary.SampleIsLight ? heavyCorrel : lightCorrel;
                panel.AddCurve("Sample", sampleCorrel, SilacQuantificationConstants.SAMPLE_COLOR, SymbolType.None);
                panel.AddCurve("Reference", refCorrel, SilacQuantificationConstants.REFERENCE_COLOR, SymbolType.None);
                panel.YAxis.Scale.Min = 0.0;
                panel.YAxis.Scale.Max = 1.2;
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcGraph);
            }
        }
 public void Update(object sender, UpdateQuantificationItemEventArgs e)
 {
     scanItraq.Update(sender, e);
     isolationWindow.Update(sender, e);
 }
Example #13
0
 public void Update(object sender, UpdateQuantificationItemEventArgs e)
 {
     zgcProfiles.Update(e.Item as SilacQuantificationSummaryItem);
 }
Example #14
0
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            var summary = e.Item as O18QuantificationSummaryItem;

            if (summary == null)
            {
                throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null");
            }

            panel.ClearData();

            var pplO16   = new PointPairList();
            var pplO18_1 = new PointPairList();
            var pplO18_2 = new PointPairList();

            var pplO16Curve   = new PointPairList();
            var pplO18_1Curve = new PointPairList();
            var pplO18_2Curve = new PointPairList();

            var identified  = new PointPairList();
            var currentScan = new PointPairList();

            bool bChecked = false;

            for (int i = 0; i < summary.ObservedEnvelopes.Count; i++)
            {
                var envelope = summary.ObservedEnvelopes[i];
                if (envelope.Enabled != bChecked)
                {
                    if (pplO16Curve.Count > 0)
                    {
                        if (bChecked)
                        {
                            panel.AddPoly("", pplO16Curve, O18QuantificationConstants.COLOR_O16, new[] { O18QuantificationConstants.COLOR_PLOY });
                            panel.AddPoly("", pplO18_1Curve, O18QuantificationConstants.COLOR_O18_1, new[] { O18QuantificationConstants.COLOR_PLOY });
                            panel.AddPoly("", pplO18_2Curve, O18QuantificationConstants.COLOR_O18_2, new[] { O18QuantificationConstants.COLOR_PLOY });
                        }
                    }
                    pplO16Curve   = new PointPairList();
                    pplO18_1Curve = new PointPairList();
                    pplO18_2Curve = new PointPairList();
                    bChecked      = envelope.Enabled;
                }

                pplO16.Add(envelope.Scan, envelope[0].Intensity);
                pplO18_1.Add(envelope.Scan, envelope[2].Intensity);
                pplO18_2.Add(envelope.Scan, envelope[4].Intensity);

                pplO16Curve.Add(envelope.Scan, envelope[0].Intensity);
                pplO18_1Curve.Add(envelope.Scan, envelope[2].Intensity);
                pplO18_2Curve.Add(envelope.Scan, envelope[4].Intensity);

                if (envelope.IsIdentified)
                {
                    identified.Add(envelope.Scan, new double[] { envelope[0].Intensity, envelope[2].Intensity, envelope[4].Intensity }.Max());
                }

                if (envelope.IsSelected)
                {
                    currentScan.Add(envelope.Scan, new double[] { envelope[0].Intensity, envelope[2].Intensity, envelope[4].Intensity }.Max());
                }
            }

            if (pplO16Curve.Count > 0)
            {
                if (bChecked)
                {
                    panel.AddPoly("", pplO16Curve, O18QuantificationConstants.COLOR_O16, new[] { O18QuantificationConstants.COLOR_PLOY });
                    panel.AddPoly("", pplO18_1Curve, O18QuantificationConstants.COLOR_O18_1, new[] { O18QuantificationConstants.COLOR_PLOY });
                    panel.AddPoly("", pplO18_2Curve, O18QuantificationConstants.COLOR_O18_2, new[] { O18QuantificationConstants.COLOR_PLOY });
                }
            }

            panel.AddCurve("O16", pplO16, O18QuantificationConstants.COLOR_O16, SymbolType.None);
            panel.AddCurve("O18(1)", pplO18_1, O18QuantificationConstants.COLOR_O18_1, SymbolType.None);
            panel.AddCurve("O18(2)", pplO18_2, O18QuantificationConstants.COLOR_O18_2, SymbolType.None);

            panel.AddIndividualLine("Identified", identified, O18QuantificationConstants.COLOR_IDENTIFIED);
            panel.AddIndividualLine("CurrentScan", currentScan, Color.Black);

            ZedGraphicExtension.UpdateGraph(zgcGraph);
        }
Example #15
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);
        }
 public void Update(object sender, UpdateQuantificationItemEventArgs e)
 {
     zgcScan.Update(sender, e);
     zgcPPM.Update(sender, e);
     zgcCorrelation.Update(sender, e);
 }
        public override void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            IQuantificationSummaryOption option = e.Option as IQuantificationSummaryOption;

            panel.InitGraphPane(this.title, option.Func.ReferenceKey, option.Func.SampleKey, true, 0.0);

            IIdentifiedProteinGroup group = e.Item as IIdentifiedProteinGroup;

            try
            {
                var pplNormal   = new PointPairList();
                var pplSelected = new PointPairList();

                var spectra = group.GetPeptides();

                var format = new SilacQuantificationSummaryItemXmlFormat();

                foreach (var pep in spectra)
                {
                    if (option.IsPeptideRatioValid(pep))
                    {
                        string ratioFile = GetRatioFile(option, pep);
                        if (ratioFile == null)
                        {
                            continue;
                        }

                        var item = format.ReadFromFile(ratioFile);

                        Func <SilacPeakListPair, double> getSamIntensity;
                        Func <SilacPeakListPair, double> getRefIntensity;

                        if (item.SampleIsLight)
                        {
                            getSamIntensity = m => m.LightIntensity;
                            getRefIntensity = m => m.HeavyIntensity;
                        }
                        else
                        {
                            getSamIntensity = m => m.HeavyIntensity;
                            getRefIntensity = m => m.LightIntensity;
                        }

                        PointPairList ppl;
                        if (pep.Selected)
                        {
                            ppl = pplSelected;
                        }
                        else
                        {
                            ppl = pplNormal;
                        }

                        foreach (var envelope in item.ObservedEnvelopes)
                        {
                            if (!envelope.Enabled)
                            {
                                continue;
                            }

                            double refIntensity    = getRefIntensity(envelope);
                            double sampleIntensity = getSamIntensity(envelope);

                            if (refIntensity == 0.0 || sampleIntensity == 0.0)
                            {
                                continue;
                            }

                            ppl.Add(refIntensity, sampleIntensity);
                            ppl[ppl.Count - 1].Tag = pep;

                            Debug.Assert(ppl[ppl.Count - 1].Tag == pep);
                        }
                    }
                }
                this.panel.ClearData();

                this.panel.AddPoints(pplSelected, SelectedColor);

                this.panel.AddPoints(pplNormal, NormalColor);

                var pplTotal = new PointPairList();
                pplTotal.AddRange(pplSelected);
                pplTotal.AddRange(pplNormal);

                if (pplTotal.Count > 0)
                {
                    var           lr      = pplTotal.GetRegression();
                    var           lr_text = MyConvert.Format("Ratio={0:0.00}, Correl={1:0.00}, FValue={2:0.00}, FProb={3:E4}", lr.Ratio, lr.RSquare, lr.TValue, lr.PValue);
                    PointPairList line    = pplTotal.GetRegressionLine();

                    var lineItem = this.panel.AddCurve(lr_text, line, RegressionLineColor, SymbolType.None);
                    lineItem.Label.FontSpec = new FontSpec()
                    {
                        Size = 15, Border = new Border()
                        {
                            IsVisible = false
                        }
                    };
                }
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.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);
        }
 public void Update(object sender, UpdateQuantificationItemEventArgs e)
 {
     updates.Update(sender, e);
 }
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            var summary = e.Item as SilacQuantificationSummaryItem;

            if (summary == null)
            {
                throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null");
            }

            ZedGraphicExtension.ClearData(zgcGraph, false);
            try
            {
                var envelope = summary.ObservedEnvelopes.Find(m => m.IsSelected);
                if (envelope == null)
                {
                    return;
                }

                double minMz = envelope.Light[0].Mz - 1.0;
                double maxMz = envelope.Heavy[envelope.Heavy.Count - 1].Mz + 1.0;

                zgcGraph.GraphPane.XAxis.Scale.Min = minMz;
                zgcGraph.GraphPane.XAxis.Scale.Max = maxMz;

                var pplLight = new PointPairList();
                envelope.Light.ForEach(p => pplLight.Add(p.Mz, p.Intensity));

                var pplHeavy = new PointPairList();
                envelope.Heavy.ForEach(p => pplHeavy.Add(p.Mz, p.Intensity));

                if (summary.SampleIsLight)
                {
                    ZedGraphicExtension.AddIndividualLine(zgcGraph, "Sample", pplLight, SilacQuantificationConstants.SAMPLE_COLOR, false);
                    ZedGraphicExtension.AddIndividualLine(zgcGraph, "Reference", pplHeavy, SilacQuantificationConstants.REFERENCE_COLOR, false);
                }
                else
                {
                    ZedGraphicExtension.AddIndividualLine(zgcGraph, "Sample", pplHeavy, SilacQuantificationConstants.SAMPLE_COLOR, false);
                    ZedGraphicExtension.AddIndividualLine(zgcGraph, "Reference", pplLight, SilacQuantificationConstants.REFERENCE_COLOR, false);
                }

                // Shift the text items up by 5 user scale units above the bars
                const float shift = 5;

                var ppl = new PointPairList();
                ppl.AddRange(pplLight);
                ppl.AddRange(pplHeavy);
                for (int i = 0; i < ppl.Count; i++)
                {
                    // format the label string to have 1 decimal place
                    string lab = ppl[i].X.ToString("0.00");
                    // create the text item (assumes the x axis is ordinal or text)
                    // for negative bars, the label appears just above the zero value
                    var text = new TextObj(lab, ppl[i].X, ppl[i].Y + shift);
                    // tell Zedgraph to use user scale units for locating the TextItem
                    text.Location.CoordinateFrame = CoordType.AxisXYScale;
                    // AlignH the left-center of the text to the specified point
                    text.Location.AlignH           = AlignH.Left;
                    text.Location.AlignV           = AlignV.Center;
                    text.FontSpec.Border.IsVisible = false;
                    text.FontSpec.Fill.IsVisible   = false;
                    // rotate the text 90 degrees
                    text.FontSpec.Angle = 90;
                    // add the TextItem to the list
                    zgcGraph.GraphPane.GraphObjList.Add(text);
                }

                if (File.Exists(summary.RawFilename))
                {
                    if (rawFile == null)
                    {
                        rawFile = new RawFileImpl(summary.RawFilename);
                    }
                    else if (!rawFile.FileName.Equals(summary.RawFilename))
                    {
                        rawFile.Open(summary.RawFilename);
                    }

                    PeakList <Peak> pkl    = rawFile.GetPeakList(envelope.Light.ScanTimes[0].Scan);
                    var             pplRaw = new PointPairList();
                    pplRaw.Add(minMz, 0.0);
                    for (int i = 0; i < pkl.Count; i++)
                    {
                        if (pkl[i].Mz < minMz)
                        {
                            continue;
                        }
                        else if (pkl[i].Mz > maxMz)
                        {
                            break;
                        }
                        pplRaw.Add(pkl[i].Mz, -pkl[i].Intensity);
                    }
                    pplRaw.Add(maxMz, 0.0);

                    ZedGraphicExtension.AddIndividualLine(zgcGraph, "PeakList From RawFile", pplRaw, SilacQuantificationConstants.IDENTIFIED_COLOR, true);
                }
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(zgcGraph);
            }
        }
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            var summary = e.Item as SilacQuantificationSummaryItem;

            if (summary == null)
            {
                throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null");
            }

            double sampleMz;
            double referenceMz;

            if (summary.SampleIsLight)
            {
                sampleMz    = summary.ObservedEnvelopes[0].Light[0].Mz;
                referenceMz = summary.ObservedEnvelopes[0].Heavy[0].Mz;
            }
            else
            {
                sampleMz    = summary.ObservedEnvelopes[0].Heavy[0].Mz;
                referenceMz = summary.ObservedEnvelopes[0].Light[0].Mz;
            }

            panel.ClearData();

            var pplSample    = new PointPairList();
            var pplReference = new PointPairList();

            var  pplSampleCurve    = new PointPairList();
            var  pplReferenceCurve = new PointPairList();
            bool bChecked          = false;

            for (int i = 0; i < summary.ObservedEnvelopes.Count; i++)
            {
                var envelope = summary.ObservedEnvelopes[i];
                if (envelope.Enabled != bChecked)
                {
                    if (pplSampleCurve.Count > 0)
                    {
                        if (bChecked)
                        {
                            panel.AddPoly("", pplSampleCurve, SilacQuantificationConstants.SAMPLE_COLOR, new[] { SilacQuantificationConstants.PLOY_COLOR });
                            panel.AddPoly("", pplReferenceCurve, SilacQuantificationConstants.REFERENCE_COLOR, new[] { SilacQuantificationConstants.PLOY_COLOR });
                        }
                    }
                    pplSampleCurve    = new PointPairList();
                    pplReferenceCurve = new PointPairList();
                    bChecked          = envelope.Enabled;
                }

                if (summary.SampleIsLight)
                {
                    pplSampleCurve.Add(envelope.Scan, envelope.LightIntensity);
                    pplReferenceCurve.Add(envelope.Scan, envelope.HeavyIntensity);
                    pplSample.Add(envelope.Scan, envelope.LightIntensity);
                    pplReference.Add(envelope.Scan, envelope.HeavyIntensity);
                }
                else
                {
                    pplSampleCurve.Add(envelope.Scan, envelope.LightIntensity);
                    pplReferenceCurve.Add(envelope.Scan, envelope.HeavyIntensity);
                    pplSample.Add(envelope.Scan, envelope.HeavyIntensity);
                    pplReference.Add(envelope.Scan, envelope.LightIntensity);
                }
            }

            if (pplSampleCurve.Count > 0)
            {
                if (bChecked)
                {
                    panel.AddPoly("", pplSampleCurve, SilacQuantificationConstants.SAMPLE_COLOR, new[] { SilacQuantificationConstants.PLOY_COLOR });
                    panel.AddPoly("", pplReferenceCurve, SilacQuantificationConstants.REFERENCE_COLOR, new[] { SilacQuantificationConstants.PLOY_COLOR });
                }
            }

            panel.AddCurve("Sample", pplSample, SilacQuantificationConstants.SAMPLE_COLOR, SymbolType.None);
            panel.AddCurve("Reference", pplReference, SilacQuantificationConstants.REFERENCE_COLOR, SymbolType.None);

            var identified = new PointPairList();

            summary.ObservedEnvelopes.FindAll(m => m.IsIdentified).ForEach(m =>
            {
                identified.Add(new PointPair(m.Scan, m.LightIntensity));
                identified.Add(new PointPair(m.Scan, m.HeavyIntensity));
            });
            panel.AddIndividualLine("Identified", identified, SilacQuantificationConstants.IDENTIFIED_COLOR);

            var currentScan = new PointPairList();

            summary.ObservedEnvelopes.FindAll(m => m.IsSelected).ForEach(m =>
            {
                currentScan.Add(new PointPair(m.Scan, Math.Max(m.LightIntensity, m.HeavyIntensity)));
            });
            if (currentScan.Count > 0)
            {
                panel.AddIndividualLine("CurrentScan", currentScan, Color.Black);
            }

            ZedGraphicExtension.UpdateGraph(zgcGraph);
        }
Example #22
0
        public void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            var summary = e.Item as SilacQuantificationSummaryItem;

            if (summary == null)
            {
                throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null");
            }

            panel.ClearData();
            try
            {
                int firstScan = summary.ObservedEnvelopes.First().Scan;
                int lastScan  = summary.ObservedEnvelopes.Last().Scan;

                var samplePPMList = summary.GetSamplePPMList();
                var refPPMList    = summary.GetReferencePPMList();

                var samplePPMs    = GetPoints(firstScan, lastScan, samplePPMList);
                var referencePPMs = GetPoints(firstScan, lastScan, refPPMList);

                panel.AddCurve("Sample", samplePPMs, SilacQuantificationConstants.SAMPLE_COLOR, SymbolType.None);
                panel.AddCurve("Reference", referencePPMs, SilacQuantificationConstants.REFERENCE_COLOR, SymbolType.None);

                var identified = new PointPairList();
                summary.ObservedEnvelopes.FindAll(m => m.IsIdentified).ForEach(m =>
                {
                    if (samplePPMList.ContainsKey(m))
                    {
                        identified.Add(new PointPair(m.Scan, samplePPMList[m]));
                    }
                    if (refPPMList.ContainsKey(m))
                    {
                        identified.Add(new PointPair(m.Scan, refPPMList[m]));
                    }
                });
                panel.AddIndividualLine("Identified", identified, SilacQuantificationConstants.IDENTIFIED_COLOR);

                var selected = new PointPairList();
                summary.ObservedEnvelopes.FindAll(m => m.IsSelected).ForEach(m =>
                {
                    if (samplePPMList.ContainsKey(m))
                    {
                        selected.Add(new PointPair(m.Scan, samplePPMList[m]));
                    }
                    if (refPPMList.ContainsKey(m))
                    {
                        selected.Add(new PointPair(m.Scan, refPPMList[m]));
                    }
                });

                if (selected.Count > 0)
                {
                    panel.AddIndividualLine("CurrentScan", selected, Color.Black);
                }

                panel.YAxis.Scale.Min = -10;
                panel.YAxis.Scale.Max = 10;
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcGraph);
            }
        }
Example #23
0
        public override void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            IQuantificationSummaryOption option = e.Option as IQuantificationSummaryOption;

            panel.InitGraphPane(title, option.Func.ReferenceKey, option.Func.SampleKey, true, 0.0);

            IIdentifiedProteinGroup group = e.Item as IIdentifiedProteinGroup;

            try
            {
                var pplNormal   = new PointPairList();
                var pplSelected = new PointPairList();

                var spectra = group.GetPeptides();

                var format = new O18QuantificationSummaryItemXmlFormat();

                foreach (var pep in spectra)
                {
                    if (pep.IsEnabled(true) && option.IsPeptideRatioValid(pep))
                    {
                        string ratioFile = GetRatioFile(option, pep);
                        if (ratioFile == null)
                        {
                            continue;
                        }

                        O18QuantificationSummaryItem item = new O18QuantificationSummaryItemXmlFormat().ReadFromFile(ratioFile);
                        item.CalculateIndividualAbundance();

                        PointPairList ppl;
                        if (pep.Selected)
                        {
                            ppl = pplSelected;
                        }
                        else
                        {
                            ppl = pplNormal;
                        }

                        foreach (var envelope in item.ObservedEnvelopes)
                        {
                            if (!envelope.Enabled)
                            {
                                continue;
                            }

                            double refIntensity    = envelope.SampleAbundance.O16;
                            double sampleIntensity = envelope.SampleAbundance.O18;

                            if (refIntensity == 0.0 || sampleIntensity == 0.0)
                            {
                                continue;
                            }

                            ppl.Add(refIntensity, sampleIntensity);
                            ppl[ppl.Count - 1].Tag = pep;

                            Debug.Assert(ppl[ppl.Count - 1].Tag == pep);
                        }
                    }
                }
                this.panel.ClearData();

                this.panel.AddPoints(pplSelected, SelectedColor);

                this.panel.AddPoints(pplNormal, NormalColor);

                var pplTotal = new PointPairList();
                pplTotal.AddRange(pplSelected);
                pplTotal.AddRange(pplNormal);

                if (pplTotal.Count > 0)
                {
                    var maxValue = (from p in pplTotal
                                    select Math.Max(p.X, p.Y)).Max() * 1.1;

                    this.panel.XAxis.Scale.Max = maxValue;
                    this.panel.YAxis.Scale.Max = maxValue;

                    var ratio = option.GetProteinRatio(group[0]);

                    PointPairList line = pplTotal.GetRegressionLine(ratio);

                    var lineItem = this.panel.AddCurve(option.GetProteinRatioDescription(group[0]), line, RegressionLineColor, SymbolType.None);
                    lineItem.Label.FontSpec = new FontSpec()
                    {
                        Size = 15, Border = new Border()
                        {
                            IsVisible = false
                        }
                    };
                }
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcGraph);
            }
        }
        public override void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            var summary = e.Item as O18QuantificationSummaryItem;

            if (summary == null)
            {
                throw new ArgumentNullException("UpdateQuantificationItemEventArgs.Item cannot be null");
            }

            panel.InitGraphPane(this.title, "m/z", "Intensity", true, 0.0);

            ZedGraphicExtension.ClearData(zgcGraph, false);
            try
            {
                var envelope = summary.ObservedEnvelopes.Find(m => m.IsSelected);
                if (envelope == null)
                {
                    return;
                }

                panel.InitGraphPane(this.title + ", Scan=" + envelope.Scan.ToString(), "m/z", "Intensity", true, 0.0);

                double minMz = envelope[0].Mz - 1.0;
                double maxMz = envelope[envelope.Count - 1].Mz + 1.0;

                zgcGraph.GraphPane.XAxis.Scale.Min = minMz;
                zgcGraph.GraphPane.XAxis.Scale.Max = maxMz;

                var ppl = new PointPairList();
                envelope.ForEach(p => { if (p.Intensity > 0)
                                        {
                                            ppl.Add(p.Mz, p.Intensity);
                                        }
                                 });
                panel.AddIndividualLine("Isotopic Envelope", ppl, Color.Red);
                panel.AddTextUp(ppl, 5, (m => m.X.ToString("0.0000")));

                var halfMax = (from env in envelope
                               select env.Intensity).Max() / 2;
                ppl.Clear();
                envelope.ForEach(p => { if (p.Intensity == 0)
                                        {
                                            ppl.Add(p.Mz, halfMax);
                                        }
                                 });
                panel.AddIndividualLine("", ppl, defaultColor: Color.Red, dStyle: DashStyle.Dash);
                panel.AddTextUp(ppl, 5, (m => m.X.ToString("0.0000")));

                if (File.Exists(summary.RawFilename))
                {
                    if (rawFile == null)
                    {
                        rawFile = RawFileFactory.GetRawFileReader(summary.RawFilename);
                    }
                    else if (!rawFile.FileName.Equals(summary.RawFilename))
                    {
                        rawFile.Close();
                        rawFile = RawFileFactory.GetRawFileReader(summary.RawFilename);
                    }

                    PeakList <Peak> pkl    = rawFile.GetPeakList(envelope.ScanTimes[0].Scan);
                    var             pplRaw = new PointPairList();
                    for (int i = 0; i < pkl.Count; i++)
                    {
                        if (pkl[i].Mz < minMz)
                        {
                            continue;
                        }
                        else if (pkl[i].Mz > maxMz)
                        {
                            break;
                        }
                        pplRaw.Add(pkl[i].Mz, -pkl[i].Intensity);
                    }

                    panel.AddIndividualLine("PeakList From RawFile", pplRaw, Color.Blue);
                    panel.AddTextDown(pplRaw, 5, (m => m.X.ToString("0.0000")));

                    /*
                     * foreach (var p in ppl)
                     * {
                     * if (p.Y == 0)
                     * {
                     *  double ppm = double.MaxValue;
                     *  double ppmAbs = Math.Abs(ppm);
                     *  foreach (var pp in pplRaw)
                     *  {
                     *    double ppmCur = PrecursorUtils.mz2ppm(pp.X, pp.X - p.X);
                     *    double ppmCurAbs = Math.Abs(ppmCur);
                     *    if (Math.Abs(ppmCur) < ppmAbs)
                     *    {
                     *      ppm = ppmCur;
                     *      ppmAbs = ppmCurAbs;
                     *    }
                     *
                     *    if (pp.X > p.X)
                     *    {
                     *      break;
                     *    }
                     *  }
                     *
                     *  p.Z = ppm;
                     * }
                     * }
                     */
                }
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(zgcGraph);
            }
        }