Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

scibex

PyPI version Documentation Status License: MIT

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 to obsm
  • 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.

Metadata

Release files for scibex 0.1.0b6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scibex 0.1.0b6
File Size Uploaded
scibex-0.1.0b6.tar.gz 60.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scibex 0.1.0b6
File Interpreter ABI Platform
scibex-0.1.0b6-py3-none-any.whl Python 3 none any Details

Total release size: 101.1 kB

Release files / scibex-0.1.0b6.tar.gz

Download URL scibex-0.1.0b6.tar.gz
Size 60.7 kB
Tags Source
SHA-256 checksum
How to use checksums
966ef140fcb7e95ae48cbf3768db36d6acd609512b379062f6029270294059e4
BLAKE2b-256 checksum
How to use checksums
2219b8020aaa4326ce4af153f66cfa71954bac5b5e6399bca82fe507ee5e6440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / scibex-0.1.0b6-py3-none-any.whl

Download URL scibex-0.1.0b6-py3-none-any.whl
Size 40.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1847ed5d1f52753634edc2fd461b612d9b4d016d60e7081f640905a2970908b
BLAKE2b-256 checksum
How to use checksums
3a434d0d3246f7a955dad1bf040c3db6c61fd4ce9b1871c646375e88298d70cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page