Ejemplo n.º 1
0
        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
            {
                HashSet <IIdentifiedSpectrum> spectra = new HashSet <IIdentifiedSpectrum>();

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

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

                    spectra.UnionWith(peptides);
                }

                List <LSPADItem> items = new List <LSPADItem>();
                foreach (var pep in spectra)
                {
                    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));

                    items.Add(new LSPADItem()
                    {
                        LogRatio  = ratio,
                        Intensity = A,
                        Tag       = pep
                    });
                }

                LSPADItem.CalculatePValue(items);



                //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);
            }
        }
 protected void OnUpdatePeptide(UpdateQuantificationItemEventArgs e)
 {
     if (UpdatePeptide != null)
     {
         UpdatePeptide(this, e);
     }
 }
 protected void OnUpdateResult(UpdateQuantificationItemEventArgs e)
 {
     if (UpdateResult != null)
     {
         UpdateResult(this, e);
     }
 }
 protected void OnUpdateProtein(UpdateQuantificationItemEventArgs e)
 {
     if (UpdateProtein != null)
     {
         UpdateProtein(this, e);
     }
 }
        private void DoUpdatePeptide()
        {
            if (this.mr != null)
            {
                if (tabPeptide == tabControl1.SelectedTab)
                {
                    if (lvPeptides.SelectedItems.Count == 0)
                    {
                        return;
                    }

                    var mph       = lvPeptides.SelectedItems[0].Tag as IIdentifiedSpectrum;
                    var ratioFile = GetRatioFile(mph);

                    if (ratioFile == null || ratioFile.Equals("-"))
                    {
                        return;
                    }

                    var summary = option.ReadRatioFile(ratioFile);
                    var e       = new UpdateQuantificationItemEventArgs(option, summary);

                    OnUpdatePeptide(e);
                }
            }
        }
 public void Update(object sender, UpdateQuantificationItemEventArgs e)
 {
     foreach (var item in Updates)
     {
         item.Update(sender, e);
     }
 }
        private void DoUpdateResult()
        {
            if (this.mr != null)
            {
                if (tabProteins == tabControl1.SelectedTab || tabPeptides == tabControl1.SelectedTab)
                {
                    var e = new UpdateQuantificationItemEventArgs(option, mr);

                    OnUpdateResult(e);
                }
            }
        }
        private void DoUpdateProtein()
        {
            if (this.mr != null)
            {
                if (tabProtein == tabControl1.SelectedTab)
                {
                    if (lvProteins.SelectedItems.Count == 0)
                    {
                        return;
                    }

                    var mpg = lvProteins.SelectedItems[0].Tag as IIdentifiedProteinGroup;

                    var e = new UpdateQuantificationItemEventArgs(option, mpg);

                    OnUpdateProtein(e);
                }
            }
        }
        public override void Update(object sender, UpdateQuantificationItemEventArgs e)
        {
            IExtendQuantificationSummaryOption option = e.Option as IExtendQuantificationSummaryOption;
            string xTitle = string.Format("Log({0})", option.Func.ReferenceKey);
            string yTitle = string.Format("Log({0})", option.Func.SampleKey);

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

            IIdentifiedProteinGroup group = e.Item as IIdentifiedProteinGroup;

            try
            {
                Dictionary <string, List <PointPairList> > pplMap = new Dictionary <string, List <PointPairList> >();

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

                var spectra = group.GetPeptides();

                foreach (var pep in spectra)
                {
                    if (pep.IsEnabled(true) && option.IsPeptideRatioValid(pep))
                    {
                        var key = option.GetPeptideClassification(pep);

                        if (!pplMap.ContainsKey(key))
                        {
                            var lst = new List <PointPairList>();
                            pplMap[key] = lst;
                            lst.Add(new PointPairList()); //selected
                            lst.Add(new PointPairList()); //outlier
                            lst.Add(new PointPairList()); //normal
                        }

                        var ppls = pplMap[key];

                        PointPairList ppl;
                        if (pep.Selected)
                        {
                            ppl = ppls[0];
                        }
                        else if (option.IsPeptideOutlier(pep))
                        {
                            ppl = ppls[1];
                        }
                        else
                        {
                            ppl = ppls[2];
                        }

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

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

                this.panel.ClearData();

                foreach (var key in pplMap.Keys)
                {
                    var ppls = pplMap[key];
                    this.panel.AddPoints(ppls[0], SelectedColor);

                    this.panel.AddPoints(ppls[1], NormalColor);

                    this.panel.AddPoints(ppls[2], OutlierColor);

                    var pplTotal = new PointPairList();
                    pplTotal.AddRange(ppls[0]);
                    pplTotal.AddRange(ppls[1]);
                    pplTotal.AddRange(ppls[2]);

                    if (pplTotal.Count > 0)
                    {
                        PointPairList line = ZedGraphicExtension.GetRegressionLine(pplTotal, option.GetProteinRatio(group[0], key));

                        var lineItem = this.panel.AddCurve(option.GetProteinRatioDescription(group[0], key), 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)
        {
            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);
            }
        }
Ejemplo n.º 11
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 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);
            }
        }
        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 abstract void Update(object sender, UpdateQuantificationItemEventArgs e);
        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);
            }
        }