keggtools#
Submodules#
Attributes#
Classes#
Create color gradient. |
|
Component model. |
|
KEGG pathway enrichment analysis. |
|
Results of KEGG pathway enrichment analysis. |
|
Entry model class. |
|
Graphics information for rendering. |
|
KEGG Pathway object. |
|
Relation model class. |
|
Renderer for KEGG Pathway. |
|
KEGG pathway resolver class. |
|
Storage handler class. |
|
Subtype model class. |
Functions#
Load dataframe to map canonical pathway id of MSigDB to KEGG pathway id. |
|
|
Plot enrichment results. |
Package Contents#
- class keggtools.ColorGradient(start, stop, steps=100)#
Create color gradient.
- get_list()#
Get gradient color as list.
- static to_css(color)#
Convert color tuple to CSS rgb color string.
- class keggtools.Component(/, **data)#
Bases:
pydantic_xml.BaseXmlModel
Component model.
- Parameters:
data (Any)
- class keggtools.Enrichment(pathways)#
KEGG pathway enrichment analysis.
- Parameters:
pathways (list[keggtools.models.Pathway])
- all_pathways: list[keggtools.models.Pathway]#
- get_subset(subset, inplace=False)#
Create subset of analysis result by list of pathway ids.
- Parameters:
- Returns:
Subset of enrichment results.
- Return type:
- result: list[EnrichmentResult] = []#
- run_analysis(gene_list)#
List of gene ids. Return list of EnrichmentResult instances.
- Parameters:
- Returns:
List of enrichment result instances.
- Return type:
- to_csv(file_obj, delimiter='\t', overwrite=False)#
Save result summary as file.
- to_dataframe()#
Return analysis result as pandas DataFrame. Required pandas dependency.
- Returns:
Export enrichment results as pandas dataframe.
- Return type:
- class keggtools.EnrichmentResult(org, pathway_id, pathway_name, found_genes, pathway_genes, pathway_title=None)#
Results of KEGG pathway enrichment analysis.
- Parameters:
- __str__()#
Build string summary of KEGG path analysis result instance.
- Return type:
- Returns:
Returns string that describes the enrichment result instance.
- static get_header()#
Build default header for enrichment analysis.
- json_summary(gene_delimiter=',')#
Build json summary for enrichment analysis.
- class keggtools.Entry(/, **data)#
Bases:
pydantic_xml.BaseXmlModel
Entry model class.
- Parameters:
data (Any)
- get_gene_id()#
Parse variable ‘name’ of Entry into KEGG id.
- has_multiple_names()#
Checks if entry has multiple names that are space seperated.
- Returns:
Retruns True if entry has multiple names.
- Return type:
- type: keggtools._types.EntryTypeAlias#
- class keggtools.Graphics(/, **data)#
Bases:
pydantic_xml.BaseXmlModel
Graphics information for rendering.
- Parameters:
data (Any)
- class keggtools.Pathway(/, **data)#
Bases:
pydantic_xml.BaseXmlModel
KEGG Pathway object.
The KEGG pathway object stores graphics information and related objects.
- Parameters:
data (Any)
- get_entry_by_id(entry_id)#
Get pathway Entry object by id.
- get_genes()#
List all genes from pathway.
- class keggtools.Relation(/, **data)#
Bases:
pydantic_xml.BaseXmlModel
Relation model class.
- Parameters:
data (Any)
- type: keggtools._types.RelationTypeAlias#
- class keggtools.Renderer(kegg_pathway, gene_dict=None, cache_or_resolver=None, upper_color=(255, 0, 0), lower_color=(0, 0, 255))#
Renderer for KEGG Pathway.
- Parameters:
kegg_pathway (keggtools.models.Pathway)
cache_or_resolver (keggtools.storage.Storage | str | keggtools.resolver.Resolver | None)
- property cmap_downreg: list[str]#
Generated color map as list of hexadecimal strings for downregulated genes in gene dict.
- property cmap_upreg: list[str]#
Generated color map as list of hexadecimal strings for upregulated genes in gene dict.
- get_gene_color(gene_id, default_color=(255, 255, 255))#
Get overlay color for given gene.
- graph: pydot.Dot#
- pathway: keggtools.models.Pathway#
- render(display_unlabeled_genes=True)#
Render KEGG pathway.
- Parameters:
display_unlabeled_genes (bool) – Entries in the KGML format can have space-seperated entry names. Set this parameter to False to hide the entries.
- Return type:
None
- resolver: keggtools.resolver.Resolver = None#
- to_binary(extension)#
Export pydot graph to binary data.
- to_file(filename, extension)#
Export pydot graph to file.
- to_string()#
Pydot graph instance to dot string.
- Returns:
Generated dot string of pathway.
- Return type:
- class keggtools.Resolver(cache=None)#
KEGG pathway resolver class.
Request interface for KEGG API endpoint.
- Parameters:
cache (keggtools.storage.Storage | str | None)
- check_organism(organism)#
Check if organism code exist.
- get_compounds(**kwargs)#
Get dict of components. Request from KEGG API if not in cache.
- get_organism_list(**kwargs)#
Get organism codes from file or KEGG API.
- get_pathway(organism, code, **kwargs)#
Load and parse KGML pathway by identifier.
- get_pathway_list(organism, **kwargs)#
Request list of pathways linked to organism.
- storage: keggtools.storage.Storage = None#
- class keggtools.Storage(cachedir=None)#
Storage handler class.
- Parameters:
cachedir (str | None)
- build_cache_path(filename)#
Build absolute filename for caching directory.
- cachedir = None#
- check_cache_dir()#
Checks if cache dir exist. Raises “NotADirectoryError” of caching folder not found.
- Raises:
NotADirectoryError – Error if cache folder does not exist.
- Return type:
None
- exist(filename)#
Check if filename exist in caching dir.
- load(filename)#
Load string from file.
- load_dump(filename)#
Load binary dump from file.
- save(filename, data)#
Save string as file in local storage. Returns absolute filename of save file.
- class keggtools.Subtype(/, **data)#
Bases:
pydantic_xml.BaseXmlModel
Subtype model class.
- Parameters:
data (Any)
- name: keggtools._types.RelationSubtypeAlias#
- keggtools.msig_to_kegg_id()#
Load dataframe to map canonical pathway id of MSigDB to KEGG pathway id.
- Returns:
Dataframe containing MSigDB id and KEGG pathway id.
- Return type:
- Raises:
AssertionError – If mapping file does not exist.
- keggtools.plot_enrichment_result(enrichment, ax=None, figsize=(7, 7), cmap='coolwarm', min_study_count=1, max_pval=None, use_percent_study_count=True)#
Plot enrichment results.