Exemple #1
0
        public static void FdrThresholding(string[] rawFiles, string decoyPrefix, double peptideFdr, double peptidePep,
                                           MascotQueryType type, bool perFileThreshold, bool debug, HashSet <string> sequences,
                                           bool onlyCollectSequences, IProteinSet proteinSet,
                                           HashSet <string> labelModificationSet, IIdentificationProvider ip)
        {
            CalcFdr(rawFiles, decoyPrefix, type, proteinSet, debug, labelModificationSet, ip);
            double pepThreshVal;

            double[] pepThreshVals = new double[rawFiles.Length];
            if (peptideFdr < 1)
            {
                for (int i = 0; i < rawFiles.Length; i++)
                {
                    pepThreshVals[i] = FindReverseHitThresholdValue(ip.GetIdentifications(rawFiles[i], type), peptideFdr,
                                                                    decoyPrefix, proteinSet);
                    ip.Dispose();
                    if (peptidePep < 1)
                    {
                        pepThreshVals[i] = Math.Min(pepThreshVals[i], peptidePep);
                    }
                }
                pepThreshVal = ArrayUtil.Median(pepThreshVals);
                if (peptidePep < 1)
                {
                    pepThreshVal = Math.Min(pepThreshVal, peptidePep);
                }
            }
            else
            {
                for (int i = 0; i < rawFiles.Length; i++)
                {
                    pepThreshVals[i] = peptidePep;
                }
                pepThreshVal = peptidePep;
            }
            if (onlyCollectSequences)
            {
                for (int i = 0; i < rawFiles.Length; i++)
                {
                    CollectSequences(ip.GetIdentifications(rawFiles[i], type),
                                     perFileThreshold ? pepThreshVals[i] : pepThreshVal, sequences);
                    ip.Dispose();
                }
            }
            else
            {
                for (int i = 0; i < rawFiles.Length; i++)
                {
                    ApplyReverseHitThreshold(ip.GetIdentifications(rawFiles[i], type),
                                             perFileThreshold ? pepThreshVals[i] : pepThreshVal);
                    ip.Dispose();
                }
            }
        }
Exemple #2
0
 private static void LimitPep(string[] rawFiles, MascotQueryType type, IIdentificationProvider ip)
 {
     for (int i = 0; i < rawFiles.Length; i++)
     {
         Identifications ident = ip.GetIdentifications(rawFiles[i], type);
         int             n     = ident.Count;
         for (int j = 0; j < n; j++)
         {
             MascotPeptide p = ident.GetPeptidesAt(j)[0];
             p.Pep = Math.Min(p.Pep, 1);
         }
         ident.Write();
         ip.Dispose();
     }
 }
Exemple #3
0
        private static void CalcFdr(string[] rawFiles, string decoyPrefix, MascotQueryType type, IProteinSet proteinSet, bool debug,
                                    IIdentificationProvider ip)
        {
            List <bool>   correct = new List <bool>();
            List <double> scores  = new List <double>();
            List <double> seqLen  = new List <double>();

            for (int i = 0; i < rawFiles.Length; i++)
            {
                Identifications ident = ip.GetIdentifications(rawFiles[i], type);
                int             n     = ident.Count;
                for (int j = 0; j < n; j++)
                {
                    bool   c = ident.IsHighestScoringCorrect(j, decoyPrefix, proteinSet);
                    double s = ident.GetHighestAltScore(j);
                    double l = Math.Log(ident.GetBestSequence(j).Length);
                    if (!double.IsNaN(s) && !double.IsInfinity(s))
                    {
                        correct.Add(c);
                        scores.Add(s);
                        seqLen.Add(l);
                    }
                }
                ip.Dispose();
                if (correct.Count > 10000000)
                {
                    break;
                }
            }
            if (correct.Count == 0)
            {
                return;
            }
            bool write             = debug && (type == MascotQueryType.Silac);
            BayesianInversion2D bi = new BayesianInversion2D(scores.ToArray(), seqLen.ToArray(), correct.ToArray(), write);

            if (write)
            {
                Write(rawFiles, bi);
            }
            for (int i = 0; i < rawFiles.Length; i++)
            {
                SetPep(ip.GetIdentifications(rawFiles[i], type), bi);
                ip.Dispose();
            }
        }
Exemple #4
0
        public static void FdrThresholding(string[] rawFiles, string[] recalFiles, string[] nonRecalFiles, string revstring,
                                           double peptideFdr, double peptidePep, bool perFileThreshold, bool keepLowScorers,
                                           IProteinSet proteinSet, HashSet <string> labelModificationSet, IIdentificationProvider ip, bool writeOut)
        {
            HashSet <string> sequences = new HashSet <string>();

            if (recalFiles.Length > 0)
            {
                FdrThresholding(recalFiles, revstring, peptideFdr, peptidePep, MascotQueryType.Silac,
                                perFileThreshold, writeOut, sequences, keepLowScorers, proteinSet,
                                labelModificationSet, ip);
                FdrThresholding(recalFiles, revstring, peptideFdr, peptidePep, MascotQueryType.Isotope,
                                perFileThreshold, false, sequences, keepLowScorers, proteinSet,
                                labelModificationSet, ip);
            }
            if (nonRecalFiles.Length > 0)
            {
                FdrThresholding(nonRecalFiles, revstring, peptideFdr, peptidePep, MascotQueryType.Silac,
                                perFileThreshold, false, sequences, keepLowScorers, proteinSet,
                                labelModificationSet, ip);
                FdrThresholding(nonRecalFiles, revstring, peptideFdr, peptidePep, MascotQueryType.Isotope,
                                perFileThreshold, false, sequences, keepLowScorers, proteinSet,
                                labelModificationSet, ip);
            }
            FdrThresholding(rawFiles, revstring, peptideFdr, peptidePep, MascotQueryType.Peak,
                            perFileThreshold,
                            false, sequences, keepLowScorers, proteinSet,
                            labelModificationSet, ip);
            if (keepLowScorers)
            {
                FilterBySequence(rawFiles, revstring, peptideFdr, peptidePep, MascotQueryType.Silac,
                                 perFileThreshold, writeOut, sequences, keepLowScorers, ip);
                FilterBySequence(rawFiles, revstring, peptideFdr, peptidePep, MascotQueryType.Isotope,
                                 perFileThreshold, false, sequences, keepLowScorers, ip);
                FilterBySequence(rawFiles, revstring, peptideFdr, peptidePep, MascotQueryType.Peak,
                                 perFileThreshold,
                                 false, sequences, keepLowScorers, ip);
            }
            LimitPep(rawFiles, MascotQueryType.Silac, ip);
            LimitPep(rawFiles, MascotQueryType.Isotope, ip);
            LimitPep(rawFiles, MascotQueryType.Peak, ip);
        }
Exemple #5
0
 public static void FilterBySequence(string[] rawFiles, string decoyPrefix, double totalPeptideFPR,
                                     double specificPeptideFPR, MascotQueryType type, bool perFileThreshold, bool debug,
                                     HashSet <string> sequences, bool onlyCollectSequences, IIdentificationProvider ip)
 {
     for (int i = 0; i < rawFiles.Length; i++)
     {
         FilterBySequence(ip.GetIdentifications(rawFiles[i], type), sequences);
         ip.Dispose();
     }
 }
Exemple #6
0
 public static void CalcFdr(string[] rawFiles, string decoyPrefix, MascotQueryType type, IProteinSet proteinSet, bool debug,
                            HashSet <string> labelModificationSet, IIdentificationProvider ip)
 {
     CalcFdr(rawFiles, decoyPrefix, type, proteinSet, debug, ip);
 }