keggtools.utils#
Basic utils for HTTP requests, parsing and rendering.
Classes#
Create color gradient. |
Functions#
|
Check if gene identifer is valid. String must match "<org>:<number>". |
|
Check if string is a valid hex color. |
|
Check if combined pathway identifer is valid. String must match "path:<org><number>". |
|
Check if pathway number has correct 5 digit format. |
|
Check if organism identifier is valid. |
|
Use pybiomart to merge entrez gene id to differential expression dataframe. |
Load dataframe to map canonical pathway id of MSigDB to KEGG pathway id. |
|
|
Parse .tsv file from string. |
|
Parse .tsv file from string and build dict from first two columns. Other columns are ignored. |
|
Returns XML Element object from string or XML Element. |
Module Contents#
- class keggtools.utils.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.
- keggtools.utils.is_valid_gene_name(value)#
Check if gene identifer is valid. String must match “<org>:<number>”.
- keggtools.utils.is_valid_hex_color(value)#
Check if string is a valid hex color.
- keggtools.utils.is_valid_pathway_name(value)#
Check if combined pathway identifer is valid. String must match “path:<org><number>”.
- keggtools.utils.is_valid_pathway_number(value)#
Check if pathway number has correct 5 digit format.
- keggtools.utils.is_valid_pathway_org(value)#
Check if organism identifier is valid.
- keggtools.utils.merge_entrez_geneid(diffexp, gene_column='names', dataset_name='hsapiens_gene_ensembl', symbol_source='hgnc_symbol', entrez_source='entrezgene_id', use_cache=True)#
Use pybiomart to merge entrez gene id to differential expression dataframe.
- Parameters:
diffexp (pandas.DataFrame) – Pandas dataframe containing to differential expression data.
gene_column (str) – Name of column in differential expression dataframe that contains to gene symbol.
dataset_name (str) – Biomart dataset to use for conversion.
symbol_source (str) – Biomart source dataset for gene symbol.
entrez_source (str) – Biomart source dataset for entrez id.
use_cache (bool) – Use cache for pybioart requests. Defaults to True.
- Returns:
Returns differential expression dataframe with merged column for entrez id.
- Return type:
- keggtools.utils.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.utils.parse_tsv(data)#
Parse .tsv file from string.
- keggtools.utils.parse_tsv_to_dict(data, col_keys=0, col_values=1)#
Parse .tsv file from string and build dict from first two columns. Other columns are ignored.
- keggtools.utils.parse_xml(xml_object_or_string)#
Returns XML Element object from string or XML Element.
- Parameters:
xml_object_or_string (str | xml.etree.ElementTree.Element) – Input parameter to check.
xml_object_or_string
- Returns:
XML element instance.
- Return type: