-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add option to write fragment level quant #443
base: main
Are you sure you want to change the base?
Conversation
alphadia/constants/default.yaml
Outdated
@@ -237,6 +237,7 @@ fdr: | |||
search_output: | |||
peptide_level_lfq: false | |||
precursor_level_lfq: false | |||
fragment_quant_matrix: false |
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.
can you add a comment what this is doing and that this is an advanced feature
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.
👍 added
alphadia/outputtransform.py
Outdated
write_df( | ||
group_intensity_df, | ||
os.path.join( | ||
self.output_folder, f"fragment_{level_name}filt.matrix" |
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.
Is the filt
intended?
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.
yes, it is meant to indicate that the fragments are filtered using the precursor-level fragment filter
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.
please be more explicit, _filtered
or smth
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.
👍
tests/e2e_tests/e2e_test_cases.yaml
Outdated
@@ -85,6 +85,7 @@ test_cases: | |||
search_output: | |||
peptide_level_lfq: true | |||
precursor_level_lfq: true | |||
fragment_quant_matrix: true |
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.
Let's only test this in one of the testcases
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.
👍
alphadia/outputtransform.py
Outdated
"peptide", | ||
self.config["search_output"]["peptide_level_lfq"], | ||
), | ||
quantlevel_configs = [ # the configs specified here are: quantlevel, level_name, should_process, save_fragments |
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.
this could be a namedtuple for instance, then the comment will be obsolete as the code will tell
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.
dataclass should be nicer:
@dataclass
class LFQOutputConfig:
should_process: bool
quant_level: str
level_name: str
save_fragments: bool = False
quantlevel_configs = [
LFQOutputConfig(
self.config["search_output"]["precursor_level_lfq"],
"mod_seq_charge_hash",
"precursor",
self.config["search_output"]["fragment_quant_matrix"],
),
LFQOutputConfig(
self.config["search_output"]["peptide_level_lfq"],
"mod_seq_hash",
"peptide",
),
LFQOutputConfig(
True,
"pg",
"pg",
),
]
lfq_results = {}
for quantlevel_config in quantlevel_configs:
if not quantlevel_config.should_process:
continue
....
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.
👍
alphadia/outputtransform.py
Outdated
write_df( | ||
group_intensity_df, | ||
os.path.join( | ||
self.output_folder, f"fragment_{level_name}filt.matrix" |
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.
please be more explicit, _filtered
or smth
alphadia/constants/default.yaml
Outdated
@@ -237,6 +237,7 @@ fdr: | |||
search_output: | |||
peptide_level_lfq: false | |||
precursor_level_lfq: false | |||
fragment_quant_matrix: false #advanced feature to write out quantitative matrix with fragment ion intensities e.g. for AlphaQuant |
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.
save_fragment_quant_matrix
?
should this also be part of the GUI @GeorgWa ?
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.
Renamed it. Indeed I think it should be part of the GUI, would be good for AlphaQuant compatibility.
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.
LGTM
@@ -120,6 +121,7 @@ test_cases: | |||
search_output: | |||
peptide_level_lfq: true | |||
precursor_level_lfq: true | |||
save_fragment_quant_matrix: false |
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.
given that false
is the default, no need to specify it here in the yaml
s
group_intensity_df, | ||
os.path.join( | ||
self.output_folder, | ||
f"fragment_{quantlevel_config.level_name}filtered.matrix", |
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.
is .matrix
a special file format? or could this be something like .matrix.tsv
?
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 the file format is set by write_df
. To me it would also be fine if the advanced output is always saved as .parquet
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.
ah, did not look into write_df
to see path_no_format
👍
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.
LGTM! Thanks Constantin
group_intensity_df, | ||
os.path.join( | ||
self.output_folder, | ||
f"fragment_{quantlevel_config.level_name}filtered.matrix", |
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 the file format is set by write_df
. To me it would also be fine if the advanced output is always saved as .parquet
This PR adds the option to write to disk a matrix with fragment-level quantities which can be used for detailed inspection of the data or downstream quantification algorithms.
Changes:
SearchPlanOutput.build_lfq_tables()
to support fragment-level table export. When enabled, the feature exports the precursor-levelgroup_intensity_df
containing all fragments that pass the precursor level correlation filtersconfig_dict["search_output"]["fragment_quant_matrix"]
(default: false)