Exemple #1
0
        public void Training(IResults results, int start, int end)
        {
            for (int scanNum = start; scanNum <= end; scanNum++)
            {
                if (results.Contains(scanNum))
                {
                    List <IScore> scores = results.GetResult(scanNum);
                    foreach (IScore score in scores)
                    {
                        double         y = (score as FDRScoreProxy).IsDecoy() ? 0 : 1;
                        List <SVMNode> X = new List <SVMNode>();
                        // store score value in X
                        int idx = 0;
                        foreach (MassType type in types)
                        {
                            SVMNode node = new SVMNode();
                            node.Index = idx;
                            node.Value = score.GetScore(type);
                            X.Add(node);
                            idx++;
                        }
                        problem.Add(X.ToArray(), y);
                    }
                }
            }

            // training
            SVMParameter parameter = new SVMParameter();

            parameter.Probability = true;
            model = problem.Train(parameter);
        }
Exemple #2
0
        public void Report(IResults results, int start, int end)
        {
            if (Init())
            {
                // training svm
                Training(results, start, end);

                // predicting probability
                List <IProbScoreProxy> probabilities = new List <IProbScoreProxy>();
                for (int scanNum = start; scanNum <= end; scanNum++)
                {
                    if (results.Contains(scanNum))
                    {
                        probabilities.AddRange(Predicting(results, scanNum));
                    }
                }
                double scoreCutoff = GetScoreCutoff(probabilities, start, end);

                // report
                //List<IProbScoreProxy> scores = probabilities.
                //    Where(score => !(score as IFDRScoreProxy).IsDecoy()).ToList();
                List <IProbScoreProxy> scores = probabilities;
                ReportLines(scores, scoreCutoff);

                Exit();
            }
        }
 public virtual void Report(IResults results, int start, int end)
 {
     if (InitSucess(scoreCutoff))
     {
         for (int scanNum = start; scanNum <= end; scanNum++)
         {
             if (results.Contains(scanNum))
             {
                 ReportLines(results.GetSpectrum(scanNum), results.GetResult(scanNum), scoreCutoff);
             }
         }
         Exit();
     }
 }
 public override void Report(IResults results, int start, int end)
 {
     //scoreCutoff = GetScoreCutoff(results, start, end);
     scoreCutoff = 0;
     if (InitSucess(scoreCutoff))
     {
         for (int scanNum = start; scanNum <= end; scanNum++)
         {
             if (results.Contains(scanNum))
             {
                 List <IScore> scores = results.GetResult(scanNum);
                 //List<IScore> scores = results.GetResult(scanNum).Where(score => !(score as IFDRScoreProxy).IsDecoy()).ToList();
                 ReportLines(results.GetSpectrum(scanNum), scores, scoreCutoff);
             }
         }
         Exit();
     }
 }
Exemple #5
0
        public void Report(IResults results, int start, int end)
        {
            if (Init())
            {
                // training svm
                Training(results, start, end);

                // predict and report
                for (int scanNum = start; scanNum <= end; scanNum++)
                {
                    if (results.Contains(scanNum))
                    {
                        List <IScore> scores = results.GetResult(scanNum);
                        //List<IScore> scores = results.GetResult(scanNum).
                        //    Where(score => !(score as IFDRScoreProxy).IsDecoy()).ToList();

                        ReportLines(results.GetSpectrum(scanNum), scores);
                    }
                }
                Exit();
            }
        }
        protected double GetScoreCutoff(IResults results, int start, int end)
        {
            // init
            double cutoff = 0;

            // get score values for true and decoy results
            List <double> targets = new List <double>();
            List <double> decoys  = new List <double>();

            for (int scan = start; scan <= end; scan++)
            {
                if (results.Contains(scan))
                {
                    foreach (IScore score in results.GetResult(scan))
                    {
                        if (!(score as IFDRScoreProxy).IsDecoy())
                        {
                            targets.Add(score.GetScore());
                            break;
                        }
                    }
                    foreach (IScore score in results.GetResult(scan))
                    {
                        if ((score as IFDRScoreProxy).IsDecoy())
                        {
                            decoys.Add(score.GetScore());
                            cutoff = Math.Max(cutoff, score.GetScore());
                            break;
                        }
                    }
                }
            }
            targets.Sort((a, b) => - a.CompareTo(b)); //descending
            decoys.Sort((a, b) => - a.CompareTo(b));

            // compare and compute
            if (decoys.Count * 1.0 / (decoys.Count + targets.Count) < fdr)   //trivial case
            {
                return(0);
            }

            int i = 0, j = 0;

            while (i < targets.Count && j < decoys.Count)
            {
                if (targets[i] > decoys[j])
                {
                    double rate = j * 1.0 / (i + j + 1);
                    if (rate <= fdr)
                    {
                        cutoff = Math.Min(cutoff, decoys[j]);
                    }
                    i++;
                }
                else
                {
                    j++;
                }
            }

            return(cutoff);
        }