Skip to content

Methods

List the methods and see what each one needs. These calls run nothing.

list_methods

list_methods(gpu_only=False)

Return the names of the methods.

PARAMETER DESCRIPTION
gpu_only

True = only the methods that can run on a GPU.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
list of str

Method names, R methods first.

Examples:

>>> kdb.list_methods()
['PRECAST', 'SC.MEB', 'BayesSpace', 'BNPSpace', 'DR.SC', 'iSC.MEB',
 'CellCharter', 'DeepST', 'SpaGCN', 'SpatialDE2']
>>> kdb.list_methods(gpu_only=True)
['CellCharter', 'DeepST', 'SpatialDE2']

get_method

get_method(name)

Return one method's settings.

PARAMETER DESCRIPTION
name

Method name, case-insensitive. Aliases such as "drsc", "iscmeb" or "spatialde" work too.

TYPE: str

RETURNS DESCRIPTION
Method

Its language, environment, GPU support, use of kmax and reference.

RAISES DESCRIPTION
ValueError

Unknown method name.

Examples:

>>> m = kdb.get_method("cellcharter")
>>> m.name, m.language, m.env, m.gpu, m.uses_kmax
('CellCharter', 'Python', 'py', True, True)

Method dataclass

One method: its script, its environment and how it is called.

Get one with get_method. You do not create them yourself.

ATTRIBUTE DESCRIPTION
name

Canonical name, e.g. "CellCharter".

TYPE: str

language

"R" or "Python".

TYPE: str

env

Environment key: "r" (your R), "py" (kdb_py) or "spatialde" (kdb_spatialde).

TYPE: str

script

The method's script in kdomainbench/methods/.

TYPE: str

argv

(h5ad, run_folder, kmax) -> list[str], the script's arguments.

TYPE: callable

gpu

True if device="gpu" really runs the method on a GPU.

TYPE: bool

uses_kmax

False if the method chooses k by itself and ignores kmax.

TYPE: bool

big_stack

True if the method needs ulimit -s unlimited.

TYPE: bool

kmax_limit

Largest kmax the method accepts, if it has a limit.

TYPE: int or None

reference

The method's documentation or repository.

TYPE: str

aliases

Other accepted names, e.g. ("drsc",).

TYPE: tuple of str

Examples:

>>> m = kdb.get_method("BNPSpace")
>>> m.language, m.env, m.gpu, m.kmax_limit
('R', 'r', False, 30)

All methods

kdb.METHODS is a dict from each method's name to its Method record, in the order of kdb.list_methods().

[m.name for m in kdb.METHODS.values() if m.language == "R"]
# ['PRECAST', 'SC.MEB', 'BayesSpace', 'BNPSpace', 'DR.SC', 'iSC.MEB']