Skip to content

Commit b0e6988

Browse files
Filtering refactor (#2285)
* Refactored spectralLibraryGeneration * Refactored UpdateSpectralLibrary * Fixed test broken by changed file name * Increased test coverage * Wrote method in postSearchAnalysis for filtering psms * tests are breaking * Added call to filtering function * Formatted CommonParameters constructor for readability * Changed how results.txt files are written * Texts still breaking * Added parameter to disable filtering * Kicking the hornet's nest * Changed test tomls * Fixed Silac issue. All tests are passing * Deleted unused line in TestPsm * Finished refactoring postSearchAnalysisTask, changed associated test * Added test for pep filtering * Further changes to PostSearchAnalysisTaskTest * Finished filtering refactor, removed OutputFilters from Common Params * Deleted commented out lines * Deleted unused code from GUI * Minor changes to comments * Minor changes
1 parent 2fc4f6e commit b0e6988

25 files changed

+699
-468
lines changed

MetaMorpheus/EngineLayer/CommonParameters.cs

+51-14
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,41 @@ public CommonParameters()
1717
{
1818
}
1919

20-
public CommonParameters(string taskDescriptor = null, DissociationType dissociationType = DissociationType.HCD, DissociationType ms2childScanDissociationType = DissociationType.Unknown, DissociationType ms3childScanDissociationType = DissociationType.Unknown, string separationType = "HPLC", bool doPrecursorDeconvolution = true,
21-
bool useProvidedPrecursorInfo = true, double deconvolutionIntensityRatio = 3, int deconvolutionMaxAssumedChargeState = 12, bool reportAllAmbiguity = true,
22-
bool addCompIons = false, int totalPartitions = 1, double scoreCutoff = 5, int? numberOfPeaksToKeepPerWindow = 200, double? minimumAllowedIntensityRatioToBasePeak = 0.01, double? windowWidthThomsons = null, int? numberOfWindows = null, bool normalizePeaksAccrossAllWindows = false, bool trimMs1Peaks = false,
23-
bool trimMsMsPeaks = true, bool useDeltaScore = false, Tolerance productMassTolerance = null, Tolerance precursorMassTolerance = null, Tolerance deconvolutionMassTolerance = null,
24-
int maxThreadsToUsePerFile = -1, DigestionParams digestionParams = null, IEnumerable<(string, string)> listOfModsVariable = null, IEnumerable<(string, string)> listOfModsFixed = null, double qValueOutputFilter = 1.0, double pepQValueOutputFilter = 1.0,
25-
bool assumeOrphanPeaksAreZ1Fragments = true, int maxHeterozygousVariants = 4, int minVariantDepth = 1, bool addTruncations = false)
20+
public CommonParameters(
21+
string taskDescriptor = null,
22+
DissociationType dissociationType = DissociationType.HCD,
23+
DissociationType ms2childScanDissociationType = DissociationType.Unknown,
24+
DissociationType ms3childScanDissociationType = DissociationType.Unknown,
25+
string separationType = "HPLC",
26+
bool doPrecursorDeconvolution = true,
27+
bool useProvidedPrecursorInfo = true,
28+
double deconvolutionIntensityRatio = 3,
29+
int deconvolutionMaxAssumedChargeState = 12,
30+
bool reportAllAmbiguity = true,
31+
bool addCompIons = false,
32+
int totalPartitions = 1,
33+
double qValueThreshold = 0.01,
34+
double pepQValueThreshold = 1.0,
35+
double scoreCutoff = 5,
36+
int? numberOfPeaksToKeepPerWindow = 200,
37+
double? minimumAllowedIntensityRatioToBasePeak = 0.01,
38+
double? windowWidthThomsons = null,
39+
int? numberOfWindows = null,
40+
bool normalizePeaksAccrossAllWindows = false,
41+
bool trimMs1Peaks = false,
42+
bool trimMsMsPeaks = true,
43+
bool useDeltaScore = false,
44+
Tolerance productMassTolerance = null,
45+
Tolerance precursorMassTolerance = null,
46+
Tolerance deconvolutionMassTolerance = null,
47+
int maxThreadsToUsePerFile = -1,
48+
DigestionParams digestionParams = null,
49+
IEnumerable<(string, string)> listOfModsVariable = null,
50+
IEnumerable<(string, string)> listOfModsFixed = null,
51+
bool assumeOrphanPeaksAreZ1Fragments = true,
52+
int maxHeterozygousVariants = 4,
53+
int minVariantDepth = 1,
54+
bool addTruncations = false)
2655

2756
{
2857
TaskDescriptor = taskDescriptor;
@@ -33,6 +62,8 @@ public CommonParameters(string taskDescriptor = null, DissociationType dissociat
3362
ReportAllAmbiguity = reportAllAmbiguity;
3463
AddCompIons = addCompIons;
3564
TotalPartitions = totalPartitions;
65+
QValueThreshold = qValueThreshold;
66+
PepQValueThreshold = pepQValueThreshold;
3667
ScoreCutoff = scoreCutoff;
3768
NumberOfPeaksToKeepPerWindow = numberOfPeaksToKeepPerWindow;
3869
MinimumAllowedIntensityRatioToBasePeak = minimumAllowedIntensityRatioToBasePeak;
@@ -59,9 +90,6 @@ public CommonParameters(string taskDescriptor = null, DissociationType dissociat
5990
// reset custom fragmentation product types to default empty list
6091
DissociationTypeCollection.ProductsFromDissociationType[DissociationType.Custom] = new List<ProductType>() { };
6192

62-
QValueOutputFilter = qValueOutputFilter;
63-
PepQValueOutputFilter = pepQValueOutputFilter;
64-
6593
AssumeOrphanPeaksAreZ1Fragments = assumeOrphanPeaksAreZ1Fragments;
6694

6795
MaxHeterozygousVariants = maxHeterozygousVariants;
@@ -90,6 +118,18 @@ public CommonParameters(string taskDescriptor = null, DissociationType dissociat
90118
public Tolerance ProductMassTolerance { get; set; } // public setter required for calibration task
91119
public Tolerance PrecursorMassTolerance { get; set; } // public setter required for calibration task
92120
public bool AddCompIons { get; private set; }
121+
/// <summary>
122+
/// Only peptides/PSMs with Q-Value and Q-Value Notch below this threshold are used for quantification and
123+
/// spectral library generation. If SearchParameters.WriteHighQValuePsms is set to false, only
124+
/// peptides/PSMs with Q-Value/Notch below this threshold are included in .psmtsv results files.
125+
/// </summary>
126+
public double QValueThreshold { get; private set; }
127+
/// <summary>
128+
/// Only peptides/PSMs with PEP Q-Value below this threshold are used for quantification and
129+
/// spectral library generation. If SearchParameters.WriteHighQValuePsms is set to false, only
130+
/// peptides/PSMs with PEP Q-Value below this threshold are included in .psmtsv results files.
131+
/// </summary>
132+
public double PepQValueThreshold { get; private set; }
93133
public double ScoreCutoff { get; private set; }
94134
public DigestionParams DigestionParams { get; private set; }
95135
public bool ReportAllAmbiguity { get; private set; }
@@ -101,13 +141,10 @@ public CommonParameters(string taskDescriptor = null, DissociationType dissociat
101141
public bool TrimMs1Peaks { get; private set; }
102142
public bool TrimMsMsPeaks { get; private set; }
103143
public bool UseDeltaScore { get; private set; }
104-
public double QValueOutputFilter { get; private set; }
105-
public double PepQValueOutputFilter { get; private set; }
106144
public List<ProductType> CustomIons { get; private set; }
107145
public bool AssumeOrphanPeaksAreZ1Fragments { get; private set; }
108146
public int MaxHeterozygousVariants { get; private set; }
109147
public int MinVariantDepth { get; private set; }
110-
111148
public bool AddTruncations { get; private set; }
112149
public DissociationType DissociationType { get; private set; }
113150
public string SeparationType { get; private set; }
@@ -159,6 +196,8 @@ public CommonParameters CloneWithNewTerminus(FragmentationTerminus? terminus = n
159196
ReportAllAmbiguity,
160197
addCompIons.Value,//possibly changed
161198
TotalPartitions,
199+
QValueThreshold,
200+
PepQValueThreshold,
162201
ScoreCutoff,
163202
NumberOfPeaksToKeepPerWindow,
164203
MinimumAllowedIntensityRatioToBasePeak,
@@ -185,8 +224,6 @@ public CommonParameters CloneWithNewTerminus(FragmentationTerminus? terminus = n
185224
),
186225
ListOfModsVariable,
187226
ListOfModsFixed,
188-
QValueOutputFilter,
189-
PepQValueOutputFilter,
190227
AssumeOrphanPeaksAreZ1Fragments,
191228
MaxHeterozygousVariants,
192229
MinVariantDepth,

MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml

+41-37
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
<Setter Property="VerticalContentAlignment" Value="Center"/>
3636
<Setter Property="Padding" Value="3 0 0 0"/>
3737
</Style>
38+
<Style TargetType="local:DoubleTextBoxControl">
39+
<Setter Property="VerticalContentAlignment" Value="Center"/>
40+
<Setter Property="Padding" Value="3 0 0 0"/>
41+
</Style>
3842
</Window.Resources>
3943
<Grid>
4044
<Grid.RowDefinitions>
@@ -95,6 +99,7 @@
9599
<RowDefinition Height="1*"/>
96100
<RowDefinition Height="1*"/>
97101
<RowDefinition Height="1*"/>
102+
<RowDefinition Height="1*"/>
98103
</Grid.RowDefinitions>
99104

100105
<!-- Precursor Mass Tolerance -->
@@ -229,6 +234,41 @@
229234
</TextBox.ToolTip>
230235
</TextBox>
231236
</StackPanel>
237+
238+
<!-- Q-Value Filter -->
239+
<StackPanel Orientation="Horizontal" Margin="5 5 5 0" Grid.Column="0" Grid.Row="6">
240+
<Label x:Name="QValueThreshold" Content="Q-Value Threshold:" Width="150" />
241+
<local:DoubleTextBoxControl x:Name="QValueThresholdTextBox" Width="45"
242+
ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500"
243+
IsEnabled="{Binding ElementName=PepQValueThresholdCheckbox, Path=IsChecked, Converter={StaticResource InvertedBooleanConverter}}">
244+
<TextBox.ToolTip>
245+
<TextBlock>
246+
The maximum q-value of peptides used for quantification and spectral library generation. Protein group construction is not affected by this threshold.
247+
<LineBreak />
248+
If the q-value threshold is set, PEP q-value filtering will not be performed.
249+
</TextBlock>
250+
</TextBox.ToolTip>
251+
</local:DoubleTextBoxControl>
252+
</StackPanel>
253+
254+
<!-- PEP Q-Value Filter -->
255+
<StackPanel Orientation="Horizontal" Margin="5 5 5 0" Grid.Column="1" Grid.Row="6">
256+
<!-- pep 1-value button -->
257+
<CheckBox x:Name="PepQValueThresholdCheckbox" Content="PEP Q-Value Threshold:"
258+
IsChecked="False" Margin="5,5,5,0" />
259+
<local:DoubleTextBoxControl x:Name="PepQValueThresholdTextBox"
260+
IsEnabled="{Binding IsChecked, ElementName=PepQValueThresholdCheckbox}" Width="45"
261+
Height="23" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500">
262+
<TextBox.ToolTip>
263+
<TextBlock>
264+
The maximum q-value of peptides used for quantification and spectral library generation. Protein group construction is not affected by this threshold.
265+
<LineBreak />
266+
If the PEP q-value threshold is set, traditional q-value filtering will not be performed.
267+
</TextBlock>
268+
</TextBox.ToolTip>
269+
</local:DoubleTextBoxControl>
270+
</StackPanel>
271+
232272
</Grid>
233273
</StackPanel>
234274
</GroupBox>
@@ -533,6 +573,7 @@
533573
<!--<CheckBox x:Name="ckbPepXML" Content="Write .pep.XML" />-->
534574
<CheckBox x:Name="WriteDecoyCheckBox" Content="Write decoys" />
535575
<CheckBox x:Name="WriteContaminantCheckBox" Content="Write contaminants" />
576+
<CheckBox x:Name="WriteHighQPsmsCheckBox" Content="Write PSMs &amp; peptides with q-value above threshold"/>
536577
<CheckBox x:Name="WriteIndividualResultsCheckBox" Content="Write individual file results" />
537578
<CheckBox x:Name="WriteSpectralLibraryCheckBox" Content="Write spectral library" IsEnabled="{Binding IsChecked, Converter={local:BooleanInverter}, ElementName=CheckBoxLFQwSpectralRecovery }"/>
538579
<CheckBox x:Name="UpdateSpectralLibraryCheckBox" Content="Update spectral library" />
@@ -543,43 +584,6 @@
543584
<!-- filtering options -->
544585
<StackPanel Orientation="Vertical" Margin="5" Grid.Column="1">
545586

546-
<!-- pep 1-value button -->
547-
<Grid>
548-
<Grid.ColumnDefinitions>
549-
<ColumnDefinition Width="400" />
550-
<ColumnDefinition Width="50" />
551-
</Grid.ColumnDefinitions>
552-
553-
<RadioButton x:Name="PepQValueRadioButton" Content="Filter results to pep q-value:"
554-
IsChecked="False" GroupName="Filtering" Checked="PepQValueRadioButton_Checked">
555-
<ToolTipService.ToolTip>
556-
Removes PSM and protein results from the written output below the input pep q-value.
557-
Mutually exclusive with filter results to q-value
558-
</ToolTipService.ToolTip>
559-
</RadioButton>
560-
<TextBox x:Name="PepQValueTextBox" PreviewTextInput="CheckIfNumber" Margin="10,0,0,0"
561-
IsEnabled="{Binding IsChecked, ElementName=PepQValueRadioButton}" Width="45" Height="23" />
562-
</Grid>
563-
564-
<!-- q value button -->
565-
<Grid>
566-
<Grid.ColumnDefinitions>
567-
<ColumnDefinition Width="400" />
568-
<ColumnDefinition Width="50" />
569-
</Grid.ColumnDefinitions>
570-
571-
<RadioButton x:Name="QValueRadioButton" Content="Filter results to q-value:"
572-
IsChecked="False" GroupName="Filtering" Checked="QValueRadioButton_Checked">
573-
<ToolTipService.ToolTip>
574-
Removes PSM and protein results from the written output below the input q-value.
575-
Mutually exclusive with filter results to pep q-value
576-
</ToolTipService.ToolTip>
577-
</RadioButton>
578-
579-
<TextBox x:Name="QValueTextBox" PreviewTextInput="CheckIfNumber" Margin="10,0,0,0"
580-
IsEnabled="{Binding IsChecked, ElementName=QValueRadioButton}" Width="45" Height="23" />
581-
</Grid>
582-
583587
<!-- min score allowed box -->
584588
<Grid>
585589
<Grid.ColumnDefinitions>

0 commit comments

Comments
 (0)