Skip to content

Commit

Permalink
add interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
cdiener committed Sep 13, 2024
1 parent af1b22a commit c7ba979
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
Binary file added docs/focal.qzv
Binary file not shown.
Binary file added docs/mes.qzv
Binary file not shown.
4 changes: 4 additions & 0 deletions q2_micom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
exchanges_per_taxon,
plot_tradeoff,
association,
focal_interactions,
mes
)

__version__ = "0.15.0"
Expand Down Expand Up @@ -56,6 +58,8 @@ def read_results(path):
"exchanges_per_taxon",
"plot_tradeoff",
"association",
"focal_interactions",
"mes",
"read_results",
"filter_models",
"filter_results",
Expand Down
31 changes: 31 additions & 0 deletions q2_micom/_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,34 @@ def association(
fdr_threshold,
atol=1e-6,
)


def focal_interactions(
output_dir: str,
results: GrowthResults,
taxon: str,
kind:str = "mass",
):
"""Plot for interactions."""
viz.plot_focal_interactions(
results,
filename=join(output_dir, "index.html"),
taxon=taxon,
kind=kind
)


def mes(
output_dir: str,
results: GrowthResults,
metadata: MetadataColumn = None,
prevalence:float = 0.5,
):
"""Test for differential metabolite production."""
meta = None if metadata is None else metadata.to_series()
viz.plot_mes(
results,
groups=meta,
filename=join(output_dir, "index.html"),
prevalence=prevalence
)
11 changes: 11 additions & 0 deletions q2_micom/citations.bib
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,14 @@ @article{gapseq
year={2021},
publisher={BioMed Central}
}

@article{marcelino,
title={Disease-specific loss of microbial cross-feeding interactions in the human gut},
author={Marcelino, Vanessa R and Welsh, Caitlin and Diener, Christian and Gulliver, Emily L and Rutten, Emily L and Young, Remy B and Giles, Edward M and Gibbons, Sean M and Greening, Chris and Forster, Samuel C},
journal={Nature Communications},
volume={14},
number={1},
pages={6546},
year={2023},
publisher={Nature Publishing Group UK London}
}
61 changes: 61 additions & 0 deletions q2_micom/plugin_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,65 @@
citations=[citations["micom"]],
)

plugin.visualizers.register_function(
function=q2_micom.focal_interactions,
inputs={"results": MicomResults},
parameters={
"taxon": Str,
"kind": Str,
},
input_descriptions={
"results": (
"A set of MICOM analysis results. "
"Contains predicted growth rates and exchange fluxes."
),
},
parameter_descriptions={
"taxon": (
"The focal taxon to use as a reference. You can use `plot-growth` to "
"check for valid taxa names."
),
"kind": (
"Which kind of flux to use. Either - 'flux': molar flux of a "
"metabolite - 'mass' (default): the mass flux (flux normalized by "
"molecular weight) - 'C': carbon flux - 'N': nitrogen flux."
)
},
name="Interactions for a taxon",
description=(
"Quantifies all metabolic interactions between a taxon of interest "
"(focal taxon) and all other taxa in all samples."
),
citations=[citations["micom"]],
)

plugin.visualizers.register_function(
function=q2_micom.mes,
inputs={"results": MicomResults},
parameters={
"metadata": MetadataColumn[Categorical],
"prevalence": Float % Range(0, 1),
},
input_descriptions={
"results": (
"A set of MICOM analysis results. "
"Contains predicted growth rates and exchange fluxes."
),
},
parameter_descriptions={
"metadata": "The metadata variable to use.",
"prevalence": (
"In what proportion of samples the metabolite has to have a "
"non-zero MES to be shown on the plots. Can be used to show only "
"very commonly exchanged metabolites."
),
},
name="Metabolic exchange scores",
description=(
"Calculates the metabolic exchange score (MES) for all metabolites "
"in all samples."
),
citations=[citations["micom"], citations["marcelino"]],
)

importlib.import_module("q2_micom._transform")

0 comments on commit c7ba979

Please sign in to comment.