Esempio n. 1
0
        private void ProcessPeptideQuantitationReport2()
        {
            KeyValuePair <List <FastaItem>, List <PepQuant> > kvp = UniQTools.ParsePeptideReport(peptideQuantitationReportFile);

            //Some error checking
            if (classLabels.Count > kvp.Value[0].MyQuants[0].MarkerIntensities.Count)
            {
                MessageBox.Show("Parameter Min no Quants per reading cannot be greater than number of channels specidied in the class menu.");
                return;
            }

            if (classLabels.Count != kvp.Value[0].MyQuants[0].MarkerIntensities.Count)
            {
                MessageBox.Show("Make sure you properly labeled your class labels followed with spaces as they do not match those from the peptide quantitation report.");
                return;
            }

            UniQTools.ScorePepQuants(classLabels, kvp.Value);

            MyPeptides   = kvp.Value;
            MyFastaItems = kvp.Key;

            protPepDict = new Dictionary <FastaItem, List <PepQuant> >();


            //Parallel.ForEach(MyFastaItems, fi =>
            foreach (FastaItem fi in MyFastaItems)
            {
                List <PepQuant> pepts = MyPeptides.FindAll(a => fi.Sequence.Contains(a.CleanPeptideSequence));

                if (pepts.Count > 0)
                {
                    protPepDict.Add(fi, pepts);
                }

                foreach (PepQuant pq in pepts)
                {
                    pq.MappableProteins.Add(fi.SequenceIdentifier);
                }
            }
            //);

            return;
        }
Esempio n. 2
0
        public void UpdateGUI()
        {
            //Lets take care of which peptides to consider in our analysis
            if ((bool)CheckBoxConsiderOnlyUniquePeptides.IsChecked)
            {
                myPeptidesTMP = MyPeptides.FindAll(a => a.MappableProteins.Count == 1);
            }
            else
            {
                myPeptidesTMP = MyPeptides.FindAll(a => a.MappableProteins.Count > 0);
            }

            int removedFold = myPeptidesTMP.RemoveAll(a => Math.Abs(a.AVGLogFold) < Math.Round((double)DoubleUpDownPeptideLogFold.Value, 2));

            ///Need to fix here....
            int removedProb1 = myPeptidesTMP.RemoveAll(a => (a.TTest > Math.Round((double)DoubleUpDownPeptidePValueCutoff.Value, 2)));

            List <PepQuant> survival = MyPeptides.FindAll(a => !myPeptidesTMP.Exists(b => b.Sequence.Equals(a.Sequence)));

            protPepDictTMP = new Dictionary <FastaItem, List <PepQuant> >();

            //New way
            foreach (FastaItem fi in MyFastaItems)
            {
                List <PepQuant> pepts = myPeptidesTMP.FindAll(a => a.MappableProteins.Contains(fi.SequenceIdentifier));
                if (pepts.Count > 0)
                {
                    protPepDictTMP.Add(fi, pepts);
                }
            }

            try
            {
                var protDisplay = from kvp in protPepDictTMP
                                  where kvp.Value.Count >= IntegerUpDown.Value
                                  select new
                {
                    ProtID             = kvp.Key.SequenceIdentifier,
                    Daltons            = Math.Round(kvp.Key.MonoisotopicMass, 2),
                    PeptideCount       = kvp.Value.Count,
                    UniquePeptideCount = kvp.Value.Count(a => a.MappableProteins.Count == 1),
                    SpecCount          = protPepDictTMP[kvp.Key].Sum(a => a.MyQuants.Count),
                    AvgLogFold         = Math.Round(kvp.Value.Average(a => a.AVGLogFold), 3),
                    StouffersPValue    = ProteinPValue(kvp.Value),
                    Coverage           = GenerateMicroChart(kvp),
                    Description        = kvp.Key.Description
                };

                int noProteins = protDisplay.Count();
                LabelNoProteins.Content = noProteins;

                if (noProteins == 0)
                {
                    MessageBox.Show("No protein satisfies current constraints.");
                    return;
                }

                //Find out how many peptides and spec counts are there

                List <PepQuant> validPepQuants = new List <PepQuant>();

                if ((bool)CHeckBoxShowPeptidesOfFilteredProteinsOnly.IsChecked)
                {
                    List <string> IDsProteinsDisplay = protDisplay.Select(a => a.ProtID).ToList();
                    foreach (string pID in IDsProteinsDisplay)
                    {
                        FastaItem fi = MyFastaItems.Find(a => a.SequenceIdentifier.Equals(pID));
                        validPepQuants.AddRange(protPepDictTMP[fi]);
                    }

                    validPepQuants = validPepQuants.Distinct().ToList();
                }
                else
                {
                    validPepQuants = MyPeptides;
                }

                DataGridAllPeptidesView.ItemsSource = validPepQuants.Select
                                                          (a => new
                {
                    Sequence            = a.Sequence,
                    Binomial_PValue     = Math.Round(a.BinomialProbability, 4),
                    Paired_TTest_Pvalue = Math.Round(a.TTest, 4),
                    AVGLogFold          = Math.Round(a.AVGLogFold, 4),
                    Redundancy          = a.MappableProteins.Count,
                    SpecCount           = a.MyQuants.Count,
                    MissingValues       = a.MissingValues,
                    MappableProts       = string.Join(" ", (
                                                          from prot in protDisplay
                                                          where a.MappableProteins.Contains(prot.ProtID)
                                                          select "(" + prot.ProtID + "::" + prot.Description + ")").ToList()
                                                      )
                }
                                                          );


                LabelNoPeptides.Content            = validPepQuants.Count();
                LabelSpecCount.Content             = validPepQuants.Sum(a => a.MyQuants.Count);
                LabelAvgFilteredPepLogFold.Content = Math.Round(validPepQuants.Average(a => a.AVGLogFold), 3);

                DataGridProteinView.ItemsSource = protDisplay;


                myPeptidesTMP = validPepQuants;

                double correctedP = PatternTools.pTools.BenjaminiHochbergFDR(0.01, protDisplay.Select(a => a.StouffersPValue).ToList(), false);
                LabelCorrectedP.Content = correctedP;

                LabelTotalPeptides.Content = MyPeptides.Count;
            }
            catch (Exception) { return; }
            //Update the graphs
            PlotQuants();
        }