-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to MBR within FlashLFQ #802
Changes from all commits
4fe3343
742ac30
e51a740
dc4493e
31ff285
dda57b6
ca9928a
15efaac
48239cc
add08ab
1da0e13
03efb21
5eb2637
1aeeb96
112ae41
7703b75
e3fe1e2
8993a25
7d9b6b1
40d5f45
4f3fc9d
79b2890
5d5c1ee
4a9149c
d8a7a0c
61fac1c
363c457
c4720ba
9ade14a
e595cd4
c88e32e
b6dbc8c
b12c44c
6d96aa7
8bb7cbe
42e922c
12f3f34
175e0a7
bcf8d7c
768b921
b324efe
9d13eb2
b147e3b
01482fc
5ee1d21
7e32625
3ceb447
1d5422f
5cbb1c5
c5249aa
95f9281
e6294a9
1fe4112
9ab8a1b
0e92cf2
d845eda
9e25e98
ac64e44
d56cf8a
4d2c1ac
53f7c78
b1d4920
a20d625
bd50ef6
7e098b5
2a86c6e
e13ff2f
ea8e9e2
8df00ed
65f8757
30c8aef
b2c210c
ec43c93
38f28bc
054120d
2caaa59
3dfa3f2
c3e2dd5
a151c8c
909a668
655df38
ba1f361
8131466
88be9cb
9ef8b23
1740c73
fa92a3a
4a4e4a7
d2b4cdd
c1a15ad
a48e5af
017e932
15255f7
2518e63
c3c5c2a
36087fe
ff7338e
5838238
05f47b4
f4e843a
e398a75
0ad40ca
c1c6c49
a08ab94
db57bca
2c13204
d713cb3
05b2d37
64394cf
0a41776
a9f37e7
e6e69a1
aa31815
28adaf0
caa785c
c2fe951
19e1e3c
a6272c3
6aee163
f562982
d891c5e
9aff2de
dcaff0c
fb19c3f
1507ee7
6b16ade
4aafb5c
7c33a6d
9a8f683
a09ee9c
26d8c27
e81a75f
14652c9
7e5d0f0
8e37695
c518a74
acde585
d9b0697
b024068
661bb36
b11721e
b0634d6
dbe394a
ce1a3d3
2a03fb2
c1943b1
fc596d7
3bfff45
439a7a7
ccb63d4
6fd02c9
c0bad3d
d404107
0ed3f53
0aa86f2
46cc07f
b437039
3f4dada
d8f3b9c
bc98a83
ddaf0b5
cbe7eee
af6490e
a3720b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,27 +15,26 @@ public class FlashLfqResults | |
public readonly Dictionary<string, ProteinGroup> ProteinGroups; | ||
public readonly Dictionary<SpectraFileInfo, List<ChromatographicPeak>> Peaks; | ||
private readonly HashSet<string> _peptideModifiedSequencesToQuantify; | ||
public string PepResultString { get; set; } | ||
public double MbrQValueThreshold { get; set; } | ||
|
||
public FlashLfqResults(List<SpectraFileInfo> spectraFiles, List<Identification> identifications, HashSet<string> peptides = null) | ||
public FlashLfqResults(List<SpectraFileInfo> spectraFiles, List<Identification> identifications, double mbrQValueThreshold = 0.05, | ||
HashSet<string> peptideModifiedSequencesToQuantify = null) | ||
{ | ||
SpectraFiles = spectraFiles; | ||
PeptideModifiedSequences = new Dictionary<string, Peptide>(); | ||
ProteinGroups = new Dictionary<string, ProteinGroup>(); | ||
Peaks = new Dictionary<SpectraFileInfo, List<ChromatographicPeak>>(); | ||
if(peptides == null || !peptides.Any()) | ||
{ | ||
peptides = identifications.Select(id => id.ModifiedSequence).ToHashSet(); | ||
} | ||
_peptideModifiedSequencesToQuantify = peptides; | ||
MbrQValueThreshold = mbrQValueThreshold; | ||
_peptideModifiedSequencesToQuantify = peptideModifiedSequencesToQuantify ?? identifications.Where(id => !id.IsDecoy).Select(id => id.ModifiedSequence).ToHashSet(); | ||
|
||
foreach (SpectraFileInfo file in spectraFiles) | ||
{ | ||
Peaks.Add(file, new List<ChromatographicPeak>()); | ||
} | ||
|
||
|
||
// Only quantify peptides within the set of valid peptide modified (full) sequences. This is done to enable pepitde-level FDR control of reported results | ||
foreach (Identification id in identifications.Where(id => peptides.Contains(id.ModifiedSequence))) | ||
foreach (Identification id in identifications.Where(id => !id.IsDecoy & _peptideModifiedSequencesToQuantify.Contains(id.ModifiedSequence))) | ||
{ | ||
if (!PeptideModifiedSequences.TryGetValue(id.ModifiedSequence, out Peptide peptide)) | ||
{ | ||
|
@@ -59,6 +58,17 @@ public FlashLfqResults(List<SpectraFileInfo> spectraFiles, List<Identification> | |
} | ||
} | ||
|
||
public void ReNormalizeResults(bool integrate = false, int maxThreads = 10, bool useSharedPeptides = false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unit test? |
||
{ | ||
foreach(var peak in Peaks.SelectMany(p => p.Value)) | ||
{ | ||
peak.CalculateIntensityForThisFeature(integrate); | ||
} | ||
new IntensityNormalizationEngine(this, integrate, silent: true, maxThreads).NormalizeResults(); | ||
CalculatePeptideResults(quantifyAmbiguousPeptides: false); | ||
CalculateProteinResultsMedianPolish(useSharedPeptides: useSharedPeptides); | ||
} | ||
|
||
public void MergeResultsWith(FlashLfqResults mergeFrom) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add method description There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For MergeResults? I didn't write it and I don't know what it does |
||
{ | ||
this.SpectraFiles.AddRange(mergeFrom.SpectraFiles); | ||
|
@@ -128,6 +138,8 @@ public void CalculatePeptideResults(bool quantifyAmbiguousPeptides) | |
{ | ||
var groupedPeaks = filePeaks.Value | ||
.Where(p => p.NumIdentificationsByFullSeq == 1) | ||
.Where(p => !p.Identifications.First().IsDecoy) | ||
.Where(p => !p.IsMbrPeak || (p.MbrQValue < MbrQValueThreshold && !p.RandomRt)) | ||
.GroupBy(p => p.Identifications.First().ModifiedSequence) | ||
.Where(group => _peptideModifiedSequencesToQuantify.Contains(group.Key)) | ||
.ToList(); | ||
|
@@ -163,11 +175,15 @@ public void CalculatePeptideResults(bool quantifyAmbiguousPeptides) | |
// report ambiguous quantification | ||
var ambiguousPeaks = filePeaks.Value | ||
.Where(p => p.NumIdentificationsByFullSeq > 1) | ||
.Where(p => !p.Identifications.First().IsDecoy) | ||
.Where(p => !p.IsMbrPeak || (p.MbrQValue < MbrQValueThreshold && !p.RandomRt)) | ||
.ToList(); | ||
foreach (ChromatographicPeak ambiguousPeak in ambiguousPeaks) | ||
{ | ||
foreach (Identification id in ambiguousPeak.Identifications) | ||
foreach (Identification id in ambiguousPeak.Identifications.Where(id => !id.IsDecoy)) | ||
{ | ||
if (!_peptideModifiedSequencesToQuantify.Contains(id.ModifiedSequence)) continue; // Ignore the ids/sequences we don't want to quantify | ||
|
||
string sequence = id.ModifiedSequence; | ||
|
||
double alreadyRecordedIntensity = PeptideModifiedSequences[sequence].GetIntensity(filePeaks.Key); | ||
|
@@ -224,7 +240,7 @@ private void HandleAmbiguityInFractions() | |
|
||
foreach (SpectraFileInfo file in sample) | ||
{ | ||
foreach (ChromatographicPeak peak in Peaks[file]) | ||
foreach (ChromatographicPeak peak in Peaks[file].Where(p => !p.IsMbrPeak || p.MbrQValue < MbrQValueThreshold)) | ||
{ | ||
foreach (Identification id in peak.Identifications) | ||
{ | ||
|
@@ -549,7 +565,7 @@ public void CalculateProteinResultsMedianPolish(bool useSharedPeptides) | |
} | ||
} | ||
|
||
public void WriteResults(string peaksOutputPath, string modPeptideOutputPath, string proteinOutputPath, string bayesianProteinQuantOutput, bool silent = true) | ||
public void WriteResults(string peaksOutputPath, string modPeptideOutputPath, string proteinOutputPath, string bayesianProteinQuantOutput, bool silent) | ||
{ | ||
if (!silent) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are really bulking up ChromatographicPeak. Is there anything to the idea of grouping a bunch of stuff into another class ChromatographicPeakMetrics? Just asking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly that would be a better way to do that. Create something like and FdrInfo type object. I hope to implement that change in a future update