High-performance ALRA-style imputation for sparse single-cell matrices
Project description
HALRA
HALRA (High-performance ALRA) is a Python implementation of the ALRA algorithm for imputing missing values in single-cell RNA-seq data [1]. It is designed to operate efficiently on sparse matrices and scale to large datasets by preserving sparsity throughout the pipeline wherever possible.
HALRA performs:
- Low-rank matrix reconstruction via randomized SVD
- Gene-wise thresholding of reconstructed values
- Per-gene rescaling to match observed statistics
- Restoration of observed (nonzero) values
The goal is to denoise and impute dropout values while preserving biological signal.
Expected Input
HALRA supports two input types:
1. AnnData
.Xshould contain a dense NumPy array or a SciPy sparse matrix (CSR/CSC).obs_namesand.var_namesare used as cell and gene labels
2. Raw matrix + labels
matrix: NumPy ndarray or SciPy sparse matrix (cell x gene)cells: list/array of cell names (length = n_rows)genes: list/array of gene names (length = n_cols)
HALRA requires log-normalized count data, so either log normalize your data first or pass normalize=True to the halra function when imputing.
Installation
HALRA can be installed as a local pip package. First install Python v3.10. Example:
conda create -n halra_env python=3.10
conda activate halra_env
Then, git clone this repo and install HALRA locally:
pip install -e .
Usage Example (AnnData)
import anndata as ad
from halra import halra
# Load your AnnData object
adata = ad.read_h5ad("anndata.h5ad")
# Run HALRA (this assumes .X is not already normalized)
adata_imputed = halra(adata, normalize=True)
# Result:
# adata_imputed.X now contains imputed values
# All metadata (.obs, .var, etc.) is preserved (filtered if needed)
Usage Example (10x)
import os
import pandas as pd
from scipy.io import mmread
from halra import halra
# Load 10x files
mtx_dir = "/path/to/dir"
matrix = mmread(os.path.join(mtx_dir, "matrix.mtx")).T
features = pd.read_csv(os.path.join(mtx_dir, "features.tsv"), sep="\t", header=None, usecols=[0])
barcodes = pd.read_csv(os.path.join(mtx_dir, "barcodes.tsv"), sep="\t", header=None)
# Run HALRA
imputed_matrix, cells, genes = halra(matrix, barcodes, features, normalize=True)
# Result:
# imputed_matrix contains imputed values
# cells and genes contain the filtered cell/gene labels
Dependency Notes
HALRA depends on:
- numpy
- scipy
- scikit-learn (for randomized SVD)
- anndata (>=0.10)
Current Limitations and Experimental Features
- Reconstruction step is dense (SVD-based), which may limit scalability for extremely large datasets (>1M cells)
- Distributed and HPC-oriented implementations of HALRA are under active development
and can be found in the
experimental/directory. These are not yet part of the stable package API.
References
[1] Linderman, G. C. et al. Zero-preserving imputation of single-cell RNA-seq data. Nat Commun 13, (2022).
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 halra-0.1.0.tar.gz.
File metadata
- Download URL: halra-0.1.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9726bf30b88671bd42d85d6d44299b61f2305904596d028df6273df4a6d6f52c
|
|
| MD5 |
6984ee5b6784aed921554d86e0ab8636
|
|
| BLAKE2b-256 |
8f680838350bf61c016b6811160f1982f3a8888859a719e35d160984294906d5
|
File details
Details for the file halra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: halra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c03aac16949cbac8e7ac9906110a5a1a6a05458ca8d29cc0daf624cae45d385
|
|
| MD5 |
4f394cc838bac10ef3a93a20cbfe787d
|
|
| BLAKE2b-256 |
21a7b1af165d700fde55c3fb534a224b90888a62a9773ffcfe6db72e630effa0
|