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

ipaPy2 PR #629

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a338bbc
started ipapy2 clustering tool
hechth Dec 4, 2023
f95e14a
added empty lines
hechth Dec 4, 2023
4982aba
added help text
hechth Dec 4, 2023
8990fcf
added citation
hechth Dec 4, 2023
2e6e58f
added tests
hechth Dec 4, 2023
3c28584
lint
hechth Dec 4, 2023
357a3e5
Update macros.xml
ChangLiuuczlcl8 Dec 7, 2023
8286e5a
Add files via upload
ChangLiuuczlcl8 Dec 7, 2023
c5a98a0
Update ipapy2_clustering.py
ChangLiuuczlcl8 Dec 7, 2023
d9b87e9
Update ipapy2_clustering.xml
ChangLiuuczlcl8 Dec 7, 2023
9705593
Add files via upload
ChangLiuuczlcl8 Dec 8, 2023
8c5bafd
Add files via upload
ChangLiuuczlcl8 Dec 8, 2023
a7f5ff8
Add files via upload
ChangLiuuczlcl8 Dec 8, 2023
c217fe1
first
ChangLiuuczlcl8 Dec 11, 2023
94af151
Update tools/ipapy2/ipapy2_clustering.xml
hechth Dec 12, 2023
76dc71a
Merge branch 'ipa_stub' of github.com:RECETOX/galaxytools into ipa_stub
hechth Dec 12, 2023
04166cd
changed ionization to select
hechth Dec 12, 2023
651874d
Update tools/ipapy2/ipapy2_MS1_annotation.xml
ChangLiuuczlcl8 Dec 12, 2023
5e4d5e9
delete outdated files
ChangLiuuczlcl8 Dec 13, 2023
895aee6
add compute bio and gibbs sampler
ChangLiuuczlcl8 Dec 20, 2023
a37e307
fix error in macros
ChangLiuuczlcl8 Dec 20, 2023
f28a256
Merge pull request #474 from ChangLiuuczlcl8/ipa_stub
hechth Jul 25, 2024
f539a24
Merge branch 'master' into ipa_stub
hechth Jul 25, 2024
fc7b6e0
Merge branch 'master' into ipa_stub
hechth Aug 15, 2024
b088e09
Merge branch 'master' into ipa
Jan 10, 2025
3fabee0
fixed 3 tests
acquayefrank Jan 23, 2025
cf93eb6
fixed a few more tests
acquayefrank Jan 23, 2025
822ee55
cleaner test data
acquayefrank Jan 24, 2025
67f7cfe
cleaner test data
acquayefrank Jan 24, 2025
2c265d3
Merge branch 'RECETOX:master' into ipa
acquayefrank Jan 27, 2025
c8bb50e
working state
acquayefrank Jan 27, 2025
6e41fbf
Merge branch 'ipa' of github.com:acquayefrank/galaxytools into ipa
acquayefrank Jan 27, 2025
5be1b0d
Update tools/ipapy2/.shed.yml
acquayefrank Jan 28, 2025
77a0c8b
made changes based on code review
acquayefrank Jan 29, 2025
4cfdafd
completed ms annotation code cleanup
acquayefrank Jan 30, 2025
b3b9e04
finished refactoring
acquayefrank Jan 31, 2025
fe475ce
lint
hechth Feb 3, 2025
40f4207
lint and fixed tests
hechth Feb 3, 2025
5411edf
removed not needed code
hechth Feb 3, 2025
0694a63
added min and max values
hechth Feb 3, 2025
d806e37
lint
hechth Feb 3, 2025
96b7fb8
Merge branch 'RECETOX:master' into ipa
acquayefrank Feb 4, 2025
c978d8b
Update tools/ipapy2/ipapy2_MS1_annotation.xml
acquayefrank Feb 4, 2025
fc5625d
added some extra references in the README
acquayefrank Feb 4, 2025
a8c80e2
added imporvements from code review
acquayefrank Feb 4, 2025
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
15 changes: 15 additions & 0 deletions tools/ipapy2/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: ipaPy2
owner: recetox
remote_repository_url: "https://github.com/RECETOX/galaxytools/tree/master/tools/ipapy2"
homepage_url: "https://github.com/francescodc87/ipaPy2"
categories:
- Metabolomics
description: "Mass spectrometry data annotation tool."
long_description: "New Python implementation of the Integrated Probabilistic Annotation (IPA) - A Bayesian annotation method for LC/MS data integrating biochemical relations, isotope patterns and adduct formation."
auto_tool_repositories:
name_template: "{{ tool_id }}"
description_template: "{{ tool_name }} tool from the ipaPy2 package"
suite:
name: suite_ipapy2
description: tools from the ipaPy2 suite are used for annotation of mass spectrometry data
type: repository_suite_definition
Binary file not shown.
128 changes: 128 additions & 0 deletions tools/ipapy2/ipapy2_MS1_annotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import argparse


from ipaPy2 import ipa
from utils import flattern_annotations, LoadDataAction, StoreOutputAction


def main(
input_dataset_database,
input_dataset_adduct,
ppm,
ratiosd,
ppmunk,
ratiounk,
ppmthr,
pRTNone,
pRTout,
output_dataset,
ncores,
):
write_func, file_path = output_dataset

annotations = ipa.MS1annotation(
input_dataset_database,
input_dataset_adduct,
ppm=ppm,
ratiosd=ratiosd,
ppmunk=ppmunk,
ratiounk=ratiounk,
ppmthr=ppmthr,
pRTNone=pRTNone,
pRTout=pRTout,
ncores=ncores,
)
annotations_flat = flattern_annotations(annotations)
write_func(annotations_flat, file_path)


if __name__ == "__main__":
parser = argparse.ArgumentParser(
"""
Annotation of the dataset based on the MS1 information. Prior probabilities
are based on mass only, while post probabilities are based on mass, RT,
previous knowledge and isotope patterns.
"""
)
parser.add_argument(
"--input_dataset_database",
nargs=2,
action=LoadDataAction,
required=True,
help="A dataset containing the MS1 data. Ideally obtained from map_isotope_patterns",
)
parser.add_argument(
"--input_dataset_adducts",
nargs=2,
action=LoadDataAction,
required=True,
help="A dataset containing information on all possible adducts.",
)
parser.add_argument(
"--ppm",
type=float,
required=True,
default=100,
help="accuracy of the MS instrument used.",
)
parser.add_argument(
"--ratiosd",
type=float,
default=0.9,
help="acceptable ratio between predicted intensity and observed intensity of isotopes.",
)
parser.add_argument(
"--ppmunk",
type=float,
help="pm associated to the 'unknown' annotation. If not provided equal to ppm.",
)
parser.add_argument(
"--ratiounk",
type=float,
default=0.5,
help="isotope ratio associated to the 'unknown' annotation.",
)
parser.add_argument(
"--ppmthr",
type=float,
help="maximum ppm possible for the annotations. if not provided equal to 2*ppm.",
)
parser.add_argument(
"--pRTNone",
type=float,
default=0.8,
help="multiplicative factor for the RT if no RTrange present in the database.",
)
parser.add_argument(
"--pRTout",
type=float,
default=0.4,
help="multiplicative factor for the RT if measured RT is outside the RTrange present in the database.",
)
parser.add_argument(
"--output_dataset",
nargs=2,
action=StoreOutputAction,
required=True,
help="MS1 annotated data",
)
parser.add_argument(
"--ncores",
type=int,
default=None,
help="number of cores to use for the computation.",
)
args = parser.parse_args()
main(
args.input_dataset_database,
args.input_dataset_adducts,
args.ppm,
args.ratiosd,
args.ppmunk,
args.ratiounk,
args.ppmthr,
args.pRTNone,
args.pRTout,
args.output_dataset,
args.ncores,
)
73 changes: 73 additions & 0 deletions tools/ipapy2/ipapy2_MS1_annotation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<tool id="ipapy2_MS1_annotation" name="IPA MS1 annotation" version="@TOOL_VERSION@+galaxy0" profile="21.09">
<macros>
<import>macros.xml</import>
</macros>

<requirements>
<requirement type="package" version="@TOOL_VERSION@">ipapy2</requirement>
<expand macro="extra_requirements"/>
</requirements>

<command detect_errors="exit_code"><![CDATA[
#set $computed_ppmthr = float($ppm) * 2
python3 '${__tool_directory__}/ipapy2_MS1_annotation.py'
--input_dataset_database '${mapped_isotope_patterns}' '${mapped_isotope_patterns.ext}'
--input_dataset_adducts '${all_adducts}' '${all_adducts.ext}'
--ppm ${ppm}
--ratiosd ${ratiosd}
#if $ppmunk
--ppmunk ${ppmunk}
#else
--ppmunk ${ppm}
#end if
--ratiounk ${ratiounk}
#if $ppmthr
--ppmthr ${ppmthr}
#else
--ppmthr ${computed_ppmthr}
#end if
--pRTNone ${pRTNone}
--pRTout ${pRTout}
--output_dataset '${MS1_annotations}' '${MS1_annotations.ext}'
--ncores \${GALAXY_SLOTS:-1}
]]></command>

<inputs>
<param label="Mapped isotope patterns" name="mapped_isotope_patterns" type="data" format="csv,tsv,tabular,parquet" help="A dataset containing the MS1 data. Ideally obtained from map_isotope_patterns" />
<param label="all possible adducts" name="all_adducts" type="data" format="csv,tsv,tabular,parquet" help="A dataset containing the information on all the possible adducts given the database. Ideally obtained from compute_all_adducts" />
<expand macro="ppm"/>
<section name="unknown" title="settings for the identification of unknowns">
<expand macro="ms_unknown"/>
</section>
<section name="optional_settings" title="optional settings">
<expand macro="ms_options"/>
</section>
</inputs>

<outputs>
<data label="${tool.name} on ${on_string}" name="MS1_annotations" format_source="mapped_isotope_patterns"/>
</outputs>

<tests>
<test>
<param name="mapped_isotope_patterns" value="mapped_isotope_patterns.csv"/>
<param name="all_adducts" value="all_adducts.csv"/>
<param name="ppm" value="3"/>
<output name="MS1_annotations" file="MS1_annotations.csv" lines_diff="20"/>
</test>
</tests>

<help><![CDATA[
::
Annotation of the dataset based on the MS1 information. Prior probabilities
are based on mass only, while post probabilities are based on mass, RT,
previous knowledge and isotope patterns.

https://github.com/francescodc87/ipaPy2#usage

https://academic.oup.com/bioinformatics/article/39/7/btad455/7230779
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use the citation annotations for this. Freetext is very unstructured. If you add this to structured elements Galaxy can do some cool stuff with it.

Copy link
Author

@acquayefrank acquayefrank Feb 4, 2025

Choose a reason for hiding this comment

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

There is already a citations section in the help text; this was just added to provide more information for users.


]]></help>

<expand macro="citations"/>
</tool>
Loading
Loading