Enrichr Tutorial#

Functions for posting genelists, retreiving ontologies, and plotting results from Enrichr. The basic workflow is:

  1. Post genelist

  2. Download results from ontologies

  3. Plot and analyze

Example#

First, post your genelist to the Enrichr website:

>>> mira.tl.post_genelist(mira.tools.enrichr_enrichments.example_genelist)
44149645

This function returns a post key, which may be used to retrieve results:

>>> results = mira.tl.fetch_ontologies(44149645,
... ontologies=['WikiPathways_2019_Mouse','BioPlanet_2019'])

You can manually provide ontologies of interest, or use MIRA’s default: mira.tl.LEGACY_ONTOLOGIES. The results are given as a python dictionary, and may be plotted using:

>>> mira.pl.plot_enrichments(results, plots_per_row = 1)
../_images/mira.topics.ExpressionTopicModel.plot_enrichments.svg

Functions#

mira.tl.post_genelist(genelist)#

Post genelist to Enrichr for comparison against pre-compiled ontologies.

Parameters
genelistIterable

List of genes

Returns
list_idstr

ID for genelist. Used to retrieve enrichment results.

mira.tl.fetch_ontologies(list_id, ontologies=['WikiPathways_2019_Human', 'WikiPathways_2019_Mouse', 'KEGG_2019_Human', 'KEGG_2019_Mouse', 'GO_Molecular_Function_2018', 'GO_Cellular_Component_2018', 'GO_Biological_Process_2018', 'BioPlanet_2019'])#

Fetch enrichment results from ontologies.

Parameters
list_idstr

genelist ID returned by post_genelist

onotologiesIterable[str], default = mira.tl.LEGACY_ONTOLOGIES

Retrieve results for these ontologies. For a full list of ontologies, see Enrichr.

Returns
resultsdict

Dictionary with schema:

{
    <ontology> : {
        [
            {'rank' : <rank>,
            'term' : <term>,
            'pvalue' : <pval>,
            'zscore': <zscore>,
            'combined_score': <combined_score>,
            'genes': [<gene1>, ..., <geneN>],
            'adj_pvalue': <adj_pval>},
            ...,
        ]
    }
}
mira.tl.fetch_ontology(list_id, ontology='WikiPathways_2019_Human')#

Fetch enrichment results from an ontology.

Parameters
list_idstr

genelist ID returned by post_genelist

onotologystr, default = “WikiPathways_2019_Human”

Retrieve results for this ontology. For a full list of ontologies, see Enrichr.

Returns
resultsdict

Dictionary with schema:

{
    <ontology> : {
        [
            {'rank' : <rank>,
            'term' : <term>,
            'pvalue' : <pval>,
            'zscore': <zscore>,
            'combined_score': <combined_score>,
            'genes': [<gene1>, ..., <geneN>],
            'adj_pvalue': <adj_pval>},
            ...,
        ]
    }
}