private void mnuOpen_Click(object sender, EventArgs e)
        {
            var dlg = new ITraqOpenFileDialog();

            dlg.LoadOption();

            if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                proteinFile = dlg.ProteinFile;
                itrapFile   = dlg.ITraqFile;

                var paramFile = Path.ChangeExtension(dlg.ProteinFile, "param");
                if (!File.Exists(paramFile))
                {
                    MessageBox.Show(this, "Error find parameter file " + paramFile);
                    return;
                }

                option = new ITraqProteinStatisticOption();
                option.LoadFromFile(paramFile);

                Progress.Begin();

                var task = Task.Factory.StartNew(() => LoadData(), TaskCreationOptions.LongRunning);
                task.ContinueWith((m) => this.Invoke(new Action(UpdateData)), TaskContinuationOptions.OnlyOnRanToCompletion);
            }
        }
Ejemplo n.º 2
0
 public ITraqUniquePeptideStatisticBuilder(ITraqProteinStatisticOption option, bool isSiteLevel, string fastaFile, IAccessNumberParser parser)
     : base(option)
 {
     this.isSiteLevel = isSiteLevel;
     this.fastaFile   = fastaFile;
     this.parser      = parser;
 }
Ejemplo n.º 3
0
        protected ITraqProteinStatisticOption GetStatisticOption()
        {
            ITraqProteinStatisticOption option = new ITraqProteinStatisticOption();

            option.DatasetMap                   = pnlClassification.GetClassificationSet();
            option.ITraqFileName                = iTraqFile.FullName;
            option.MinimumProbability           = filterPeptide.Checked ? minProbability.Value : 0.0;
            option.NormalizeByMedianRatio       = normalize.Checked;
            option.RatioPeptideToProteinBuilder = builders.SelectedItem;
            option.QuantifyModifiedPeptideOnly  = modifiedPeptideOnly.Checked;
            option.ModificationChars            = modifiedChar.Text;
            option.References                   = itraqIons.GetFuncs();
            return(option);
        }
        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 AbstractITraqProteinStatisticBuilder(ITraqProteinStatisticOption option)
 {
     this.option    = option;
     this.ratioCalc = option.GetRatioCalculator();
 }
Ejemplo n.º 6
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 ITraqProteinStatisticBuilder(ITraqProteinStatisticOption option)
     : base(option)
 {
 }