ehrapy.tools.Translator#
- class ehrapy.tools.Translator(flavour='deepl', source='de', target='en', token=None)[source]#
Class providing an interface to all translation functions. Requires a flavour.
Methods table#
|
Translates a X column into the target language in place. |
|
Translates a single obs column and optionally replaces the original values |
|
Translates the provided text into the target language. |
|
Translates a single var column and optionally replaces the original values |
Methods#
translate_X_column#
- Translator.translate_X_column(adata, columns=typing.Union[str, typing.List], translate_column_name=False)[source]#
Translates a X column into the target language in place.
Note that the translation of a column in X is always in place.
- Parameters:
adata (
AnnData
) –AnnData
object containing the var column to translatetarget_language – The target language to translate into (default: EN-US)
columns – The columns to translate. Can be either a single column (str) or a list of columns
translate_column_name (
bool
) – Whether to translate the column name itself (only translates var_names, not var)
- Return type:
translate_obs_column#
- Translator.translate_obs_column(adata, columns=typing.Union[str, typing.List], translate_column_name=False, inplace=False)[source]#
Translates a single obs column and optionally replaces the original values
- Parameters:
adata (
AnnData
) –AnnData
object containing the obs column to translatetarget_language – The target language to translate into (default: EN-US)
columns – The columns to translate. Can be either a single column (str) or a list of columns
translate_column_name (
bool
) – Whether to translate the column name itselfinplace (
bool
) – Whether to replace the obs values or add a new obs column
- Return type:
translate_text#
translate_var_column#
- Translator.translate_var_column(adata, columns=typing.Union[str, typing.List], translate_column_name=False, inplace=False)[source]#
Translates a single var column and optionally replaces the original values
- Parameters:
adata (
AnnData
) –AnnData
object containing the obs column to translatetarget_language – The target language to translate into (default: EN-US)
columns – The columns to translate. Can be either a single column (str) or a list of columns
translate_column_name (
bool
) – Whether to translate the column name itselfinplace (
bool
) – Whether to replace the obs values or add a new obs column
- Return type: