-
Notifications
You must be signed in to change notification settings - Fork 38
IsoTracker: Change searching target #873
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
Open
RayMSMS
wants to merge
10
commits into
master
Choose a base branch
from
IsoTracker_ChangeTarget
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
60a5c06
Create the new class "IsobaricPeptide"
RayMSMS 6c8851a
Fix the error in reference XIC chosing.
RayMSMS f8a38c1
Clean the redundant tester.
RayMSMS dd259a8
clean up
RayMSMS 3f35387
clean the line
RayMSMS 53eefc1
Clean the line
RayMSMS 370cc69
Clean the line
RayMSMS 44ae61b
Merge branch 'master' into IsoTracker_ChangeTarget
RayMSMS edda4e3
Address the comment
RayMSMS 7b0b110
Merge branch 'IsoTracker_ChangeTarget' of https://github.com/smith-ch…
RayMSMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| using FlashLFQ.Interfaces; | ||
|
|
||
| [assembly: InternalsVisibleTo("TestFlashLFQ")] | ||
| [assembly: InternalsVisibleTo("Test")] | ||
|
|
||
| namespace FlashLFQ | ||
| { | ||
|
|
@@ -47,7 +48,7 @@ public class FlashLfqEngine | |
| //IsoTracker settings | ||
| public readonly bool IsoTracker; //Searching parameter for the FlashLFQ engine | ||
| public bool IsoTrackerIsRunning { get; private set;} // a flag used to indicate if the isobaric case is running, used to control the indexEngine | ||
| public ConcurrentDictionary<string, Dictionary<PeakRegion, List<ChromatographicPeak>>> IsobaricPeptideDict { get; private set; } // The dictionary of isobaric peaks for each modified sequence | ||
| public ConcurrentDictionary<PeptideMassBin, Dictionary<PeakRegion, List<ChromatographicPeak>>> IsobaricPeptideDict { get; private set; } // The dictionary of isobaric peaks for each modified sequence | ||
|
|
||
| // MBR settings | ||
| public readonly bool MatchBetweenRuns; | ||
|
|
@@ -253,7 +254,7 @@ public FlashLfqResults Run() | |
| if (IsoTracker) | ||
| { | ||
| IsoTrackerIsRunning = true; // Turn on the flag, then we will use the separate indexEngine for each files | ||
| IsobaricPeptideDict = new ConcurrentDictionary<string, Dictionary<PeakRegion, List<ChromatographicPeak>>>(); | ||
| IsobaricPeptideDict = new ConcurrentDictionary<PeptideMassBin, Dictionary<PeakRegion, List<ChromatographicPeak>>>(); | ||
| QuantifyIsobaricPeaks(); | ||
| _results.IsobaricPeptideDict = IsobaricPeptideDict; | ||
| AddIsoPeaks(); | ||
|
|
@@ -1967,21 +1968,18 @@ private void QuantifyIsobaricPeaks() | |
| double lastReportedProgress = 0; | ||
| double currentProgress = 0; | ||
|
|
||
| var idGroupedBySeq = _allIdentifications | ||
| .Where(p => p.BaseSequence != p.ModifiedSequence && !p.IsDecoy) | ||
| .GroupBy(p => new | ||
| { p.BaseSequence, MonoisotopicMassGroup = Math.Round(p.MonoisotopicMass / 0.0001) }) | ||
| .ToList(); | ||
|
|
||
| Parallel.ForEach(Partitioner.Create(0, idGroupedBySeq.Count), | ||
| // Group the identifications by their mass, and build the isobaricPeptide | ||
| Tolerance massTolerance = new PpmTolerance(PpmTolerance); | ||
| List<PeptideMassBin> peptideMassBins = SortIsobaricPeptide(_allIdentifications, massTolerance); | ||
| Parallel.ForEach(Partitioner.Create(0, peptideMassBins.Count), | ||
| new ParallelOptions { MaxDegreeOfParallelism = MaxThreads }, | ||
| (range, loopState) => | ||
| { | ||
| for (int i = range.Item1; i < range.Item2; i++) | ||
| { | ||
| var idGroup = idGroupedBySeq[i]; | ||
| var isobaricPeptide = peptideMassBins[i]; | ||
| List<XIC> xicGroup = new List<XIC>(); | ||
| var mostCommonChargeIdGroup = idGroup.GroupBy(p => p.PrecursorChargeState).OrderBy(p => p.Count()).Last(); | ||
| var mostCommonChargeIdGroup = isobaricPeptide.Ids.GroupBy(p => p.PrecursorChargeState).OrderBy(p => p.Count()).Last(); | ||
| var id = mostCommonChargeIdGroup.First(); | ||
|
|
||
| // Try to get the primitive window for the XIC , from the (firstOne - 2) -> (lastOne + 2) | ||
|
|
@@ -2010,7 +2008,7 @@ private void QuantifyIsobaricPeaks() | |
| if (xicGroup.Count > 1) | ||
| { | ||
| // Step 1: Find the XIC with most IDs then, set as reference XIC | ||
| xicGroup.OrderBy(p => p.Ids.Count()).First().Reference = true; | ||
| xicGroup.OrderByDescending(p => p.Ids.Count()).First().Reference = true; | ||
|
|
||
| //Step 2: Build the XICGroups | ||
| XICGroups xICGroups = new XICGroups(xicGroup); | ||
|
|
@@ -2038,15 +2036,15 @@ private void QuantifyIsobaricPeaks() | |
| } | ||
| } | ||
| } | ||
| IsobaricPeptideDict.TryAdd(id.ModifiedSequence, sharedPeaksDict); | ||
| IsobaricPeptideDict.TryAdd(isobaricPeptide, sharedPeaksDict); | ||
| } | ||
|
|
||
| // report search progress (proteins searched so far out of total proteins in database) | ||
| if (!Silent) | ||
| { | ||
| Interlocked.Increment(ref isoGroupsSearched); | ||
|
|
||
| double percentProgress = ((double)isoGroupsSearched / idGroupedBySeq.Count * 100); | ||
| double percentProgress = ((double)isoGroupsSearched / peptideMassBins.Count * 100); | ||
| currentProgress = Math.Max(percentProgress, currentProgress); | ||
|
|
||
| if (currentProgress > lastReportedProgress + 10) | ||
|
|
@@ -2061,6 +2059,38 @@ private void QuantifyIsobaricPeaks() | |
| Console.WriteLine("Finished quantifying isobaric species!"); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Sort ids in the IDList and classify into isobaricPeptide by their mass. | ||
| /// </summary> | ||
| internal List<PeptideMassBin> SortIsobaricPeptide(List<Identification> _allIdentifications, Tolerance massTolerance) | ||
| { | ||
| List<PeptideMassBin> isobaricPeptides = new List<PeptideMassBin>(); | ||
| var ids = _allIdentifications.Where(p => p.BaseSequence != p.ModifiedSequence).OrderBy(p => p.PeakfindingMass).ToList(); | ||
|
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. can you add a comment explaining this restriction |
||
|
|
||
| for (int i = 0; i < ids.Count; i++) | ||
| { | ||
| Identification id = ids[i]; | ||
| PeptideMassBin isobaricPeptide = new PeptideMassBin(id, massTolerance); | ||
|
|
||
| for (int j = i+1; j < ids.Count; j++) | ||
| { | ||
| Identification id2 = ids[j]; | ||
| if (id2.PeakfindingMass < isobaricPeptide.MaxMass) | ||
| { | ||
| isobaricPeptide.Ids.Add(id2); | ||
| i = j; | ||
| } | ||
| else | ||
| { | ||
| i = j-1; | ||
| break; | ||
| } | ||
| } | ||
| isobaricPeptides.Add(isobaricPeptide); | ||
| } | ||
| return isobaricPeptides; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Build the XIC from the given IDs. | ||
| /// </summary> | ||
|
|
||
This file contains hidden or 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,30 @@ | ||
| using MzLibUtil; | ||
| using System.Collections.Generic; | ||
|
|
||
|
|
||
| namespace FlashLFQ.IsoTracker | ||
| { | ||
| /// <summary> | ||
| /// This class is used to group isobaric peptides together based on their mass. | ||
| /// </summary> | ||
| public class PeptideMassBin | ||
| { | ||
| public double MaxMass { get; private set; } // The mass of the isobaric peptide | ||
| public List<Identification> Ids { get; set; } // The identification of the isobaric peptide | ||
|
|
||
| public PeptideMassBin(Identification id, Tolerance tolerance) | ||
|
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. i think you should specify the kind of tolerance (ppm or mass) |
||
| { | ||
| Ids = new List<Identification>() { id }; | ||
| MaxMass = tolerance.GetMaximumValue(id.PeakfindingMass); | ||
| } | ||
|
|
||
| public override bool Equals(object obj) | ||
| { | ||
| return base.Equals(obj); | ||
| } | ||
| public override int GetHashCode() | ||
| { | ||
| return base.GetHashCode(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this should be PeptideMzBin unless it is deconvoluted neutral mass. In that case, Mass is fine.