Skip to content
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

Open
wants to merge 154 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
4fe3343
Predict Retention Time function added
Alexander-Sol Oct 23, 2023
742ac30
breaking up mbr function, cont'd
Alexander-Sol Oct 23, 2023
e51a740
Decoy search is working
Alexander-Sol Oct 31, 2023
dc4493e
Merge branch 'master' into MbrRefactor
Alexander-Sol Jan 30, 2024
31ff285
Removed decoy toggle from GetIsotopicEnvelopes
Alexander-Sol Jan 30, 2024
dda57b6
About to start MbrScorer refactor
Alexander-Sol Jan 30, 2024
ca9928a
Refactor of MBR is working succesfully
Alexander-Sol Jan 30, 2024
15efaac
Deleted unused code
Alexander-Sol Jan 30, 2024
48239cc
got those decoys decoying naw mean
Alexander-Sol Jan 31, 2024
add08ab
refactore MBR to use concurrent dictionaries
Alexander-Sol Jan 31, 2024
1da0e13
Test method with output
Alexander-Sol Feb 2, 2024
03efb21
Deleted unused fields and references to PearsonCorrelation in isotopi…
Alexander-Sol Feb 2, 2024
5eb2637
Deleted unused using statements in FlashLFQ engine
Alexander-Sol Feb 2, 2024
1aeeb96
Commented + removed unused variables for PredicteRetentionTime method
Alexander-Sol Feb 2, 2024
112ae41
Added comments, removed unused using statements
Alexander-Sol Feb 2, 2024
7703b75
Merge branch 'master' into MbrRefactor
Alexander-Sol Feb 2, 2024
e3fe1e2
Deleted unused variables
Alexander-Sol Feb 2, 2024
8993a25
Merge branch 'MbrRefactor' of https://github.com/Alexander-Sol/mzLib …
Alexander-Sol Feb 2, 2024
7d9b6b1
fixed merge conflicts
Alexander-Sol Feb 2, 2024
40d5f45
Tests are still passing, but I'm about to break things
Alexander-Sol Feb 2, 2024
4f3fc9d
Edited scoring method
Alexander-Sol Feb 2, 2024
79b2890
Umm, edited scoring, increased ppm tolerance, changed minimum rt widt…
Alexander-Sol Feb 6, 2024
5d5c1ee
Did some weird filtering of donor files that should probably be reverted
Alexander-Sol Feb 7, 2024
4a9149c
Peak Organism fix
Alexander-Sol Feb 12, 2024
d8a7a0c
fixed merge conflicts
Alexander-Sol Feb 13, 2024
61fac1c
Basically works, QValue still underestimates
Alexander-Sol Feb 15, 2024
363c457
Minor changes to peakfinding
Alexander-Sol Feb 19, 2024
c4720ba
MSMS double checking
Alexander-Sol Feb 29, 2024
9ade14a
Removed msms double checking
Alexander-Sol Feb 29, 2024
e595cd4
Add check for MBR/MSMS peak collision
Alexander-Sol Mar 1, 2024
c88e32e
Changed peak decoy selection method
Alexander-Sol Mar 7, 2024
b6dbc8c
Optional PeptidesForMbr argument added, not covered in previous commi…
Alexander-Sol Mar 7, 2024
b12c44c
5.3.2.4 - Changed randomRT selection method
Alexander-Sol Mar 7, 2024
6d96aa7
5.3.2.5 - Minimum rtWindowWidth = 30 seconds
Alexander-Sol Mar 7, 2024
8bb7cbe
Actually updated nuget
Alexander-Sol Mar 7, 2024
42e922c
5.3.2.6 - Fixed decoy search. 2.4 and 2.5 are junk
Alexander-Sol Mar 7, 2024
12f3f34
Changed MBR RT prediction method
Alexander-Sol Mar 8, 2024
175e0a7
Fixed bug in rtPrediction
Alexander-Sol Mar 8, 2024
bcf8d7c
Changed decoy search method and fixed issues with decoy rt scoring
Alexander-Sol Mar 9, 2024
768b921
small changes to double check procedure
Alexander-Sol Mar 9, 2024
b324efe
Fixed merge conflicts
Alexander-Sol Mar 9, 2024
9d13eb2
Finished Merging in MbrFdr - mzLib 5341
Alexander-Sol Mar 9, 2024
b147e3b
minor
Alexander-Sol Mar 9, 2024
01482fc
Actually changed nuspec
Alexander-Sol Mar 9, 2024
5ee1d21
Increased Rt Range
Alexander-Sol Mar 9, 2024
7e32625
Increased doublecheck count to 2500. mzLib 5343
Alexander-Sol Mar 9, 2024
3ceb447
reduced window slightly. mzLib 5344
Alexander-Sol Mar 9, 2024
1d5422f
amended rt scoring distribution in mbr scorer
Alexander-Sol Apr 18, 2024
5cbb1c5
Mostly deleted stuff that will be introduced in a different commit
Alexander-Sol Apr 18, 2024
c5249aa
Fixed all tests but one
Alexander-Sol Apr 18, 2024
95f9281
Fixed final test
Alexander-Sol Apr 18, 2024
e6294a9
minor
Alexander-Sol Apr 18, 2024
1fe4112
fixed merge conflicts
Alexander-Sol Apr 18, 2024
9ab8a1b
Merged in important parts from MbrDoubleCheck
Alexander-Sol Apr 22, 2024
0e92cf2
Changed decoy peak pairing
Alexander-Sol Apr 22, 2024
d845eda
finished update
Alexander-Sol Apr 23, 2024
9e25e98
Updated anchors
Alexander-Sol Apr 23, 2024
ac64e44
MbrThresholdAsParam
Alexander-Sol Apr 24, 2024
d56cf8a
Prevented decoys from being used for protein quant
Alexander-Sol Apr 24, 2024
4d2c1ac
minor
Alexander-Sol Apr 25, 2024
53f7c78
Deleted MSMS double check, changed scoring algo (removed intensity)
Alexander-Sol Apr 26, 2024
b1d4920
reverted scoring function
Alexander-Sol Apr 26, 2024
a20d625
Fixed issue where decoy peaks were being used to calculate peptide in…
Alexander-Sol Apr 26, 2024
bd50ef6
Fixed issue where low scoring peak traces could overwrite intensity v…
Alexander-Sol Apr 27, 2024
7e098b5
Removed minimum for RT window
Alexander-Sol Apr 28, 2024
2a86c6e
minor
Alexander-Sol May 6, 2024
e13ff2f
Fixed issue where MbrScorer would crash if too few anchor peptides pa…
Alexander-Sol May 16, 2024
ea8e9e2
Finished test structure to use for creating censored mzMls
Alexander-Sol May 25, 2024
8df00ed
Started and failed fragger stuff
Alexander-Sol May 27, 2024
65f8757
minor
Alexander-Sol Jun 4, 2024
30c8aef
Added fragger experiment class
Alexander-Sol Jun 4, 2024
b2c210c
Minor
Alexander-Sol Jun 10, 2024
ec43c93
MaxQuant Reader started
Alexander-Sol Jun 12, 2024
38f28bc
Merge branch 'master' into censorMzml
Alexander-Sol Jun 12, 2024
054120d
Fixed omics issue. Finished MaxQuantEvidence
Alexander-Sol Jun 12, 2024
2caaa59
Added maxQuantEvidence, MqResultsFile, got it working
Alexander-Sol Jun 17, 2024
3dfa3f2
minor
Alexander-Sol Jun 19, 2024
c3e2dd5
minor
Alexander-Sol Jun 19, 2024
a151c8c
changed nuspec
Alexander-Sol Jun 20, 2024
909a668
minor
Alexander-Sol Jun 22, 2024
655df38
Added renomalization function to FlashLFQ results, incremented nuspec
Alexander-Sol Jun 22, 2024
ba1f361
minor
Alexander-Sol Jul 1, 2024
8131466
idk
Alexander-Sol Jul 3, 2024
88be9cb
minor
Alexander-Sol Jul 8, 2024
9ef8b23
Deleted unrelated changes
Alexander-Sol Jul 10, 2024
1740c73
Added FraggerMasterFile
Alexander-Sol Jul 10, 2024
fa92a3a
Fixed conflicts
Alexander-Sol Jul 10, 2024
4a4e4a7
fixed errors introduced by merge
Alexander-Sol Jul 10, 2024
d2b4cdd
idk
Alexander-Sol Jul 10, 2024
c1a15ad
Changing parameters
Alexander-Sol Jul 10, 2024
a48e5af
about to break things
Alexander-Sol Jul 11, 2024
017e932
Implemented better PIP donor selection
Alexander-Sol Jul 11, 2024
15255f7
Implemented PEP, and it's working
Alexander-Sol Jul 11, 2024
2518e63
Included ML.NET in nuspec
Alexander-Sol Jul 11, 2024
c3c5c2a
idk
Alexander-Sol Jul 11, 2024
36087fe
Semi-supervised PEP
Alexander-Sol Jul 12, 2024
ff7338e
Retrain within splits
Alexander-Sol Jul 12, 2024
5838238
Working
Alexander-Sol Jul 13, 2024
05f47b4
Added donor groups, pep is working
Alexander-Sol Jul 13, 2024
f4e843a
Multiple peaks per donor
Alexander-Sol Jul 13, 2024
e398a75
Switched to 514, single donor training
Alexander-Sol Jul 13, 2024
0ad40ca
fixed merge conflicts
Alexander-Sol Jul 13, 2024
c1c6c49
mzLib 315
Alexander-Sol Jul 15, 2024
a08ab94
mzLib 315 for real
Alexander-Sol Jul 15, 2024
db57bca
Commit before decoy pairing
Alexander-Sol Jul 16, 2024
2c13204
Creating groups by decoy count only
Alexander-Sol Jul 16, 2024
d713cb3
idk
Alexander-Sol Jul 17, 2024
05b2d37
Implemented cursed algorithm for donorGroup partitioning
Alexander-Sol Jul 18, 2024
64394cf
mzLib 324
Alexander-Sol Jul 18, 2024
0a41776
mzLib 5.326
Alexander-Sol Jul 18, 2024
a9f37e7
327
Alexander-Sol Jul 19, 2024
e6e69a1
mzLib 328
Alexander-Sol Jul 19, 2024
aa31815
mzLib 329
Alexander-Sol Jul 23, 2024
28adaf0
nuspec
Alexander-Sol Aug 1, 2024
caa785c
Updates to window width calculations
Alexander-Sol Aug 19, 2024
c2fe951
More changes to window width calculations
Alexander-Sol Aug 19, 2024
19e1e3c
nuspec update
Alexander-Sol Aug 20, 2024
a6272c3
reverted donor exclusion window stuff
Alexander-Sol Aug 31, 2024
6aee163
Merge conflicts not quite fixed
Alexander-Sol Sep 20, 2024
f562982
Fixing merge conflicts one at a time
Alexander-Sol Sep 20, 2024
d891c5e
minor
Alexander-Sol Sep 20, 2024
9aff2de
Fixed errors, deleted tests with local file refs
Alexander-Sol Sep 20, 2024
dcaff0c
Merged master into Pip-ECHO FlashLFQ, fixed all the issues that arose.
Alexander-Sol Sep 22, 2024
fb19c3f
Reverted unneccessary changes
Alexander-Sol Sep 23, 2024
1507ee7
minor
Alexander-Sol Sep 23, 2024
6b16ade
minor
Alexander-Sol Sep 23, 2024
4aafb5c
minor
Alexander-Sol Sep 23, 2024
7c33a6d
Pep engine no longer static
Alexander-Sol Sep 23, 2024
9a8f683
MlContext Seed
Alexander-Sol Sep 23, 2024
a09ee9c
xyz
Alexander-Sol Sep 23, 2024
26d8c27
messed with the .yml
Alexander-Sol Sep 23, 2024
e81a75f
More logs
Alexander-Sol Sep 23, 2024
14652c9
Even more logs
Alexander-Sol Sep 23, 2024
7e5d0f0
dsf
Alexander-Sol Sep 23, 2024
8e37695
One million logs
Alexander-Sol Sep 23, 2024
c518a74
thread safe rng
Alexander-Sol Sep 23, 2024
acde585
Fixed random issue, tests are passing
Alexander-Sol Sep 23, 2024
d9b0697
More lgos
Alexander-Sol Sep 23, 2024
b024068
Stabilized results?
Alexander-Sol Sep 23, 2024
661bb36
Fixed issues
Alexander-Sol Sep 23, 2024
b11721e
Deleted unused properties, changed ChromatographicPeak tostring
Alexander-Sol Sep 24, 2024
b0634d6
Removed unintended changes
Alexander-Sol Sep 24, 2024
dbe394a
started refactor
Alexander-Sol Oct 1, 2024
ce1a3d3
Commit before breaking things
Alexander-Sol Oct 1, 2024
2a03fb2
Refactored donorGroup equalization, added test
Alexander-Sol Oct 1, 2024
c1943b1
Finished tests for Pip-ECHO
Alexander-Sol Oct 3, 2024
fc596d7
Added more unit tests, addressed Shortreed's comments
Alexander-Sol Oct 3, 2024
3bfff45
Reverted changes to github actions .yml, updated MicrosoftML
Alexander-Sol Oct 3, 2024
439a7a7
Update dotnet.yml
Alexander-Sol Oct 4, 2024
ccb63d4
Updated comments
Alexander-Sol Oct 15, 2024
6fd02c9
Revert nuspec
Alexander-Sol Oct 15, 2024
c0bad3d
Merge branch 'master' into MbrPart2
Alexander-Sol Oct 15, 2024
d404107
Edited realDataMbr test to account for change to MbrScorer
Alexander-Sol Oct 15, 2024
0ed3f53
More changes to tests
Alexander-Sol Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 38 additions & 50 deletions mzLib/FlashLFQ/ChromatographicPeak.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using MzLibUtil;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassExtensions = Chemistry.ClassExtensions;
using FlashLFQ.PEP;

namespace FlashLFQ
{
Expand All @@ -16,20 +16,23 @@ public class ChromatographicPeak
public int ScanCount => IsotopicEnvelopes.Count;
public double SplitRT;
public readonly bool IsMbrPeak;
public double PredictedRetentionTime { get; init; }
Copy link
Contributor

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.

Copy link
Contributor Author

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


public double MbrScore;
public double PpmScore { get; set; }
public double IntensityScore { get; set; }
public double RtScore { get; set; }
public double ScanCountScore { get; set; }
public double IsotopicDistributionScore { get; set; }
/// <summary>
/// A score bounded by 100 and 0, with more confident MBR-detections receiving higher scores
/// Stores the pearson correlation between the apex isotopic envelope and the theoretical isotopic distribution
/// </summary>
public double MbrScore { get; private set; }

/// The four scores below are bounded by 0 and 1, with higher scores being better
public double PpmScore { get; private set; }
public double IntensityScore { get; private set; }
public double RtScore { get; private set; }
public double ScanCountScore { get; private set; }

public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fileInfo)
public double IsotopicPearsonCorrelation => Apex?.PearsonCorrelation ?? -1;
public double RtPredictionError { get; set; }
public List<int> ChargeList { get; set; }
internal double MbrQValue { get; set; }
public ChromatographicPeakData PepPeakData { get; set; }
public double? MbrPep { get; set; }

public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fileInfo, bool randomRt = false)
{
SplitRT = 0;
NumChargeStatesObserved = 0;
Expand All @@ -40,12 +43,14 @@ public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fi
IsotopicEnvelopes = new List<IsotopicEnvelope>();
IsMbrPeak = isMbrPeak;
SpectraFileInfo = fileInfo;
RandomRt = randomRt;
}

public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fileInfo, double predictedRetentionTime) :
this(id, isMbrPeak, fileInfo)
public bool Equals(ChromatographicPeak peak)
{
PredictedRetentionTime = predictedRetentionTime;
return SpectraFileInfo.Equals(peak.SpectraFileInfo)
&& Identifications.First().ModifiedSequence.Equals(peak.Identifications.First().ModifiedSequence)
&& ApexRetentionTime == peak.ApexRetentionTime;
}

public IsotopicEnvelope Apex { get; private set; }
Expand All @@ -54,13 +59,18 @@ public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fi
public int NumIdentificationsByBaseSeq { get; private set; }
public int NumIdentificationsByFullSeq { get; private set; }
public double MassError { get; private set; }
/// <summary>
nbollis marked this conversation as resolved.
Show resolved Hide resolved
/// Bool that describes whether the retention time of this peak was randomized
/// If true, implies that this peak is a decoy peak identified by the MBR algorithm
/// </summary>
public bool RandomRt { get; }
public bool DecoyPeptide => Identifications.First().IsDecoy;

public void CalculateIntensityForThisFeature(bool integrate)
{
if (IsotopicEnvelopes.Any())
{
double maxIntensity = IsotopicEnvelopes.Max(p => p.Intensity);
Apex = IsotopicEnvelopes.First(p => p.Intensity == maxIntensity);
Apex = IsotopicEnvelopes.MaxBy(p => p.Intensity);

if (integrate)
{
Expand Down Expand Up @@ -123,25 +133,6 @@ public void ResolveIdentifications()
this.NumIdentificationsByBaseSeq = Identifications.Select(v => v.BaseSequence).Distinct().Count();
this.NumIdentificationsByFullSeq = Identifications.Select(v => v.ModifiedSequence).Distinct().Count();
}

/// <summary>
/// Calculates four component scores and one overarching Mbr score for an MBR peak.
/// MBR Score is equal to 100 * the geometric mean of the four component scores.
/// </summary>
/// <param name="scorer"> An MbrScorer specific to the file where this peak was found </param>
/// <param name="donorPeak"> The donor peak used as the basis for the MBR identification. </param>
internal void CalculateMbrScore(MbrScorer scorer, ChromatographicPeak donorPeak)
{
if (SpectraFileInfo != scorer.AcceptorFile) throw new MzLibException("Error when performing match-between-runs: Mismatch between scorer and peak.");

IntensityScore = scorer.CalculateIntensityScore(this, donorPeak);
RtScore = scorer.CalculateRetentionTimeScore(this, donorPeak);
PpmScore = scorer.CalculatePpmErrorScore(this);
ScanCountScore = scorer.CalculateScanCountScore(this);

MbrScore = 100 * Math.Pow(IntensityScore * RtScore * PpmScore * ScanCountScore, 0.25);
}

public static string TabSeparatedHeader
{
get
Expand All @@ -164,20 +155,18 @@ public static string TabSeparatedHeader
sb.Append("Peak Charge" + "\t");
sb.Append("Num Charge States Observed" + "\t");
sb.Append("Peak Detection Type" + "\t");
sb.Append("MBR Score" + "\t");
sb.Append("Ppm Score" + "\t");
sb.Append("Intensity Score" + "\t");
sb.Append("Rt Score" + "\t");
sb.Append("Scan Count Score" + "\t");
sb.Append("PIP Q-Value" + "\t");
sb.Append("PIP PEP" + "\t");
sb.Append("PSMs Mapped" + "\t");
sb.Append("Base Sequences Mapped" + "\t");
sb.Append("Full Sequences Mapped" + "\t");
sb.Append("Peak Split Valley RT" + "\t");
sb.Append("Peak Apex Mass Error (ppm)");
sb.Append("Peak Apex Mass Error (ppm)" + "\t");
sb.Append("Decoy Peptide" + "\t");
sb.Append("Random RT");
return sb.ToString();
}
}

public override string ToString()
{
StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -260,17 +249,16 @@ public override string ToString()
sb.Append("" + "MSMS" + "\t");
}

sb.Append("" + (IsMbrPeak ? MbrScore.ToString() : "") + "\t");
sb.Append("" + (IsMbrPeak ? PpmScore.ToString() : "") + "\t");
sb.Append("" + (IsMbrPeak ? IntensityScore.ToString() : "") + "\t");
sb.Append("" + (IsMbrPeak ? RtScore.ToString() : "") + "\t");
sb.Append("" + (IsMbrPeak ? ScanCountScore.ToString() : "") + "\t");
sb.Append("" + (IsMbrPeak ? MbrQValue.ToString() : "") + "\t");
sb.Append("" + (IsMbrPeak ? MbrPep.ToString() : "") + "\t");

sb.Append("" + Identifications.Count + "\t");
sb.Append("" + NumIdentificationsByBaseSeq + "\t");
sb.Append("" + NumIdentificationsByFullSeq + "\t");
sb.Append("" + SplitRT + "\t");
sb.Append("" + MassError);
sb.Append("\t" + DecoyPeptide);
sb.Append("\t" + RandomRt);

return sb.ToString();
}
Expand Down
2 changes: 2 additions & 0 deletions mzLib/FlashLFQ/FlashLFQ.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<ItemGroup>
<PackageReference Include="CsvHelper" Version="32.0.3" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="Microsoft.ML" Version="3.0.1" />
<PackageReference Include="Microsoft.ML.FastTree" Version="3.0.1" />
<PackageReference Include="NetSerializer" Version="4.1.2" />
<PackageReference Include="SharpLearning.Optimization" Version="[0.28.0]" />
</ItemGroup>
Expand Down
38 changes: 27 additions & 11 deletions mzLib/FlashLFQ/FlashLFQResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -59,6 +58,17 @@ public FlashLfqResults(List<SpectraFileInfo> spectraFiles, List<Identification>
}
}

public void ReNormalizeResults(bool integrate = false, int maxThreads = 10, bool useSharedPeptides = false)
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add method description

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
Loading
Loading