Metadata-Version: 2.4
Name: kdomainbench
Version: 0.1.0
Summary: Benchmark of spatial-domain number (k) estimation methods with one interface
License-Expression: GPL-3.0-only AND MIT
Project-URL: Documentation, https://pyanglab.github.io/domainNumber/
Project-URL: Source, https://github.com/PYangLab/domainNumber
Project-URL: Issues, https://github.com/PYangLab/domainNumber/issues
Project-URL: Changelog, https://github.com/PYangLab/domainNumber/blob/main/CHANGELOG.md
Keywords: spatial transcriptomics,spatial domains,clustering,number of clusters,benchmark,Visium
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: src/kdomainbench/methods/bnpspace_R/LICENSE
Requires-Dist: numpy>=1.23
Requires-Dist: pandas>=1.5
Requires-Dist: matplotlib>=3.6
Requires-Dist: scikit-learn>=1.2
Requires-Dist: anndata>=0.9
Dynamic: license-file

# kDomainBench

Benchmark of methods that estimate the **number of spatial domains (k)** in spatial
transcriptomics, behind one interface.

**Documentation and tutorials: <https://pyanglab.github.io/domainNumber/>**

Many spatial clustering methods choose the number of domains themselves, but each needs its
own software, input format and settings, which makes them hard to run and to compare.
kDomainBench runs ten such methods from one Python call or one command, each in the
environment it needs, and compares the k each one estimates with the number of domains in a
manual reference annotation. It is for researchers who want to estimate k for their own 10x
Visium samples, or to compare k-estimation methods. It does not add a method of its own.

```python
import kdomainbench as kdb
clusters = kdb.run("SpaGCN", "data/D3_151509_5k.h5ad")
kdb.evaluate(clusters, "data/D3_151509_5k.h5ad")       # k error, ARI and NMI against the annotation
```

* 10 methods: PRECAST, SC.MEB, BayesSpace, BNPSpace, DR.SC and iSC.MEB in R, and CellCharter,
  DeepST, SpaGCN and SpatialDE2 in Python. CellCharter, DeepST and SpatialDE2 can use a GPU.
* 2 version-locked conda environments for the Python methods, the same on CPU-only and
  GPU machines. The R methods use your own R.
* Results: `kdb.load_results`, `kdb.evaluate`, `kdb.k_accuracy`. Plots: `kdb.pl`.
* `kdb.metrics`: the twelve metrics of the paper, computed by the paper's own R and Python code
  (R ≥ 4.5 with Bioconductor ≥ 3.22).
* The `kdomainbench` command does the same from the shell.

## Installation

The methods run on Linux (x86-64) and need conda or mamba, R ≥ 4.4, a C++ compiler, `cmake`
and `git`:

```bash
git clone https://github.com/PYangLab/domainNumber.git && cd domainNumber
bash envs/install_envs.sh                 # the two Python environments, with kdomainbench in kdb_py
conda activate kdb_py
kdomainbench install r                    # the R packages, into your R
kdomainbench check                        # checks that every environment starts
```

To score and plot finished runs on macOS or Windows, `pip install -e .` in the cloned folder,
with Python 3.10 or later, is enough. [Installation](https://pyanglab.github.io/domainNumber/installation.html) has the details.

## Layout

```
src/kdomainbench/                 package (run, results, plotting, CLI)
src/kdomainbench/methods/         one script per method (device is a flag, no CPU/GPU copies)
src/kdomainbench/metric_scripts/  the paper's metric code (metrics.R, scs.py), unchanged
src/kdomainbench/envs/            the two environment files and the R package installer
envs/                             install_envs.sh and the scripts that export the environment files
docs/, mkdocs.yml, snippets/      documentation site (mkdocs-material)
scripts/                          make_results_page.py, make_logo.py, check_docs.py
tests/                            unit tests and their small test files
```
