RefCM is a computational method that combines optimal transport and integer programming to enhance the annotation of scRNA clusters using established reference datasets.
Project description
RefCM: Reference Cluster-Mapping
RefCM is an automated tool enabling cell-type annotation across different scRNA-seq datasets. The model bases itself on the geometric properties of optimal transport to map cell-type clusters across tissues, sequencing methods, and species.
Table of Contents
About
The primary purpose of this repository is to enable the reproduction of the results reported in the paper, and help others utilize this method towards their own work.
Installation
We recommend using uv. After installation, simply run uv sync to install the required virtual environment and compatible python version.
For conda users, we have provided a yaml file:
conda env create -n refcm -f env.yml
conda activate refcm
Additionally, users will need to install GLPK. On MacOS, this can be done via homebrew with brew install glpk. Windows users require a few more steps, described in this guide. Please restart your IDE after setup.
To download the datasets in our study, please visit our Google Drive link and accompanying data setup notebook which includes source links and data preprocessing instructions.
Requirements
The package has been tested on:
- macOS Sequoia (Apple M1 Pro, 32 GB RAM)
- Windows 11 (Intel i5 4-core CPU, 8 GB RAM)
There are no strict hardware requirements, aside from the ability to load the query and reference datasets into memory. All analyses, except for the large embryogenesis datasets, were reproducible on the 8 GB Windows system. On the M1 Pro, even the largest datasets completed in under 20 minutes.
Installation typically takes under 10 minutes (from cloning the repository to running example scripts), depending on network speed.
Usage
Running RefCM on a given query: AnnData and reference: AnnData dataset pair, assuming clustering information under their respective .obs['cluster'] attributes, can be achieved by running the following code and tweaking the remaining hyperparameters. The method expects raw counts to be provided under each dataset's .X attribute.
from refcm import RefCM
rcm = RefCM()
rcm.setref(reference, 'reference', 'cluster')
m = rcm.annotate(query, 'query', 'cluster')
The resulting annotations are written out to the .obs['refcm_annot'] field in the query's AnnData object, leaving the remaining fields unchanged.
For a graphical representation of the resulting matching/cluster-mapping:
m.display_matching_costs()
Provided a ground-truth .obs field, the matching's performance can be evaluated as follows:
m.display_matching_costs(ground_truth_obs_key='ground_truth_key')
m.eval(ground_truth_obs_key='ground_truth_key')
Examples
We’ve put together a few example Jupyter notebooks under /vignettes to help you start using RefCM right away. Our starter example, brain.ipynb, walks you through applying the method to the Allen Brain Atlas datasets.
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 refcm-0.1.0.tar.gz.
File metadata
- Download URL: refcm-0.1.0.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22e5c692b4bcc33e79033296db88966ae294c41c6a6c7d4acc3a853f978f727f
|
|
| MD5 |
3f88a03d108e6b5e065303b1cb4beeac
|
|
| BLAKE2b-256 |
98f947baca8f30facbe49622894b63e222b97817343f82a16444842df1c48e3f
|
File details
Details for the file refcm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: refcm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1bc6ce9ea392687ed8e5047d57ad433762f1d7dff0ccaa328af3ff6eb005e44
|
|
| MD5 |
b2d04a95fcdc36b4d6e9505cf9b2a029
|
|
| BLAKE2b-256 |
6aa9dcfd2bcd083e1bca111f22de0ac053bd584bc85de8859e1b7919d4b21858
|