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

Python Versions License

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.

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

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


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.0.tar.gz (20.1 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.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

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

Hashes for refcm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22e5c692b4bcc33e79033296db88966ae294c41c6a6c7d4acc3a853f978f727f
MD5 3f88a03d108e6b5e065303b1cb4beeac
BLAKE2b-256 98f947baca8f30facbe49622894b63e222b97817343f82a16444842df1c48e3f

See more details on using hashes here.

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

Hashes for refcm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1bc6ce9ea392687ed8e5047d57ad433762f1d7dff0ccaa328af3ff6eb005e44
MD5 b2d04a95fcdc36b4d6e9505cf9b2a029
BLAKE2b-256 6aa9dcfd2bcd083e1bca111f22de0ac053bd584bc85de8859e1b7919d4b21858

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