Skip to main content

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

PyPI version Python versions License

RefCM: Reference Cluster-Mapping

RefCM is an automated tool for cell type annotation across single-cell RNA-seq datasets. It leverages optimal transport to align cell-type clusters across tissues, sequencing technologies, and species.

This repository supports reproducing the results from our paper and helps others apply RefCM to their own datasets.

overview

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

RefCM is available on PyPI. You can install it using pip:

pip install refcm

If you want to build from source, you can use uv:

uv pip install -e ".[dev]"

Note: RefCM depends on the GLPK solver.

  • On macOS, install via Homebrew with brew install glpk.
  • On Windows, follow this guide.

After installation, restart your IDE or terminal to ensure the solver is recognized.

To download the datasets used in our study, please visit our Google Drive folder, along with the accompanying data setup notebook, which includes source links and 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 5 minutes, 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 done as follows. 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 the vignettes folder.

We recommend starting with brain.ipynb, which applies RefCM to the Allen Brain Atlas.

Citation & Contact

If you use RefCM in your work, please consider citing our paper (link coming soon).
Feel free to open an issue or pull request — contributions and feedback are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

refcm-0.1.1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

refcm-0.1.1-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file refcm-0.1.1.tar.gz.

File metadata

  • Download URL: refcm-0.1.1.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for refcm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6b07134027dc34ff31626f972ef9926e32f3a31bc58ccdab2576697b18fa632c
MD5 40220cb0213585ee4a31fe82398c5c26
BLAKE2b-256 0c741e50ce84212d585888d7a49abf4461264dd4f25073939e3ab6881e7bff23

See more details on using hashes here.

File details

Details for the file refcm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: refcm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for refcm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a39c86ebaec21cec19c9fcbdc8bd2013856f30e885f99909d7a01151cf5ccb41
MD5 d594aec245bdf1019b00916cdc21b6cb
BLAKE2b-256 90ce31a174aa1018a4a1ab4ef8e343e9d654775da386e0ede8e3713b7105dc22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page