Metadata-Version: 2.4
Name: scbix
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Dist: anndata>=0.10
Requires-Dist: beartype>=0.19
Requires-Dist: numpy>=1.23
Requires-Dist: pandas>=1.5
Requires-Dist: scipy>=1.8
Requires-Dist: scbix[manifolds,nebula,bonsai] ; extra == 'all'
Requires-Dist: bonsai-rs[anndata]>=0.4.0 ; extra == 'bonsai'
Requires-Dist: manifolds-rs[anndata]>=0.7.3 ; extra == 'manifolds'
Requires-Dist: edge-rs[anndata]>=0.2.0 ; python_full_version >= '3.11' and extra == 'nebula'
Provides-Extra: all
Provides-Extra: bonsai
Provides-Extra: manifolds
Provides-Extra: nebula
License-File: LICENSE
Summary: Rust implementations of single cell methods for AnnData: UMAP and t-SNE via manifolds-rs, NEBULA via edge-rs, Sanity and Bonsai via bonsai-rs, and scDblFinder and SEACells via Bixverse.
Author-email: Gregor Lueg <gregorlueg@me.com>, Thomas Sirchi <thomasirchi@gmail.com>
License: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://gregorlueg.github.io/scbix/
Project-URL: Repository, https://github.com/GregorLueg/scbix

# scbix

scbix brings Rust implementations of single cell methods to AnnData, in memory
and scanpy style: doublet detection via scDblFinder, SEACells metacells, UMAP
and t-SNE from [manifolds-rs](https://github.com/GregorLueg/manifolds-rs),
NEBULA from [edge-rs](https://github.com/GregorLueg/edge-rs) and Sanity/Bonsai
from [bonsai-rs](https://github.com/GregorLueg/bonsai-rs), with optional GPU
acceleration via wgpu.

scbix works on data that fits in memory. For atlas-scale data,
[bixverse](https://github.com/GregorLueg/bixverse-rs) runs the same Rust core
out of core from an on-disk store, reads h5ad and Zarr directly and writes
results back to h5ad.

## Install

```bash
uv add scbix
uv add 'scbix[all]'  # include UMAP, t-SNE, NEBULA and Sanity/Bonsai
```

The base install includes NumPy, SciPy, AnnData, and `tl.scdblfinder` and `tl.seacells`.
The extras pull in the sibling wheels:

| extra | adds | from |
|---|---|---|
| `manifolds` | `tl.umap`, `tl.tsne` | manifolds-rs |
| `nebula` | `tl.nebula` | edge-rs, Python 3.11 or later |
| `bonsai` | `tl.sanity`, `tl.bonsai` | bonsai-rs |

Accessing a function without its extra raises an `ImportError` naming the extra.
On Python 3.10 the `nebula` extra installs nothing, since edge-rs needs 3.11.

## Usage

Same slots as scanpy, so `sc.pl.umap` and friends work unchanged:

```python
import scanpy as sc
import scbix as sb

adata = sc.datasets.pbmc3k_processed()
sb.tl.umap(adata)  # on the sc.pp.neighbors graph
sb.tl.tsne(adata, approx="fft")
sc.pl.umap(adata, color="louvain")
```

`device="gpu"` switches to the GPU estimators where the wheel was built with
them. Everything else the manifolds-rs estimators take goes through as keyword
arguments.

`scbix.tl.scdblfinder` accepts CSR and CSC raw counts and can score captures
independently via `group_by`. Pass a `ScdblfinderParams` object through
`scdblfinder_params` to configure the algorithm. See the [API documentation](docs/api/tl.md).

Fit CPU SEACells on an AnnData embedding:

```python
import scbix as sb

sb.tl.seacells(adata, seacells_params=sb.tl.SeacellsParams(n_sea_cells=500))
```

Assignments are stored in `adata.obs["seacells"]` and fit diagnostics in
`adata.uns["seacells"]`. See the [tools documentation](docs/api/tl.md).

NEBULA, Sanity and Bonsai are the sibling wheels' own AnnData functions. They
read raw counts from `adata.layers["counts"]`, leave `adata` alone and return a
result object:

```python
fit = sb.tl.nebula(adata, "donor", "~ condition", genes=hvgs)
res = fit.test(coef="condition[T.treated]")  # pandas frame, one row per gene

tree = sb.tl.bonsai(adata, layer="counts")
tree.to_newick()  # leaves labelled by obs_names
```

## Docs

[gregorlueg.github.io/scbix](https://gregorlueg.github.io/scbix/), with the API
reference and vignettes.

## Licence

MIT.

