Metadata-Version: 2.4
Name: refcm
Version: 1.0.0
Summary: RefCM is a computational method that combines optimal transport and integer programming to enhance the annotation of scRNA clusters using established reference datasets.
Author-email: Valerio Galanti <vg2551@columbia.edu>, Lingting Shi <ls3456@columbia.edu>, Elham Azizi <ea2690@columbia.edu>, Yining Liu <yl4536@columbia.edu>, "Andrew J. Blumberg" <ab4808@columbia.edu>
License: BSD 3-Clause License
        
        Copyright (c) 2025, Valerio Galanti
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: <3.12,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pot>=0.9.5
Requires-Dist: pulp>=3.2.1
Requires-Dist: scanpy>=1.11.2
Provides-Extra: dev
Requires-Dist: ipykernel>=6.29.5; extra == "dev"
Requires-Dist: nbformat>=5.10.4; extra == "dev"
Requires-Dist: plotly>=5.0.0; extra == "dev"
Requires-Dist: rpy2==3.4.5; extra == "dev"
Requires-Dist: scalex>=1.0.4; extra == "dev"
Requires-Dist: scvi-tools>=1.3.3; extra == "dev"
Requires-Dist: torch>=2.9.0; extra == "dev"
Requires-Dist: celltypist>=1.7.1; extra == "dev"
Dynamic: license-file

[![PyPI version](https://img.shields.io/pypi/v/refcm.svg?color=blue)](https://pypi.org/project/refcm)
[![Python versions](https://img.shields.io/pypi/pyversions/refcm.svg)](https://pypi.org/project/refcm/)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)

<center> <h1>RefCM: Reference Cluster-Mapping</h1> </center>

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](https://github.com/vgalanti/RefCM/blob/main/vignettes/overview.jpeg?raw=true)


## Table of Contents
- [Table of Contents](#table-of-contents)
- [About](#about)
- [Installation](#installation)
- [Requirements](#requirements)
- [Usage](#usage)
- [Examples](#examples)
- [Citation & Contact](#citation--contact)


## About <a name="about"></a>

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 <a name="installation"></a>

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

If you want to build from source and/or run our benchmarking suite, you can use [uv](https://docs.astral.sh/uv/):
```shell
uv sync --all-extras
```

**Note**: RefCM depends on the [GLPK solver](https://www.gnu.org/software/glpk/).

- On macOS, install via Homebrew with `brew install glpk`.
- On Windows, follow [this guide](https://stackoverflow.com/questions/17513666/installing-glpk-gnu-linear-programming-kit-on-windows).

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


## Requirements <a name="requirements"></a>

The package has been tested on:

- macOS Sequoia (Apple M1 Pro, 32 GB RAM)
- Windows 11 (Intel i5 4-core CPU, 8 GB RAM)
- Ubuntu 24.04 (NVIDIA GH200, 480 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 10 minutes.


## Usage <a name="usage"></a>

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 log-normalized counts to be provided under each dataset's `.X` attribute.

```python
from refcm import RefCM

rcm = RefCM()
rcm.setref(reference, 'cluster')
rcm.annotate(query, 'cluster')
```

The resulting annotations are written out to the `.obs['refcm']` field in the query's `AnnData` object, metadata in `.uns['refcm']`, leaving the remaining fields unchanged.

## Examples <a name="examples"></a>

We’ve put together a few example Jupyter notebooks under the [vignettes](https://github.com/vgalanti/RefCM/tree/main/vignettes) folder.

We recommend starting with [brain.ipynb](https://github.com/vgalanti/RefCM/blob/main/vignettes/brain.ipynb), which applies RefCM to the Allen Brain Atlas.


## Citation & Contact <a name="citation--contact"></a>

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!
