public void ScoreFeatures(IProgressMonitor progressMonitor = null)
        {
            if (_features == null)
            {
                _features = Document.GetPeakFeatures(_calcs, progressMonitor);
            }
            if (ScoringModel == null)
            {
                return;
            }

            var bestTargetPvalues = new List <double>();
            var targetIds         = new List <PeakTransitionGroupIdKey>();

            foreach (var transitionGroupFeatures in _features)
            {
                var mProphetScoresGroup = new List <double>();
                foreach (var peakGroupFeatures in transitionGroupFeatures.PeakGroupFeatures)
                {
                    mProphetScoresGroup.Add(ScoringModel.Score(peakGroupFeatures.Features));
                }
                var    pValuesGroup = mProphetScoresGroup.Select(score => 1 - Statistics.PNorm(score)).ToList();
                int    bestIndex    = mProphetScoresGroup.IndexOf(mProphetScoresGroup.Max());
                double bestPvalue   = pValuesGroup[bestIndex];
                var    featureStats = new PeakFeatureStatistics(transitionGroupFeatures, mProphetScoresGroup, pValuesGroup, bestIndex, null);
                _featureDictionary.Add(transitionGroupFeatures.Id.Key, featureStats);
                if (!transitionGroupFeatures.Id.NodePep.IsDecoy)
                {
                    bestTargetPvalues.Add(bestPvalue);
                    targetIds.Add(transitionGroupFeatures.Id.Key);
                }
            }
            _qValues = new Statistics(bestTargetPvalues).Qvalues(MProphetPeakScoringModel.DEFAULT_R_LAMBDA, MProphetPeakScoringModel.PI_ZERO_MIN).ToList();
            for (int i = 0; i < _qValues.Count; ++i)
            {
                var newFeatureStats = _featureDictionary[targetIds[i]].SetQValue(_qValues[i]);
                _featureDictionary[targetIds[i]] = newFeatureStats;
            }
        }
Пример #2
0
        public void ScoreFeatures(IProgressMonitor progressMonitor = null, bool releaseRawFeatures = false, TextWriter output = null)
        {
            if (_features == null)
            {
                _features = Document.GetPeakFeatures(_calcs, progressMonitor);
            }
            if (ScoringModel == null)
            {
                return;
            }

            var bestTargetPvalues = new List <double>(_features.TargetCount);
            var targetIds         = new List <PeakTransitionGroupIdKey>(_features.TargetCount);

            foreach (var transitionGroupFeatures in _features.Features)
            {
                int           bestIndex = 0;
                float         bestScore = float.MinValue;
                float         bestPvalue = float.NaN;
                var           peakGroupFeatures = transitionGroupFeatures.PeakGroupFeatures;
                IList <float> mProphetScoresGroup = null, pvalues = null;
                if (!releaseRawFeatures)
                {
                    mProphetScoresGroup = new float[peakGroupFeatures.Count];
                }
                if (!releaseRawFeatures)
                {
                    pvalues = new float[peakGroupFeatures.Count];
                }

                for (int i = 0; i < peakGroupFeatures.Count; i++)
                {
                    double score = ScoringModel.Score(peakGroupFeatures[i].Features);
                    if (double.IsNaN(bestScore) || score > bestScore)
                    {
                        bestIndex  = i;
                        bestScore  = (float)score;
                        bestPvalue = (float)(1 - Statistics.PNorm(score));
                    }
                    if (mProphetScoresGroup != null)
                    {
                        mProphetScoresGroup[i] = (float)score;
                    }
                    if (pvalues != null)
                    {
                        pvalues[i] = (float)(1 - Statistics.PNorm(score));
                    }
                }
                if (bestScore == float.MinValue)
                {
                    bestScore = float.NaN;
                }

                var featureStats = new PeakFeatureStatistics(transitionGroupFeatures,
                                                             mProphetScoresGroup, pvalues, bestIndex, bestScore, null);
                _featureDictionary.Add(transitionGroupFeatures.Key, featureStats);
                if (!transitionGroupFeatures.IsDecoy)
                {
                    bestTargetPvalues.Add(bestPvalue);
                    targetIds.Add(transitionGroupFeatures.Key);
                }
            }
            _qValues = new Statistics(bestTargetPvalues).Qvalues(MProphetPeakScoringModel.DEFAULT_R_LAMBDA, MProphetPeakScoringModel.PI_ZERO_MIN);
            for (int i = 0; i < _qValues.Length; ++i)
            {
                _featureDictionary[targetIds[i]].QValue = (float)_qValues[i];
            }
            if (releaseRawFeatures)
            {
                _features = null;   // Done with this memory
            }
        }
Пример #3
0
        public void ScoreFeatures(IProgressMonitor progressMonitor = null)
        {
            if (_features == null)
            {
                _features = Document.GetPeakFeatures(_calcs, progressMonitor);
            }
            if (ScoringModel == null)
                return;

            var bestTargetPvalues = new List<double>();
            var targetIds = new List<PeakTransitionGroupIdKey>();
            foreach (var transitionGroupFeatures in _features)
            {
                var mProphetScoresGroup = new List<double>();
                foreach (var peakGroupFeatures in transitionGroupFeatures.PeakGroupFeatures)
                {
                    mProphetScoresGroup.Add(ScoringModel.Score(peakGroupFeatures.Features));
                }
                var pValuesGroup = mProphetScoresGroup.Select(score => 1 - Statistics.PNorm(score)).ToList();
                int bestIndex = mProphetScoresGroup.IndexOf(mProphetScoresGroup.Max());
                double bestPvalue = pValuesGroup[bestIndex];
                var featureStats = new PeakFeatureStatistics(transitionGroupFeatures, mProphetScoresGroup, pValuesGroup, bestIndex, null);
                _featureDictionary.Add(transitionGroupFeatures.Id.Key, featureStats);
                if (!transitionGroupFeatures.Id.NodePep.IsDecoy)
                {
                    bestTargetPvalues.Add(bestPvalue);
                    targetIds.Add(transitionGroupFeatures.Id.Key);
                }
            }
            _qValues = new Statistics(bestTargetPvalues).Qvalues(MProphetPeakScoringModel.DEFAULT_R_LAMBDA, MProphetPeakScoringModel.PI_ZERO_MIN).ToList();
            for (int i = 0; i < _qValues.Count; ++i)
            {
                var newFeatureStats = _featureDictionary[targetIds[i]].SetQValue(_qValues[i]);
                _featureDictionary[targetIds[i]] = newFeatureStats;
            }
        }