Skip to content

Commit

Permalink
add hyperscore to PEP calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
trishorts committed Aug 29, 2024
1 parent bd5aefc commit 0ff7b36
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
35 changes: 35 additions & 0 deletions MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,38 @@ private static float GetMobilityZScore(SpectralMatch psm, IBioPolymerWithSetMods
return (float)mobilityZScore;
}

public static float GetFraggerHyperScore(SpectralMatch psm, IBioPolymerWithSetMods selectedPeptide)
{
var peptideFragmentIons = psm.BioPolymersWithSetModsToMatchingFragments[selectedPeptide];
var nIons = peptideFragmentIons.Where(f => f.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.N).ToList();
var cIons = peptideFragmentIons.Where(f => f.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.C).ToList();
double nIonIntensitySum = nIons.Sum(f => f.Intensity);
double cIonIntensitySum = cIons.Sum(f => f.Intensity);
float nIon = GetLog10Factorial((int)nIons.Count);
float cIon = GetLog10Factorial((int)cIons.Count);

return (float)((nIon + cIon + Math.Log10(nIonIntensitySum * cIonIntensitySum)));
}

private static ulong GetFactorial(ulong n)
{
if (n == 0)
{
return 1;
}
return n * GetFactorial(n - 1);
}

public static float GetLog10Factorial(int n)
{
double log10Factorial = 0.0;
for (int i = 1; i <= n; i++)
{
log10Factorial += Math.Log10(i);
}
return (float)log10Factorial;
}

public static IEnumerable<PsmData> CreatePsmData(string searchType, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters,
List<SpectralMatch> psms, List<int> psmIndicies,
Dictionary<string, Dictionary<int, Tuple<double, double>>> timeDependantHydrophobicityAverageAndDeviation_unmodified,
Expand Down Expand Up @@ -790,6 +822,7 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file
float peaksInPrecursorEnvelope = 0;
float mostAbundantPrecursorPeakIntensity = 0;
float fractionalIntensity = 0;
float fraggerHyperScore = 0;

float missedCleavages = 0;
float longestSeq = 0;
Expand Down Expand Up @@ -837,6 +870,7 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file
peaksInPrecursorEnvelope = psm.PrecursorScanEnvelopePeakCount;
mostAbundantPrecursorPeakIntensity = (float)Math.Round((float)psm.PrecursorScanIntensity / normalizationFactor * multiplier, 0);
fractionalIntensity = (float)psm.PrecursorFractionalIntensity;
fraggerHyperScore = GetFraggerHyperScore(psm, selectedPeptide);

if (PsmHasSpectralAngle(psm))
{
Expand Down Expand Up @@ -954,6 +988,7 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file
MostAbundantPrecursorPeakIntensity = mostAbundantPrecursorPeakIntensity,
PrecursorFractionalIntensity = fractionalIntensity,
InternalIonCount = internalMatchingFragmentCount,
FraggerHyperScore = fraggerHyperScore
};

return psm.PsmData_forPEPandPercolator;
Expand Down
8 changes: 6 additions & 2 deletions MetaMorpheus/EngineLayer/FdrAnalysis/PsmData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class PsmData
"TotalMatchingFragmentCount", "Intensity", "PrecursorChargeDiffToMode", "DeltaScore",
"Notch", "ModsCount", "AbsoluteAverageFragmentMassErrorFromMedian", "MissedCleavagesCount",
"Ambiguity", "LongestFragmentIonSeries", "ComplementaryIonCount", "HydrophobicityZScore",
"IsVariantPeptide", "IsDeadEnd", "IsLoop", "SpectralAngle", "HasSpectralAngle",
"IsVariantPeptide", "IsDeadEnd", "IsLoop", "SpectralAngle", "HasSpectralAngle", "FraggerHyperScore"
}
},

Expand All @@ -26,7 +26,7 @@ public class PsmData
"Notch", "ModsCount", "AbsoluteAverageFragmentMassErrorFromMedian", "Ambiguity",
"LongestFragmentIonSeries", "ComplementaryIonCount", "SpectralAngle",
"HasSpectralAngle", "PeaksInPrecursorEnvelope", "ChimeraCount",
"MostAbundantPrecursorPeakIntensity", "PrecursorFractionalIntensity", "InternalIonCount"
"MostAbundantPrecursorPeakIntensity", "PrecursorFractionalIntensity", "InternalIonCount", "FraggerHyperScore"
}
},

Expand Down Expand Up @@ -75,6 +75,7 @@ public class PsmData
{ "MostAbundantPrecursorPeakIntensity", 1 },
{ "PrecursorFractionalIntensity", 1 },
{ "InternalIonCount", 1},
{ "FraggerHyperScore", 1},
}.ToImmutableDictionary();

public string ToString(string searchType)
Expand Down Expand Up @@ -179,5 +180,8 @@ public string ToString(string searchType)

[LoadColumn(28)]
public float InternalIonCount { get; set; }

[LoadColumn(29)]
public float FraggerHyperScore { get; set; }
}
}

0 comments on commit 0ff7b36

Please sign in to comment.