Skip to content

Commit

Permalink
Merge branch 'qValueThresholdAdjustmentAndBugFix' of https://github.c…
Browse files Browse the repository at this point in the history
…om/trishorts/MetaMorpheus into qValueThresholdAdjustmentAndBugFix
  • Loading branch information
trishorts committed Nov 4, 2024
2 parents 3afcf09 + 4975e08 commit 70705b4
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 165 deletions.
29 changes: 14 additions & 15 deletions MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,24 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults)
//PEP will model will be developed using peptides and then applied to all PSMs.
Compute_PEPValue(myAnalysisResults, psms);

// peptides are ordered by MM score from good to bad in order to select the best PSM for each peptide
// peptides are ordered by PEP score from good to bad in order to select the best PSM for each peptide
peptides = psms
.OrderByDescending(p => p)
.GroupBy(p => p.FullSequence)
.Select(p => p.FirstOrDefault())
.OrderBy(p => p.FdrInfo.PEP) // Then order by PEP (PSM PEP and Peptide PEP are the same)
.OrderBy(p => p.FdrInfo.PEP)
.ThenByDescending(p => p)
.GroupBy(p => p.FullSequence)
.Select(p => p.FirstOrDefault()) // Get the best psm for each peptide based on PEP (default comparer is used to break ties)
.ToList();
CalculateQValue(peptides, peptideLevelCalculation: true, pepCalculation: true);

psms = psms.OrderBy(p => p.PsmFdrInfo.PEP).ThenByDescending(p => p).ToList();
psms = psms.OrderBy(p => p.FdrInfo.PEP).ThenByDescending(p => p).ToList();
CalculateQValue(psms, peptideLevelCalculation: false, pepCalculation: true);

}
else //we have more than 100 psms but less than 100 peptides so
{
//this will be done using PSMs because we dont' have enough peptides
Compute_PEPValue(myAnalysisResults, psms);
psms = psms.OrderBy(p => p.PsmFdrInfo.PEP).ThenByDescending(p => p).ToList();
psms = psms.OrderBy(p => p.FdrInfo.PEP).ThenByDescending(p => p).ToList();
CalculateQValue(psms, peptideLevelCalculation: false, pepCalculation: true);
}
}
Expand All @@ -117,27 +116,27 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults)
// really, in this case, we only need to run one or the other (i.e., only peptides or psms are passed in)
// but there's no mechanism to pass that info to the FDR analysis engine, so we'll do this for now
peptides = psms
.OrderByDescending(p => p)
.GroupBy(p => p.FullSequence)
.Select(p => p.FirstOrDefault()) // Get the best psm for each peptide based on MBR score
.OrderBy(p => p.FdrInfo.PEP) // Then order by PEP (PSM PEP and Peptide PEP are the same)
.OrderBy(p => p.FdrInfo.PEP)
.ThenByDescending(p => p)
.GroupBy(p => p.FullSequence)
.Select(p => p.FirstOrDefault()) // Get the best psm for each peptide based on PEP (default comparer is used to break ties)
.ToList();
CalculateQValue(peptides, peptideLevelCalculation: true, pepCalculation: true);

psms = psms
.OrderBy(p => p.PsmFdrInfo.PEP)
.OrderBy(p => p.FdrInfo.PEP)
.ThenByDescending(p => p)
.ToList();
CalculateQValue(psms, peptideLevelCalculation: false, pepCalculation: true);

}

//we do this section last so that target and decoy counts written in the psmtsv files are appropriate for the sort order which is by MM score
peptides = psms
.OrderByDescending(p => p)
.OrderBy(p => p.FdrInfo.PEP)
.ThenByDescending(p => p)
.GroupBy(b => b.FullSequence)
.Select(b => b.FirstOrDefault())
.Select(b => b.FirstOrDefault()) // Get the best psm for each peptide based on PEP (default comparer is used to break ties)
.OrderByDescending(p => p) // Sort using the default comparer before calculating Q Values
.ToList();
CalculateQValue(peptides, peptideLevelCalculation: true, pepCalculation: false);

Expand Down
36 changes: 18 additions & 18 deletions MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="maxMissedCleavageLabel" Content="Max Missed Cleavages" />
<TextBox x:Name="MissedCleavagesTextBox" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500" TextChanged="ProteaseSpecificUpdate">
<local:IntegerTexBoxControl x:Name="MissedCleavagesTextBox" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500" TextChanged="ProteaseSpecificUpdate">
<TextBox.ToolTip>
<TextBlock>
Maximum number of missed proteolytic cleavages allowed.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="proteaseLabel" Content="Protease" />
Expand All @@ -114,55 +114,55 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="lblMinPeptideLength" Content="Min Peptide Len" />
<TextBox x:Name="MinPeptideLengthTextBox" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<local:IntegerTexBoxControl x:Name="MinPeptideLengthTextBox" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<TextBox.ToolTip>
<TextBlock>
The minimum allowed peptide length. Must be a positive, non-zero integer.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="lblMaxPeptideLength" Content="Max Peptide Len" />
<TextBox x:Name="MaxPeptideLengthTextBox" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500" TextChanged="ProteaseSpecificUpdate">
<local:IntegerTexBoxControl x:Name="MaxPeptideLengthTextBox" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500" TextChanged="ProteaseSpecificUpdate">
<TextBox.ToolTip>
<TextBlock>
The maximum allowed peptide length. Leave empty for no limitation.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="LbMinVariantDepth" Content="Min read depth for variants" />
<TextBox x:Name="MinVariantDepthTextBox" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<local:IntegerTexBoxControl x:Name="MinVariantDepthTextBox" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<TextBox.ToolTip>
<TextBlock>
The minimum number of reads to consider a nucleic acid sequence variant.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="LbMaxHeterozygousVariants" Content="Max heterozygous variants for combinitorics" />
<TextBox x:Name="MaxHeterozygousVariantsTextBox" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<local:IntegerTexBoxControl x:Name="MaxHeterozygousVariantsTextBox" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<TextBox.ToolTip>
<TextBlock>
The maximum number of heterozygous variants for combinitorics.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="MinimumScoreLabel" Content="Minimum score allowed:" />
<TextBox x:Name="MinScoreAllowed" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<local:IntegerTexBoxControl x:Name="MinScoreAllowed" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<TextBox.ToolTip>
<TextBlock>
The minimum MetaMorpheus score allowed for a PSM to be reportable.
<LineBreak/>
Decreasing this number increases search time.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="1">
Expand All @@ -188,25 +188,25 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="MaxModsPerPeptideLabel" Content="Max Mods Per Peptide" />
<TextBox x:Name="MaxModsPerPeptideTextBox" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<local:IntegerTexBoxControl x:Name="MaxModsPerPeptideTextBox" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<TextBox.ToolTip>
<TextBlock>
The maximum number of modifications allowed on a single isoform.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="MaxModificationIsoformsLabel" Content="Max Modification Isoforms" />
<TextBox x:Name="MaxModificationIsoformsTextBox" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<local:IntegerTexBoxControl x:Name="MaxModificationIsoformsTextBox" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<TextBox.ToolTip>
<TextBlock>
The maximum number of isoforms (sequences with modifications) allowed from a given unmodified "base-sequence".
<LineBreak/>
This prevents highly ambiguous regions from greatly expanding the search space.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label x:Name="ionsToSearchLabel" Content="Dissociation Type" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
Expand All @@ -220,15 +220,15 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<Label Content="Max Threads" />
<TextBox x:Name="MaxThreadsTextBox" PreviewTextInput="CheckIfNumber" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<local:IntegerTexBoxControl x:Name="MaxThreadsTextBox" Width="45" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
<TextBox.ToolTip>
<TextBlock>
By default, MetaMorpheus uses this machine's number of threads minus one to maximize search speed while letting you use your computer for other purposes.
<LineBreak/>
Enter a lower number to limit CPU usage.
</TextBlock>
</TextBox.ToolTip>
</TextBox>
</local:IntegerTexBoxControl>
</StackPanel>
</StackPanel>
</Grid>
Expand Down
5 changes: 0 additions & 5 deletions MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,6 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
DialogResult = true;
}

private void CheckIfNumber(object sender, TextCompositionEventArgs e)
{
e.Handled = GlobalGuiSettings.CheckIsPositiveInteger(e.Text);
}

private void KeyPressed(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
Expand Down
Loading

0 comments on commit 70705b4

Please sign in to comment.