goatools.go_enrichment module

python %prog study.file population.file gene-association.file

This program returns P-values for functional enrichment in a cluster of study genes using Fisher’s exact test, and corrected for multiple testing (including Bonferroni, Holm, Sidak, and false discovery rate)

class goatools.go_enrichment.GOEnrichmentRecord(goid, **kwargs)[source]

Bases: object

Represents one result (from a single GOTerm) in the GOEnrichmentStudy

namespace2NS = {'biological_process': 'BP', 'cellular_component': 'CC', 'molecular_function': 'MF'}
get_method_name()[source]

Return name of first method in the method_flds list.

get_pvalue()[source]

Returns pval for 1st method, if it exists. Else returns uncorrected pval.

set_corrected_pval(nt_method, pvalue)[source]

Add object attribute based on method name.

get_indent_dots()[source]

Get a string of dots (”….”) representing the level of the GO term.

set_goterm(go2obj)[source]

Set goterm and copy GOTerm’s name and namespace.

property fold_enrichment

Ratio of observed to expected representation (study proportion / population proportion).

Returns the fold enrichment (>1 means enriched, <1 means purified/depleted). Returns None if the population proportion cannot be computed.

update_remaining_fldsdefprt(min_ratio=None)[source]

Finish updating self (GOEnrichmentRecord) field, is_ratio_different.

get_prtflds_default()[source]

Get default fields.

get_prtflds_all()[source]

When converting to a namedtuple, get all possible fields in their original order.

get_field_values(fldnames, rpt_fmt=True, itemid2name=None)[source]

Get flat namedtuple fields for one GOEnrichmentRecord.

class goatools.go_enrichment.GOEnrichmentStudy(pop, assoc, obo_dag, propagate_counts=True, alpha=0.05, methods=None, **kws)[source]

Bases: object

Runs Fisher’s exact test, as well as multiple corrections

objprtres = <goatools.godag.prtfncs.GoeaPrintFunctions object>
kws_ok: Set[str] = {'algorithm', 'alternative', 'log', 'name', 'pvalcalc', 'relationships'}
run_study(study, **kws)[source]

Run Gene Ontology Enrichment Study (GOEA) on study ids.

run_study_nts(study, **kws)[source]

Run GOEA on study ids. Return results as a list of namedtuples.

get_results_msg(results, study)[source]

Return summary for GOEA results.

get_pval_uncorr(study, log=sys.stdout, selected_goids=None)[source]

Calculate the uncorrected pvalues for study items.

static get_study_items(results)[source]

Return a list of study items associated with the given results.

print_results(results, min_ratio=None, indent=False, pval=0.05, prt=sys.stdout)[source]

Print GOEA results with some additional statistics calculated.

wr_txt(fout_txt, goea_results, prtfmt=None, **kws)[source]

Print GOEA results to text file.

static prt_txt(prt, goea_results, prtfmt=None, **kws)[source]

Print GOEA results in text format.

wr_xlsx(fout_xlsx, goea_results, **kws)[source]

Write a xlsx file.

wr_tsv(fout_tsv, goea_results, **kws)[source]

Write tab-separated table data to file

prt_tsv(prt, goea_results, **kws)[source]

Write tab-separated table data

static get_ns2nts(results, fldnames=None, **kws)[source]

Get namedtuples of GOEA results, split into BP, MF, CC.

static get_item_cnt(results, attrname='study_items')[source]

Get all study or population items (e.g., geneids).

wr_py_goea_results(fout_py, goea_results, **kws)[source]

Save GOEA results into Python package containing list of namedtuples.