skm_tools.translate
Translate Arabidopsis (ath) networks to other species with SKM gene translation files.
Functions
|
Load a SKM gene translation file, downloading it from skm.nib.si if missing. |
|
Translate the Arabidopsis genes of CKN to another species' gene identifiers. |
Module Contents
- skm_tools.translate.load_translation_file(species_code, translation_path=None, data_dir='.')
Load a SKM gene translation file, downloading it from skm.nib.si if missing.
- Parameters:
species_code (str) – SKM species code of the translation (e.g.
"stu"for potato,"parm"for apricot).translation_path (str or pathlib.Path, optional) – Local file (default
<data_dir>/translation_ath_to_<species_code>.tsv.gz); downloaded if it doesn’t exist (so it can be reused offline), gzipped if the name ends in.gz.data_dir (str or pathlib.Path) – Folder for the default file name (default: the current folder).
- Returns:
The translation table: the Arabidopsis genes (
ath_source), the genes of the species (a column named after the species, e.g.potato), and the evidence. All values are strings (empty: None).- Return type:
- skm_tools.translate.integrate_translation_ckn(g, translation_df, t_target_col, g_source_attribute='TAIR', t_source_col='ath_source', method='full_replacement', edges_within_translation=True, edges_across_translation=True, keep_unmapped=True)
Translate the Arabidopsis genes of CKN to another species’ gene identifiers.
Each node with an Arabidopsis gene identifier (g_source_attribute, e.g.
TAIR) is replaced by one node per translation of its gene; translations can be many-to-many, and all are kept. Translated node ids are{original}_{translation}, so one original can have several translations. Edges of the original node are copied to every new node. Nodes without an identifier (complexes, metabolites, processes, nodes of other species) are copied as they are.Translation edges (see edges_within_translation, edges_across_translation) have
typeandinteraction"homology"anddirectedFalse; in a directed graph, they are added in both directions.- Parameters:
g (networkx.Graph) – CKN with Arabidopsis gene identifiers (
species=="ath").translation_df (pandas.DataFrame) – Translation table, e.g. from
load_translation_file(), with a source (Arabidopsis) and a target identifier column.t_target_col (str) – Column of translation_df with the target species’ identifiers (e.g.
"potato").g_source_attribute (str) – Node attribute of g with the Arabidopsis identifier (default
"TAIR").t_source_col (str) – Column of translation_df with the Arabidopsis identifiers (default
"ath_source").method ({"full_replacement"}) – How to add the translations. Only
"full_replacement"(replace the original nodes) is implemented;"pendant_nodes"(add translations as extra nodes linked to the originals) is planned.edges_within_translation (bool) – Link the translations of the same original node to each other (
translation_relation=="same_translation_source").edges_across_translation (bool) – Link the nodes of different originals that translate to the same gene (
translation_relation=="same_translation_target").keep_unmapped (bool) – Keep the nodes with an identifier but without a translation (with
translatedFalse), or drop them and their edges.
- Returns:
A new graph: a (Multi)DiGraph if g is directed, a (Multi)Graph otherwise; a multigraph if either kind of translation edge is added. Translated nodes get the attributes
translation,translated_fromandtranslated.- Return type:
- Raises:
NotImplementedError – For a method other than
"full_replacement".