public IsotopeEnvelopeStatisticalInfo PreformStatisticalSignificanceTest(ObservedIsotopeEnvelope envelope) { int peakStartIndex; Tuple <double, double> mzBoundary; //var refPeak = envelope.Peaks[envelope.RefIsotopeInternalIndex]; var mostAbuMz = 0d; var mostAbutPeakInternalIndex = envelope.TheoreticalEnvelope.IndexOrderByRanking[0]; if (envelope.Peaks[mostAbutPeakInternalIndex] != null) { mostAbuMz = envelope.Peaks[mostAbutPeakInternalIndex].Mz; } else { mostAbuMz = envelope.TheoreticalEnvelope.GetIsotopeMz(envelope.Charge, mostAbutPeakInternalIndex); } var rankings = GetLocalRankings(mostAbuMz, out peakStartIndex, out mzBoundary); // smallest delta_mz = 0.01 (th) ? var ret = new IsotopeEnvelopeStatisticalInfo { LocalMzStart = mzBoundary.Item1, LocalMzEnd = mzBoundary.Item2, NumberOfLocalPeaks = rankings.Length, NumberOfPossiblePeaks = (int)Math.Ceiling(100 * (mzBoundary.Item2 - mzBoundary.Item1)), NumberOfIsotopePeaks = envelope.Size, }; // calculate ranksum test score var ranksum = 0; var nRankSum = 0; for (var i = 0; i < envelope.Size; i++) { if (envelope.Peaks[i] == null || !envelope.Peaks[i].Active) { continue; } ret.NumberOfMatchedIsotopePeaks++; //if (isotopeList[i].Ratio > RelativeIntesnityThresholdForRankSum) //{ var localIndex = envelope.Peaks[i].IndexInSpectrum - peakStartIndex; if (localIndex >= rankings.Length || localIndex < 0) { continue; } ranksum += rankings[localIndex]; nRankSum++; //} } var pvalue = FitScoreCalculator.GetRankSumPvalue(ret.NumberOfLocalPeaks, nRankSum, ranksum); ret.RankSumScore = (pvalue > 0) ? -Math.Log(pvalue, 2) : 50; // calculate poisson test score var n = ret.NumberOfPossiblePeaks; var k = ret.NumberOfIsotopePeaks; // # of theretical isotope ions of the mass within the local window var n1 = ret.NumberOfLocalPeaks; // # of detected ions within the local window var k1 = ret.NumberOfMatchedIsotopePeaks; // # of matched ions generating isotope envelope profile var lambda = ((double)n1 / (double)n) * k; pvalue = 1 - Poisson.CDF(lambda, k1); ret.PoissonScore = (pvalue > 0) ? -Math.Log(pvalue, 2) : 50; return(ret); }
public IsotopeEnvelopeStatisticalInfo PreformStatisticalSignificanceTest(ObservedIsotopeEnvelope envelope) { int peakStartIndex; Tuple<double, double> mzBoundary; //var refPeak = envelope.Peaks[envelope.RefIsotopeInternalIndex]; var mostAbuMz = 0d; var mostAbutPeakInternalIndex = envelope.TheoreticalEnvelope.IndexOrderByRanking[0]; if (envelope.Peaks[mostAbutPeakInternalIndex] != null) { mostAbuMz = envelope.Peaks[mostAbutPeakInternalIndex].Mz; } else { mostAbuMz = envelope.TheoreticalEnvelope.GetIsotopeMz(envelope.Charge, mostAbutPeakInternalIndex); } var rankings = GetLocalRankings(mostAbuMz, out peakStartIndex, out mzBoundary); // smallest delta_mz = 0.01 (th) ? var ret = new IsotopeEnvelopeStatisticalInfo { LocalMzStart = mzBoundary.Item1, LocalMzEnd = mzBoundary.Item2, NumberOfLocalPeaks = rankings.Length, NumberOfPossiblePeaks = (int)Math.Ceiling(100 * (mzBoundary.Item2 - mzBoundary.Item1)), NumberOfIsotopePeaks = envelope.Size, }; // calculate ranksum test score var ranksum = 0; var nRankSum = 0; for (var i = 0; i < envelope.Size; i++) { if (envelope.Peaks[i] == null || !envelope.Peaks[i].Active) continue; ret.NumberOfMatchedIsotopePeaks++; //if (isotopeList[i].Ratio > RelativeIntesnityThresholdForRankSum) //{ var localIndex = envelope.Peaks[i].IndexInSpectrum - peakStartIndex; if (localIndex >= rankings.Length || localIndex < 0) continue; ranksum += rankings[localIndex]; nRankSum++; //} } var pvalue = FitScoreCalculator.GetRankSumPvalue(ret.NumberOfLocalPeaks, nRankSum, ranksum); ret.RankSumScore = (pvalue > 0) ? -Math.Log(pvalue, 2) : 50; // calculate poisson test score var n = ret.NumberOfPossiblePeaks; var k = ret.NumberOfIsotopePeaks; // # of theretical isotope ions of the mass within the local window var n1 = ret.NumberOfLocalPeaks; // # of detected ions within the local window var k1 = ret.NumberOfMatchedIsotopePeaks; // # of matched ions generating isotope envelope profile var lambda = ((double)n1 / (double)n) * k; pvalue = 1 - Poisson.CDF(lambda, k1); ret.PoissonScore = (pvalue > 0) ? -Math.Log(pvalue, 2) : 50; return ret; }