Run¶
Run methods, each in the environment it needs. Needs the environments from Installation.
run
¶
Run one method on one .h5ad file and return its spatial domains.
The method runs in the environment it needs, as a separate process, and writes to its run
folder <out_root>/<method>/<dataset>_<device>. A run into a folder that already holds
a run replaces it.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
Method name, case-insensitive, from list_methods.
TYPE:
|
h5ad
|
Input
TYPE:
|
kmax
|
Largest number of domains the method may consider, at least 2. DeepST and SpaGCN ignore it. BNPSpace starts from it and accepts at most 30.
TYPE:
|
device
|
TYPE:
|
out_root
|
Folder that collects the run folders, the same as for run_all.
TYPE:
|
gpu_id
|
GPU to use with
TYPE:
|
verbose
|
Print the method's output while it runs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
One row per spot, indexed by |
| RAISES | DESCRIPTION |
|---|---|
MethodFailed
|
The method stopped with an error or wrote no labels. |
FileNotFoundError
|
|
TypeError
|
|
ValueError
|
Unknown method or device, an input file that is not |
| WARNS | DESCRIPTION |
|---|---|
UserWarning
|
|
Notes
The run folder holds:
cluster_results.csv: the label of each spot.run.log: everything the method printed.packages.txt: the packages and versions of the method's environment.-
run_info.json, with these fields:method,dataset(the file name without.h5ad),h5ad(the input path),kmax.device_requested, anddevice_used, which is"cpu"for a method without GPU code.gpu_id: the GPU of a GPU run.started,wall_time_s(the whole run, data loading included) andpeak_rss_mb(peak memory of the method's largest process, 1 GB = 1024 MB, without its worker processes and the GPU).returncodeandsuccess. A successful run addsn_spots(spots with a label) andk_estimated.kdomainbench(the package version),command(the call of the method script, started in the run folder, to rerun it by hand) andenv(the environment variables that change what the method does).
Examples:
run_all
¶
run_all(h5ad, kmax=30, device='cpu', methods=None, out_root='kdb_results', gpu_id=None, verbose=True)
Run several methods on one .h5ad file, one after another.
A method that fails, or whose environment is missing, is reported and skipped, so it does not stop the others. At the end one warning names every method that did not finish.
| PARAMETER | DESCRIPTION |
|---|---|
h5ad
|
Input file, see run.
TYPE:
|
kmax
|
Largest number of domains the methods may consider. BNPSpace accepts at most 30: for a
larger
TYPE:
|
device
|
TYPE:
|
methods
|
Methods to run. Default: all ten. Each one runs again, also when
TYPE:
|
out_root
|
Each method writes to
TYPE:
|
gpu_id
|
GPU for
TYPE:
|
verbose
|
Print the methods' output while they run.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Method name -> its clusters, for the methods that succeeded. |
| RAISES | DESCRIPTION |
|---|---|
FileNotFoundError
|
|
TypeError
|
|
ValueError
|
An unknown method or device, an input file that is not |
| WARNS | DESCRIPTION |
|---|---|
UserWarning
|
Some methods did not finish. The warning names them and their logs. |
Examples:
MethodFailed
¶
Bases: RuntimeError
A method exited with an error or wrote no labels to cluster_results.csv.
The message names the run's run.log and ends with its last 20 lines. log is the path
of that run.log.