scValue: value-based subsampling of large-scale single-cell transcriptomic data
Project description
scValue
Desciption
scValue is a Python package designed for efficient value-based subsampling of large scRNA-seq datasets. It prioritises cells of higher value (indicative of greater utility for cell type identification) over cells of lower value and allocates more representation to cell types with greater value variability in the resulting subsamples, which support effective downstream machine/deep learning tasks.
The package has been implemented using Python 3.10, scikit-learn 1.5.2, SciPy 1.14.0, NumPy 1.26.4, pandas 1.5.3, and joblib 1.4.2. Experiments in the paper were conducted using Scanpy 1.10.2 and AnnData 0.10.8.
Installation
The package can be installed using pip:
pip install scvalue
Quick start
Load necessary modules
import pandas as pd
import numpy as np
import scanpy as sc
from scvalue import SCValue
Read and preprocess input scRNA-seq data
The example dataset of 89,429 mouse T cells (mTC) can be downloaded from https://datasets.cellxgene.cziscience.com/6c253303-8255-4004-8464-5e90dd5846cb.h5ad in the h5ad format. It has already been log-normalised. Here, we perform principal component analysis (PCA) on the top 3,000 highly variable genes (HVGs), as scValue accepts principal components (PCs) as the default features (n_comps=50).
adata = sc.read_h5ad('mTC.h5ad')
sc.pp.highly_variable_genes(adata, n_top_genes=3000)
sc.pp.pca(adata, n_comps=50, use_highly_variable=True)
Subsample by scValue
Subsample 10% cells of mTC and return a new AnnData containing the subsample. Alternatively, sketch_size can be specified as an integer, representing the exact number of cells to be subsampled. Users can also specify:
- the type of features
use_rep(default "X_pca") cell_type_key(default "cell_type") in the original anndata- the number of trees,
n_trees, in the random forest (default 100) - the subsampling
strategy, one of the three options, listed in an increasing order of cell type separation:- full binning, "FB" (default)
- mean-threshold binning, "MTB"
- top-pick, "TP"
Instead of value-weighted subsampling, proportional subsampling, prop_sampling, can be carried out if the original cell types are highly balanced or if users wish to maintain the original cell type proportions. In addition, the data value of individual cells can be saved to disk for future reference by setting write_dv=True. Lastly, a random seed (default 42) can be specified for random forest fitting.
# create an instance of the SCValue class
scv = SCValue(adata=adata,
sketch_size=0.1,
use_rep="X_pca",
cell_type_key="cell_type",
n_trees=100,
strategy="FB",
prop_sampling=False,
write_dv=False,
seed=42)
scv.value() # perform value computation and value-based subsampling
adata_sub = scv.adata_sub
adata_sub can be plotted using plot_umap in reproducibility/eval_time_hd_gini.py to reproduce the demo (Section 3.1) in the paper. All datasets used in the paper are publicly available, as detailed in Supplementary Section S1.
Reference
Li Huang & Dongsheng Chen, scValue: value-based subsampling of large-scale single-cell transcriptomic data. 2024.
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 scvalue-0.0.1.tar.gz.
File metadata
- Download URL: scvalue-0.0.1.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c670aea70d31e94dedf43aebf16e0c614cef9ca7241ab76524cd5b670a7b457
|
|
| MD5 |
30746341c7945c9c26c7e4abe36c1f4b
|
|
| BLAKE2b-256 |
5508856b7a90a8a1b4d00418a4cd6b0b847d615cd7469489eea8662a8effbe59
|
File details
Details for the file scvalue-0.0.1-py3-none-any.whl.
File metadata
- Download URL: scvalue-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba8fd134f060cf2c795830d1e12a036126e2f86b90a1c96f0269c52165a27a32
|
|
| MD5 |
a49be86219f0ecd9445215a0a9f8e85c
|
|
| BLAKE2b-256 |
836809e18f096af6d322e4dc8fc943c8c84051f1924f3964b6d272b3d72bab6c
|