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);
        }
        public override void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            IIdentifiedResult            mr     = e.Item as IIdentifiedResult;
            IQuantificationSummaryOption option = e.Option as IQuantificationSummaryOption;

            string xTitle = MyConvert.Format("(Log({0}) + Log({1})) / 2", option.Func.ReferenceKey, option.Func.SampleKey);
            string yTitle = MyConvert.Format("Log(Ratio)");

            panel.InitGraphPane(title, xTitle, yTitle, true, 0.0);

            var groups = from g in mr
                         where option.IsProteinRatioValid(g[0])
                         select g;

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

                double maxX = 0.0;
                foreach (var group in groups)
                {
                    PointPairList ppl;
                    if (group.Selected)
                    {
                        ppl = pplSelected;
                    }
                    else if (option.IsProteinOutlier(group[0]))
                    {
                        ppl = pplOutlier;
                    }
                    else
                    {
                        ppl = pplNormal;
                    }

                    double int1 = Math.Log(option.Func.GetReferenceIntensity(group[0]));
                    double int2 = Math.Log(option.Func.GetSampleIntensity(group[0]));

                    double A     = (int1 + int2) / 2;
                    double ratio = Math.Log(option.GetProteinRatio(group[0]));
                    ppl.Add(A, ratio);
                    ppl[ppl.Count - 1].Tag = group;

                    Debug.Assert(ppl[ppl.Count - 1].Tag == group);

                    maxX = Math.Max(A, maxX);
                }

                this.panel.ClearData();

                var ratios = (from mpg in groups
                              let ratio = Math.Log(option.GetProteinRatio(mpg[0]))
                                          orderby ratio
                                          select ratio).ToList();

                panel.DrawProbabilityRange(maxX, ratios);

                this.panel.AddPoints(pplOutlier, OutlierColor, "Outlier");

                this.panel.AddPoints(pplSelected, GroupColor, "Current Protein");

                this.panel.AddPoints(pplNormal, NormalColor, "Other");
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcGraph);
            }
        }
        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, UpdateMRMPairedPeptideItemEventArgs e)
        {
            var summary = e.Item;

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

            var myMaster = zgcGraph.GraphPane;

            myMaster.Title.Text       = "Retention time ranges";
            myMaster.XAxis.Title.Text = "Files";
            myMaster.YAxis.Title.Text = "Retention time";
            myMaster.CurveList.Clear();
            try
            {
                var           splRange   = new PointPairList();
                var           splEnabled = new PointPairList();
                var           splAll     = new StockPointList();
                List <string> filenames  = new List <string>();
                int           index      = 0;

                List <double> median = new List <double>();
                for (int i = 0; i < summary.ProductIonPairs.Count; i++)
                {
                    if (summary.ProductIonPairs[i] == null)
                    {
                        continue;
                    }

                    index++;
                    filenames.Add(summary.ProductIonPairs[i].FileName);

                    var ints = summary.ProductIonPairs[i].Light.Intensities;
                    var low  = ints.First().RetentionTime;
                    var high = ints.Last().RetentionTime;

                    var firstEnabled = ints.Find(m => m.Enabled);
                    var open         = firstEnabled == null ? (low + high) / 2 : firstEnabled.RetentionTime;
                    var lastEnabled  = ints.FindLast(m => m.Enabled);
                    var close        = lastEnabled == null ? (low + high) / 2 : lastEnabled.RetentionTime;

                    median.Add((open + close) / 2);

                    splRange.Add(new PointPair(index, low, high));
                    splEnabled.Add(new PointPair(index, open, close));
                    splAll.Add(index, high, low, open, close, 1000);
                }
                myMaster.XAxis.Type             = AxisType.Text;
                myMaster.XAxis.Scale.TextLabels = filenames.ToArray();

                var item = myMaster.AddJapaneseCandleStick("", splAll);
                item.Stick.RisingFill  = new Fill(Color.Red);
                item.Stick.FallingFill = new Fill(Color.Blue);

                zgcGraph.AxisChange();
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcGraph);
            }
        }
        public void Update(object sender, UpdateMRMPairedProductIonEventArgs e)
        {
            panel.ClearData();

            var summary = e.Item;

            if (summary == null)
            {
                return;
            }

            var option = e.ViewOption;

            panel.Tag = summary;

            panel.ClearData();
            try
            {
                var    enabledCount = summary.EnabledScanCount;
                double maxLightIntensity, maxHeavyIntensity;
                if (enabledCount == 0)
                {
                    maxLightIntensity = summary.LightMaxIntensity;
                    maxHeavyIntensity = summary.HeavyMaxIntensity;
                }
                else
                {
                    maxLightIntensity = summary.LightMaxEnabledIntensity;
                    maxHeavyIntensity = summary.HeavyMaxEnabledIntensity;
                }
                var maxIntensity = Math.Max(maxLightIntensity, maxHeavyIntensity);

                if (summary.IsCurrent && option.ViewCurrentHighlight)
                {
                    panel.Chart.Fill = new Fill(Color.Cornsilk);
                }
                else
                {
                    panel.Chart.Fill = new Fill(Color.Transparent);
                }

                if (summary.Light != null && summary.Heavy != null && !option.ViewGreenLine)
                {
                    AddAbsoluteCurve(summary.Light, "Light", Color.Blue, DashStyle.Solid);
                    AddAbsoluteCurve(summary.Heavy, "Heavy", Color.Red, DashStyle.Dot);
                }
                else
                {
                    if (summary.Light != null)
                    {
                        AddAbsoluteCurve(summary.Light, "Light", Color.Blue, DashStyle.Solid);
                    }

                    if (summary.Heavy != null)
                    {
                        AddAbsoluteCurve(summary.Heavy, "Heavy", Color.Red, DashStyle.Solid);
                    }

                    if (option.ViewGreenLine)
                    {
                        if ((maxLightIntensity > maxHeavyIntensity) && (summary.Heavy != null))
                        {
                            AddAbsoluteCurve2(summary.Heavy, maxLightIntensity * 0.9 / maxHeavyIntensity, Color.Green);
                        }
                        else if (summary.Light != null)
                        {
                            AddAbsoluteCurve2(summary.Light, maxHeavyIntensity * 0.9 / maxLightIntensity, Color.Green);
                        }
                    }
                }

                var filename = string.IsNullOrEmpty(summary.FileName) ? "" : summary.FileName + "; ";
                if (summary.IsPaired)
                {
                    this.panel.Title.Text = filename + summary.GetFormula() + "\n" + summary.GetSignalToNoise();
                }
                else
                {
                    this.panel.Title.Text = filename + summary.GetSignalToNoise();
                }

                this.panel.Title.IsVisible = true;
                this.panel.YAxis.Scale.Min = 0;

                if (option.ViewType == DisplayType.PerfectSize || option.ViewType == DisplayType.FullHeight)
                {
                    var range = (from scan in summary.Light.Intensities
                                 where scan.Enabled
                                 orderby scan.RetentionTime
                                 select scan.RetentionTime).ToList();

                    if (range.Count > 0)
                    {
                        var minRt = range.First() - 1;
                        var maxRt = range.Last() + 1;

                        panel.XAxis.Scale.Min = minRt;
                        panel.XAxis.Scale.Max = maxRt;
                    }

                    if (option.ViewType == DisplayType.PerfectSize)
                    {
                        panel.YAxis.Scale.Max = maxIntensity * 1.2;
                    }
                }
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcGraph);
            }
        }
示例#6
0
        private void UpdateCurve()
        {
            foreach (GraphPane pane in zgcCurve.MasterPane.PaneList)
            {
                pane.ClearData();
            }

            try
            {
                if (lvPrecursor.SelectedItems.Count == 0)
                {
                    return;
                }

                GraphPane graphScans = zgcCurve.MasterPane.PaneList[0];
                GraphPane graphPPM   = zgcCurve.MasterPane.PaneList[1];

                var pplScan = new PointPairList();
                var pplPPM  = new PointPairList();

                var  pplScanCurve = new PointPairList();
                bool bChecked     = false;

                double precursorMz = MyConvert.ToDouble(lvPrecursor.SelectedItems[0].Text);
                var    identified  = new PointPairList();

                foreach (ListViewItem item in this.lvScans.Items)
                {
                    if (item == null)
                    {
                        return;
                    }

                    if (item.Checked != bChecked)
                    {
                        if (pplScanCurve.Count > 0 && bChecked)
                        {
                            graphScans.AddPoly("", pplScanCurve, Color.Blue, new[] { PLOY_COLOR });
                        }
                        pplScanCurve = new PointPairList();
                        bChecked     = item.Checked;
                    }

                    LabelFreeItem c = (LabelFreeItem)item.Tag;

                    pplScan.Add(new PointPair(c.Scan, c.AdjustIntensity));
                    pplScanCurve.Add(new PointPair(c.Scan, c.AdjustIntensity));
                    pplPPM.Add(new PointPair(c.Scan, c.DeltaMzPPM));
                    if (c.Identified)
                    {
                        identified.Add(new PointPair(c.Scan, c.AdjustIntensity));
                    }
                }

                if (pplScanCurve.Count > 0 && bChecked)
                {
                    graphScans.AddPoly("", pplScanCurve, Color.Blue, new[] { PLOY_COLOR });
                }

                graphScans.AddCurve(precursorMz.ToString(), pplScan, Color.Blue, SymbolType.None);
                graphPPM.AddCurve(precursorMz.ToString(), pplPPM, Color.Blue, SymbolType.None);
                graphScans.AddIndividualLine("Identified", identified, Color.Red);
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcCurve);
            }
        }
        public void UpdateMaxIntensity(double maxIntensity)
        {
            panel.YAxis.Scale.Max = maxIntensity;

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

            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);
            }
        }
示例#9
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);
            }
        }
        private void lvPeptides_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvPeptides.SelectedItems.Count > 0)
            {
                var spectrum = lvPeptides.SelectedItems[0].Tag as IIdentifiedSpectrum;
                var file     = ProteinChromatographProcessor.GetTargetFile(GetOriginFile(), rawFile.FullName, SpectrumToChro(spectrum));
                var chro     = new SimplePeakChroXmlFormat().ReadFromFile(file);

                try
                {
                    zgcScans.ClearData(false);

                    var mainPane = ZedGraphicExtension.InitMasterPanel(zgcScans, CreateGraphics(), 2, "Chromotograph");

                    if (chro.Peaks.Count > 0)
                    {
                        var pplSample = new PointPairList();
                        var pplppm    = new PointPairList();
                        var bFirst    = true;
                        foreach (ScanPeak p in chro.Peaks)
                        {
                            pplSample.Add(p.RetentionTime, p.Intensity);
                            pplppm.Add(p.RetentionTime, p.PPMDistance);
                            //if (p.Intensity > 0)
                            //{
                            //  pplSample.Add(p.RetentionTime, p.Intensity);
                            //  pplppm.Add(p.RetentionTime, p.PPMDistance);
                            //}
                            //else if (pplSample.Count > 0)
                            //{
                            //  if (bFirst)
                            //  {
                            //    mainPane.PaneList[0].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplSample, Color.Red, SymbolType.None);
                            //    mainPane.PaneList[1].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplppm, Color.Red, SymbolType.None);
                            //  }
                            //  else
                            //  {
                            //    mainPane.PaneList[0].AddCurve("a", pplSample, Color.Red, SymbolType.None);
                            //    mainPane.PaneList[1].AddCurve("a", pplppm, Color.Red, SymbolType.None);
                            //  }

                            //  pplSample.Clear();
                            //  pplppm.Clear();
                            //  bFirst = false;
                            //}
                        }

                        if (pplSample.Count > 0)
                        {
                            if (bFirst)
                            {
                                mainPane.PaneList[0].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplSample, Color.Red, SymbolType.None);
                                mainPane.PaneList[1].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplppm, Color.Red, SymbolType.None);
                            }
                            else
                            {
                                mainPane.PaneList[0].AddCurve("a", pplSample, Color.Red, SymbolType.None);
                                mainPane.PaneList[1].AddCurve("a", pplppm, Color.Red, SymbolType.None);
                            }
                        }
                    }
                }
                finally
                {
                    ZedGraphicExtension.UpdateGraph(zgcScans);
                }
            }
        }
示例#11
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);
        }
示例#12
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);
        }
        public override void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            IQuantificationSummaryOption option = e.Option as IQuantificationSummaryOption;
            IIdentifiedResult            mr     = e.Item as IIdentifiedResult;

            string xTitle = MyConvert.Format("(Log({0}) + Log({1})) / 2", option.Func.ReferenceKey, option.Func.SampleKey);
            string yTitle = MyConvert.Format("Log(Ratio)");

            panel.InitGraphPane(title, xTitle, yTitle, true, 0.0);

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

                var groups = from g in mr
                             where g[0].IsEnabled(true) && option.IsProteinRatioValid(g[0])
                             select g;

                HashSet <IIdentifiedSpectrum> spectra = new HashSet <IIdentifiedSpectrum>();

                double        maxX = 0.0;
                PointPairList ppl;
                foreach (var mpg in groups)
                {
                    var peptides = from p in mpg.GetPeptides()
                                   where p.IsEnabled(true) && option.IsPeptideRatioValid(p)
                                   select p;

                    spectra.UnionWith(peptides);

                    foreach (var pep in peptides)
                    {
                        if (pep.Selected)
                        {
                            ppl = pplSelected;
                        }
                        else if (mpg.Selected)
                        {
                            ppl = pplGroup;
                        }
                        else if (option.IsPeptideOutlier(pep))
                        {
                            ppl = pplOutlier;
                        }
                        else
                        {
                            ppl = pplNormal;
                        }

                        double refIntensity    = Math.Log(option.Func.GetReferenceIntensity(pep));
                        double sampleIntensity = Math.Log(option.Func.GetSampleIntensity(pep));

                        double A     = (refIntensity + sampleIntensity) / 2;
                        double ratio = Math.Log(option.GetPeptideRatio(pep));
                        ppl.Add(A, ratio);
                        ppl[ppl.Count - 1].Tag = new Pair <IIdentifiedProteinGroup, IIdentifiedSpectrum>(mpg, pep);

                        maxX = Math.Max(A, maxX);
                    }
                }

                this.panel.ClearData();

                var ratios = (from pep in spectra
                              let ratio = Math.Log(option.GetPeptideRatio(pep))
                                          orderby ratio
                                          select ratio).ToList();

                this.panel.DrawProbabilityRange(maxX, ratios);

                this.panel.AddPoints(pplSelected, SelectedColor, "Current Peptide");
                this.panel.AddPoints(pplGroup, GroupColor, "Current Protein");
                this.panel.AddPoints(pplOutlier, OutlierColor, "Outlier");
                this.panel.AddPoints(pplNormal, NormalColor, "Other");
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcGraph);
            }
        }
        public override void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            IQuantificationSummaryOption option = e.Option as IQuantificationSummaryOption;
            IIdentifiedResult            mr     = e.Item as IIdentifiedResult;

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

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

                var groups = from g in mr
                             where option.IsProteinRatioValid(g[0])
                             select g;

                HashSet <IIdentifiedSpectrum> spectra = new HashSet <IIdentifiedSpectrum>();

                double        maxX = 0.0;
                PointPairList ppl;
                foreach (var mpg in groups)
                {
                    var peptides = from p in mpg.GetPeptides()
                                   where option.IsPeptideRatioValid(p)
                                   select p;

                    spectra.UnionWith(peptides);

                    foreach (var pep in peptides)
                    {
                        if (pep.Selected)
                        {
                            ppl = pplSelected;
                        }
                        else if (mpg.Selected)
                        {
                            ppl = pplGroup;
                        }
                        else if (option.IsPeptideOutlier(pep))
                        {
                            ppl = pplOutlier;
                        }
                        else
                        {
                            ppl = pplNormal;
                        }

                        double refIntensity = option.Func.GetReferenceIntensity(pep);
                        double samIntensity = option.Func.GetSampleIntensity(pep);

                        ppl.Add(refIntensity, samIntensity);
                        ppl[ppl.Count - 1].Tag = new Pair <IIdentifiedProteinGroup, IIdentifiedSpectrum>(mpg, pep);

                        maxX = Math.Max(refIntensity, maxX);
                    }
                }

                this.panel.ClearData();

                this.panel.AddPoints(pplSelected, SelectedColor, "Current Peptide");
                this.panel.AddPoints(pplGroup, GroupColor, "Current Protein");
                this.panel.AddPoints(pplOutlier, OutlierColor, "Outlier");
                this.panel.AddPoints(pplNormal, NormalColor, "Other");

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

                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 lrrr = pplTotal.GetRegression();

                    PointPairList line = pplTotal.GetRegressionLine(lrrr.Ratio);

                    var lineItem = this.panel.AddCurve(MyConvert.Format("Ratio={0:0.0000}, R2={1:0.0000}", lrrr.Ratio, lrrr.RSquare), line, Color.Red, SymbolType.None);
                }
            }
            finally
            {
                ZedGraphicExtension.UpdateGraph(this.zgcGraph);
            }
        }
        private void lbPeptides_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbPeptides.SelectedItem != null)
            {
                DigestPeptideInfo dpi = lbPeptides.SelectedItem as DigestPeptideInfo;

                lbPrecursor.BeginUpdate();
                try
                {
                    lbPrecursor.Items.Clear();
                    List <SimplePeakChro> peaks = (List <SimplePeakChro>)dpi.Annotations[CHRO_KEY];

                    var validPeaks = (from p in peaks
                                      where p.Peaks.Count > 0
                                      select p).ToList();

                    try
                    {
                        if (validPeaks.Count == 0)
                        {
                            ZedGraphicExtension.InitMasterPanel(zgcScans, CreateGraphics(), 1, "Chromotograph");
                            zgcScans.MasterPane.PaneList[0].ClearData();
                            return;
                        }

                        var mainPane = ZedGraphicExtension.InitMasterPanel(zgcScans, CreateGraphics(), validPeaks.Count, "Chromotograph");
                        int index    = 0;
                        foreach (var chro in peaks)
                        {
                            lbPrecursor.Items.Add(chro);
                            if (chro.Peaks.Count > 0)
                            {
                                var pplSample = new PointPairList();
                                foreach (ScanPeak p in chro.Peaks)
                                {
                                    pplSample.Add(p.Scan, p.Intensity);
                                }

                                mainPane.PaneList[index].AddCurve(MyConvert.Format("{0:0.0000},{1}", chro.Mz, chro.Charge), pplSample, Color.Red, SymbolType.None);
                                //mainPane.PaneList[index].XAxis.Scale.Min = 0;
                                //mainPane.PaneList[index].XAxis.Scale.Max = chro.MaxRetentionTime;

                                index++;
                            }
                        }
                    }
                    finally
                    {
                        ZedGraphicExtension.UpdateGraph(zgcScans);
                    }
                }
                finally
                {
                    lbPrecursor.EndUpdate();
                }

                lbIdentified.Items.Clear();
                if (ir != null)
                {
                    if (pepMap.ContainsKey(dpi.PeptideSeq))
                    {
                        lbIdentified.BeginUpdate();
                        try
                        {
                            var ids = pepMap[dpi.PeptideSeq];
                            foreach (var id in ids)
                            {
                                lbIdentified.Items.Add(MyConvert.Format("[{0}; {1}]", id.Query.FileScan.FirstScan, id.Charge));
                            }
                        }
                        finally
                        {
                            lbIdentified.EndUpdate();
                        }
                    }
                }
            }
        }
示例#16
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 pplOutlier  = new PointPairList();

                var spectra = group.GetPeptides();

                foreach (var pep in spectra)
                {
                    if (option.IsPeptideRatioValid(pep))
                    {
                        PointPairList ppl;
                        if (pep.Selected)
                        {
                            ppl = pplSelected;
                        }
                        else if (option.IsPeptideOutlier(pep))
                        {
                            ppl = pplOutlier;
                        }
                        else
                        {
                            ppl = pplNormal;
                        }

                        double sampleIntensity = option.Func.GetSampleIntensity(pep);
                        double refIntensity    = option.Func.GetReferenceIntensity(pep);
                        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);

                this.panel.AddPoints(pplOutlier, OutlierColor);

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

                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 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 override void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            IQuantificationSummaryOption option = e.Option as IQuantificationSummaryOption;
            IIdentifiedResult            mr     = e.Item as IIdentifiedResult;

            panel.InitGraphPane(title, option.Func.ReferenceKey, option.Func.SampleKey, true, 0.0);
            try
            {
                var pplNormal   = new PointPairList();
                var pplSelected = new PointPairList();
                var pplOutlier  = new PointPairList();

                var groups = (from g in mr
                              where option.IsProteinRatioValid(g[0])
                              select g).ToList();

                foreach (var group in groups)
                {
                    PointPairList ppl;
                    if (group.Selected)
                    {
                        ppl = pplSelected;
                    }
                    else if (option.IsProteinOutlier(group[0]))
                    {
                        ppl = pplOutlier;
                    }
                    else
                    {
                        ppl = pplNormal;
                    }

                    double sampleIntensity = option.Func.GetSampleIntensity(group[0]);
                    double refIntensity    = option.Func.GetReferenceIntensity(group[0]);
                    ppl.Add(refIntensity, sampleIntensity);
                    ppl[ppl.Count - 1].Tag = group;

                    Debug.Assert(ppl[ppl.Count - 1].Tag == group);
                }

                this.panel.ClearData();

                this.panel.AddPoints(pplOutlier, OutlierColor, "Outlier");

                this.panel.AddPoints(pplSelected, GroupColor, "Current Protein");

                this.panel.AddPoints(pplNormal, NormalColor, "Other");

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

                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 lrrr = pplTotal.GetRegression();

                    PointPairList line = pplTotal.GetRegressionLine(lrrr.Ratio);

                    var lineItem = this.panel.AddCurve(MyConvert.Format("Ratio={0:0.0000}", lrrr.Ratio), line, Color.Red, SymbolType.None);
                }
            }
            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);
            }
        }