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

Enable local gene list analysis #158

Open
cthoyt opened this issue Mar 21, 2024 · 0 comments
Open

Enable local gene list analysis #158

cthoyt opened this issue Mar 21, 2024 · 0 comments

Comments

@cthoyt
Copy link
Member

cthoyt commented Mar 21, 2024

Right now, there are several gene list analysis available through the INDRA Discovery website (https://discovery.indra.bio/gene/discrete, https://discovery.indra.bio/gene/signed, https://discovery.indra.bio/gene/continuous). Depending on the query, they can be slow, so it would be nice to have a way to run these analyses locally with an indra_cogex.client module that interacts with the REST API to get the underlying data that's necessary, then run the analysis locally.

This shouldn't be a huge lift, since most of the code necessary to run this is modularized already inside the web endpoints (see below), but one change is that it currently uses the client to interact with the database directly, and we'd want to switch that to a different client that interacts with the API, so we don't have to give direct access to the database

def discretize_analysis():
"""Render the home page."""
form = DiscreteForm()
if form.validate_on_submit():
method = form.correction.data
alpha = form.alpha.data
keep_insignificant = form.keep_insignificant.data
minimum_evidence_count = form.minimum_evidence.data
minimum_belief = form.minimum_belief.data
genes, errors = form.parse_genes()
gene_set = set(genes)
go_results = go_ora(
client,
gene_set,
method=method,
alpha=alpha,
keep_insignificant=keep_insignificant,
)
wikipathways_results = wikipathways_ora(
client,
gene_set,
method=method,
alpha=alpha,
keep_insignificant=keep_insignificant,
)
reactome_results = reactome_ora(
client,
gene_set,
method=method,
alpha=alpha,
keep_insignificant=keep_insignificant,
)
phenotype_results = phenotype_ora(
gene_set,
client=client,
method=method,
alpha=alpha,
keep_insignificant=keep_insignificant,
)
if form.indra_path_analysis.data:
indra_upstream_results = indra_upstream_ora(
client,
gene_set,
method=method,
alpha=alpha,
keep_insignificant=keep_insignificant,
minimum_evidence_count=minimum_evidence_count,
minimum_belief=minimum_belief,
)
indra_downstream_results = indra_downstream_ora(
client,
gene_set,
method=method,
alpha=alpha,
keep_insignificant=keep_insignificant,
minimum_evidence_count=minimum_evidence_count,
minimum_belief=minimum_belief,
)
else:
indra_upstream_results = None
indra_downstream_results = None
if INDRA_COGEX_WEB_LOCAL and form.local_download.data:
downloads = Path.home().joinpath("Downloads")
go_results.to_csv(
downloads.joinpath("go_results.tsv"), sep="\t", index=False
)
wikipathways_results.to_csv(
downloads.joinpath("wikipathways_results.tsv"), sep="\t", index=False
)
reactome_results.to_csv(
downloads.joinpath("reactome_results.tsv"), sep="\t", index=False
)
phenotype_results.to_csv(
downloads.joinpath("phenotype_results.tsv"), sep="\t", index=False
)
if form.indra_path_analysis.data:
indra_downstream_results.to_csv(
downloads.joinpath("indra_downstream_results.tsv"),
sep="\t",
index=False,
)
indra_upstream_results.to_csv(
downloads.joinpath("indra_upstream_results.tsv"),
sep="\t",
index=False,
)
flask.flash(f"Downloaded files to {downloads}")
return flask.redirect(url_for(f".{discretize_analysis.__name__}"))
return flask.render_template(
"gene_analysis/discrete_results.html",
genes=genes,
errors=errors,
method=method,
alpha=alpha,
go_results=go_results,
wikipathways_results=wikipathways_results,
reactome_results=reactome_results,
phenotype_results=phenotype_results,
indra_downstream_results=indra_downstream_results,
indra_upstream_results=indra_upstream_results,
)
return flask.render_template(
"gene_analysis/discrete_form.html",
form=form,
example_hgnc_ids=", ".join(EXAMPLE_GENE_IDS),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant