-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworking PEP to prevent cross-contamination (#2394)
- Loading branch information
1 parent
dd3dc20
commit 5c019b4
Showing
17 changed files
with
813 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
937 changes: 460 additions & 477 deletions
937
...er/FdrAnalysis/PEPValueAnalysisGeneric.cs → ...ineLayer/FdrAnalysis/PEPAnalysisEngine.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using Omics; | ||
using Proteomics.ProteolyticDigestion; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EngineLayer | ||
{ | ||
public class PeptideMatchGroup : IEnumerable<SpectralMatch> | ||
{ | ||
public string PeptideFullSequence { get; } | ||
public List<SpectralMatch> SpectralMatches { get; } | ||
|
||
/// <summary> | ||
/// This class groups all spectral matches associated with a given peptide together, | ||
/// to facilitate the calculation of PEP values. | ||
/// </summary> | ||
/// <param name="fullPeptideSeq"> The full sequence to be used for grouping</param> | ||
/// <param name="spectralMatches"> Every spectral match that matches the full sequence</param> | ||
public PeptideMatchGroup(string fullPeptideSeq, List<SpectralMatch> spectralMatches) | ||
{ | ||
PeptideFullSequence = fullPeptideSeq; | ||
SpectralMatches = spectralMatches; | ||
} | ||
|
||
public static List<PeptideMatchGroup> GroupByBaseSequence(List<SpectralMatch> spectralMatches) | ||
{ | ||
// This groups psms by base sequence, ensuring that PSMs with the same base sequence but different modifications are grouped together when training. | ||
|
||
// TODO: Determine if it's better to group PSMs by base sequence or by full sequence. | ||
return spectralMatches.GroupBy(p => p.BaseSequence) | ||
.Select(group => new PeptideMatchGroup(group.Key, group.ToList())) | ||
.OrderByDescending(matchGroup => matchGroup.Count()) | ||
.ThenByDescending(matchGroup => matchGroup.BestMatch.Score) | ||
.ToList(); | ||
} | ||
|
||
public IEnumerable<SpectralMatch> GetBestMatchByMod() | ||
{ | ||
return SpectralMatches.GroupBy(p => p.FullSequence).Select(g => g.MaxBy(p => p)); | ||
} | ||
|
||
/// <summary> | ||
/// This function is called if there aren't enough peptides to train at the peptide level | ||
/// </summary> | ||
/// <param name="spectralMatches"></param> | ||
/// <returns></returns> | ||
public static List<PeptideMatchGroup> GroupByIndividualPsm(List<SpectralMatch> spectralMatches) | ||
{ | ||
return spectralMatches.Select(psm => new PeptideMatchGroup(psm.FullSequence, new List<SpectralMatch> { psm })) | ||
.ToList(); | ||
} | ||
|
||
public SpectralMatch BestMatch => SpectralMatches.MaxBy(match => match); | ||
|
||
public IEnumerator<SpectralMatch> GetEnumerator() | ||
{ | ||
return SpectralMatches.GetEnumerator(); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return GetEnumerator(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.