Skip to content

Setup

Tell kDomainBench where the method environments are. The kdomainbench command has its own page, Command line.

set_env

set_env(key, interpreter=None, r_lib=None)

Point one method environment at an interpreter, for this Python session.

An environment variable (KDB_PY_PYTHON, KDB_SPATIALDE_PYTHON, KDB_RSCRIPT, KDB_METRICS_RSCRIPT, KDB_R_LIB) still wins over this setting.

PARAMETER DESCRIPTION
key

"py" (kdb_py), "spatialde" (kdb_spatialde), "r" (your R) or "metrics" (the R of the metric code, when it is not the R of the methods).

TYPE: str

interpreter

The environment's python, or Rscript for "r" and "metrics". It is checked when a method starts, not here.

TYPE: str or path DEFAULT: None

r_lib

An isolated R library for the R methods, whatever key is. They then see only this library and base R. The metric code uses it too, unless "metrics" names its own Rscript.

TYPE: str or path DEFAULT: None

RAISES DESCRIPTION
ValueError

Unknown key.

Examples:

>>> kdb.set_env("spatialde", "/opt/envs/kdb_spatialde/bin/python")
>>> kdb.set_env("r", "/usr/bin/Rscript", r_lib="/path/to/R/library")

example_data

example_data(folder='data')

Download the example file of the tutorials, DLPFC sample 151509.

A cloned repository already has the file in data/, and then nothing is downloaded. A file that is there is checked too.

PARAMETER DESCRIPTION
folder

Where the file goes. It is created when missing.

TYPE: str or path DEFAULT: 'data'

RETURNS DESCRIPTION
Path

<folder>/D3_151509_5k.h5ad (14 MB): 4,786 spots with the reference annotation in obs["clusters"].

RAISES DESCRIPTION
ValueError

The download, or the file already in folder, is not the example file. Nothing is written.

Examples:

>>> kdb.example_data()
PosixPath('data/D3_151509_5k.h5ad')

Environment variables

Variable Meaning Default
KDB_PY_PYTHON python of kdb_py the conda env kdb_py
KDB_SPATIALDE_PYTHON python of kdb_spatialde the conda env kdb_spatialde
KDB_ENVS_DIR folder with the two conda environments. kdomainbench install creates them there, and they are looked for there first conda's own folder
KDB_RSCRIPT Rscript for the R methods Rscript on PATH
KDB_R_LIB separate R library. The R methods see only it and base R none
KDB_METRICS_RSCRIPT Rscript for the metric code, when it is not the R of the methods. KDB_R_LIB is not applied to it the R of the methods
OMP_NUM_THREADS threads of CellCharter, DeepST and SpaGCN every core of the machine
PRECAST_CORES worker processes of PRECAST 4
SCMEB_PARALLEL TRUE = run SC.MEB with parallel workers FALSE
SCMEB_CORES worker processes of SC.MEB when SCMEB_PARALLEL=TRUE 3

Without the first three variables, the conda envs are looked for next to the environment kdomainbench runs in, then under $CONDA_EXE, $MAMBA_EXE, $CONDA_PREFIX and ~/anaconda3, ~/miniconda3, ~/mambaforge, ~/miniforge3, ~/.conda. Environments created together by envs/install_envs.sh are therefore found without any setting.