Mapping Functions
- class transbrain.trans.SpeciesTrans(atlas_type='bn')[source]
Bases:
objectTransfer phenotypes between species using graph embeddings.
- Parameters:
atlas_type ({'bn', 'dk', 'aal'}, optional) –
The type of human atlas used for initialization.
’bn’ : Brainnetome Atlas
’dk’ : Desikan-Killiany Atlas
’aal’ : Automated Anatomical Labeling (AAL) Atlas
Default is ‘bn’.
- atlas_type
The selected atlas type.
- Type:
str
- regions
Dictionary containing human and mouse brain regions (cortex, subcortex, all).
- Type:
dict
- embeddings
Loaded graph embeddings used for phenotype translation.
- Type:
np.ndarray
- _load_embeddings()[source]
Load graph embeddings for phenotype translation.
The function loads precomputed embeddings from a binary file (pickle format) based on the selected atlas type. These embeddings are used to map phenotypes between species.
- Returns:
A NumPy array containing the loaded embeddings corresponding to the specified atlas type.
- Return type:
np.ndarray
- _dual_mapping(pheno_data, source_matrix, target_matrix, normalize=False)[source]
Map phenotype data from source to target space using dual regression.
- Parameters:
pheno_data (np.ndarray) – An array of phenotype values (regions,) in the source species.
source_matrix (np.ndarray) – The embedding matrix for the source species.
target_matrix (np.ndarray) – The embedding matrix for the target species.
normalize (bool, optional) – Whether to normalize the phenotype values before regression. Default is False.
- Returns:
An array of predicted phenotype values in the target species.
- Return type:
np.ndarray
- _translate(phenotype, direction, region_type='cortex', normalize=True, restore=False)[source]
Unified translation method for both directions.
- Parameters:
phenotype (pd.DataFrame) – A DataFrame where rows are brain regions and columns are phenotype types.
direction ({'human_to_mouse', 'mouse_to_human'}) – The translation direction.
region_type ({'cortex', 'subcortex', 'all'}, optional) – The region subset to use for translation. Default is ‘cortex’.
normalize (bool, optional) – Whether to normalize phenotype values before translation. Default is True.
restore (bool, optional) – Whether to inverse-transform values back to original scale. Only used if normalize is True.
- Returns:
Translated phenotype values in the target species, indexed by brain region name.
- Return type:
pd.DataFrame
- mouse_to_human(phenotype, region_type='cortex', normalize=True, restore=False)[source]
Translate mouse phenotype to human.
- Parameters:
phenotype (pd.DataFrame) – Mouse phenotype DataFrame (regions × phenotypes).
region_type ({'cortex', 'subcortex', 'all'}, optional) – The brain region type to translate. Default is ‘cortex’.
normalize (bool, optional) – Whether to normalize data before translation. Default is True.
restore (bool, optional) – Whether to restore values back to original scale after translation. Only used if normalize is True.
- Returns:
Translated human phenotype DataFrame (regions × phenotypes).
- Return type:
pd.DataFrame
- human_to_mouse(phenotype, region_type='cortex', normalize=True, restore=False)[source]
Translate human phenotype to mouse.
- Parameters:
phenotype (pd.DataFrame) – Human phenotype DataFrame (regions × phenotypes).
region_type ({'cortex', 'subcortex', 'all'}, optional) – The brain region type to translate. Default is ‘cortex’.
normalize (bool, optional) – Whether to normalize data before translation. Default is True.
restore (bool, optional) – Whether to restore values back to original scale after translation. Only used if normalize is True.
- Returns:
Translated mouse phenotype DataFrame (regions × phenotypes).
- Return type:
pd.DataFrame