Python interface to the Ibex BCR embedding R package for scverse single-cell analysis
Project description
scibex
scibex brings Ibex BCR embeddings into the scverse ecosystem. It wraps the R Ibex package via rpy2 and stores results directly in AnnData.obsm, making it a drop-in complement to scirpy for B-cell receptor analysis.
Ibex encodes CDR3 (or CDR1+2+3) amino acid sequences from paired heavy and light chains using convolutional/variational autoencoders or a fast geometric transform. The resulting low-dimensional embeddings can be combined with gene expression data for multimodal single-cell analysis.
Features
- scirpy-native: reads chain sequences from
obsm["chain_indices"]; writes embeddings back toobsm - Heavy and light chains: embed each independently then combine downstream
- Multiple models: geometric baseline, CNN autoencoder, VAE, and expanded CDR1+2+3 variants
- Multiple encodings: Atchley factors, Kidera factors, Cruciani properties, MSWHIM, tScales, one-hot
- No manual sequence handling:
scibex.tl.ibex(mdata, ...)does the full extract → embed → store pipeline
Installation
pip install scibex
scibex wraps the Ibex R package via rpy2. Install the R dependency from Python:
import scibex as ib
ib.install_r_deps() # into R's default library
ib.install_r_deps(lib_loc="/path/to/my/Rlib") # into a specific directory
ib.install_r_deps(force=True) # force-reinstall everything
Or directly in R:
remotes::install_github("BorchLab/Ibex@devel")
If Ibex is in a non-default R library, call ib.setup(lib_loc=...) once
before any embedding call:
ib.setup(lib_loc="/path/to/my/Rlib")
See the Installation docs for R environment
troubleshooting (conda ABI mismatches, .Rprofile interference, keras setup).
Quick start
import scirpy as ir
import scibex as ib
# Load a scirpy MuData (chain_indices must already be populated)
mdata = ir.datasets.stephenson2021_5k()
# Embed heavy-chain CDR3 sequences → stored in mdata["airr"].obsm["X_ibex_heavy"]
ib.tl.ibex(mdata, chain="Heavy", key_added="X_ibex_heavy")
# Embed light-chain CDR3 sequences → stored in mdata["airr"].obsm["X_ibex_light"]
ib.tl.ibex(mdata, chain="Light", key_added="X_ibex_light")
Switch encoder_input or encoder_model for different representations:
ib.tl.ibex(
mdata,
chain="Heavy",
method="encoder",
encoder_model="VAE",
encoder_input="kideraFactors",
key_added="X_ibex_heavy",
)
If you only have a list of sequences (e.g. from a custom pipeline), use the low-level function directly:
embedding = ib.ibex_matrix(
["CARDLVSYGMDVW", "CAKGGQIFHFSSGFYFDFW"],
chain="Heavy",
method="encoder",
) # returns np.ndarray of shape [N, D]
Tutorial
A complete end-to-end tutorial on the Stephenson 2021 COVID-19 dataset (5k BCR cells) is available in
the Tutorials section (docs/notebooks/tutorial_5k_bcr.ipynb).
It covers:
- Loading a scirpy
MuData - Embedding heavy and light chains with
scibex.tl.ibex - Visualising the embedding space as a UMAP
- Training a logistic-regression classifier to predict patient outcome from paired BCR embeddings
API overview
| Function | Description |
|---|---|
scibex.tl.ibex(adata, ...) |
Embed BCR sequences in a scirpy AnnData/MuData; stores result in obsm |
scibex.ibex_matrix(seqs, ...) |
Low-level: embed a list of CDR3 strings, returns [N, D] numpy array |
Key parameters for tl.ibex:
| Parameter | Options | Default |
|---|---|---|
chain |
"Heavy", "Light" |
"Heavy" |
method |
"encoder", "geometric" |
"encoder" |
encoder_model |
"CNN", "VAE", "CNN.EXP", "VAE.EXP" |
"VAE" |
encoder_input |
"atchleyFactors", "kideraFactors", "crucianiProperties", "MSWHIM", "tScales", "OHE" |
"atchleyFactors" |
species |
"Human", "Mouse" |
"Human" |
key_added |
any string | "X_ibex" |
Acknowledgements
scibex is a Python interface to the Ibex R package. If you use scibex in your work, please cite the original Ibex publication.
- PyPI: https://pypi.org/project/scibex/
- Documentation: https://scibex.readthedocs.io
- License: MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scibex-0.1.0b5.tar.gz.
File metadata
- Download URL: scibex-0.1.0b5.tar.gz
- Upload date:
- Size: 30.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07e051855690b83ae15533733399a3f21b49d3699eb755dad3f67286f6cc8dd2
|
|
| MD5 |
8f015b954f6415d2f897d1c7893af4b9
|
|
| BLAKE2b-256 |
47020c7b5a2a7a0f3fd4ff928ac8e8f78284ba24d66b4800b523b11ddd222809
|
Provenance
The following attestation bundles were made for scibex-0.1.0b5.tar.gz:
Publisher:
publish.yml on Qile0317/scibex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scibex-0.1.0b5.tar.gz -
Subject digest:
07e051855690b83ae15533733399a3f21b49d3699eb755dad3f67286f6cc8dd2 - Sigstore transparency entry: 1935284301
- Sigstore integration time:
-
Permalink:
Qile0317/scibex@1bd508ff4482e67c4116792f0559bed29cd74741 -
Branch / Tag:
refs/tags/v0.1.0b5 - Owner: https://github.com/Qile0317
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1bd508ff4482e67c4116792f0559bed29cd74741 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scibex-0.1.0b5-py3-none-any.whl.
File metadata
- Download URL: scibex-0.1.0b5-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad8746b2b83d80bdb0be3a389fdca2cf77408e4a7d7fb9f3754bed91519aef4d
|
|
| MD5 |
f6371d11400746be87b8730fd612cf21
|
|
| BLAKE2b-256 |
6ef995a1755e1f1b5fc46d167f39e5c6e47605cd152233a585e0ee10217f2063
|
Provenance
The following attestation bundles were made for scibex-0.1.0b5-py3-none-any.whl:
Publisher:
publish.yml on Qile0317/scibex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scibex-0.1.0b5-py3-none-any.whl -
Subject digest:
ad8746b2b83d80bdb0be3a389fdca2cf77408e4a7d7fb9f3754bed91519aef4d - Sigstore transparency entry: 1935284327
- Sigstore integration time:
-
Permalink:
Qile0317/scibex@1bd508ff4482e67c4116792f0559bed29cd74741 -
Branch / Tag:
refs/tags/v0.1.0b5 - Owner: https://github.com/Qile0317
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1bd508ff4482e67c4116792f0559bed29cd74741 -
Trigger Event:
push
-
Statement type: