scDenorm
scDenorm is an algorithm that reverts normalised single-cell omics data to raw counts, preserving the integrity of the original measurements and ensuring consistent data processing during integration.
Install
pip install scDenorm
#or
conda install -c changebio scdenorm
Dependency
numpy
pandas
matplotlib
scanpy
anndata
scipy
tqdm
pathlib
fastcore
colorlog
How to use
Using pbmc3k as an example dataset
import scanpy as sc
from scipy.io import mmwrite
from scDenorm.denorm import *
DEBUG:my_logger:This is a debug message
INFO:my_logger:This is an info message
WARNING:my_logger:This is a warning message
ERROR:my_logger:This is an error message
CRITICAL:my_logger:This is a critical message
ad=sc.datasets.pbmc3k()
ad.layers['count']=ad.X.copy()
ad
AnnData object with n_obs × n_vars = 2700 × 32738
var: 'gene_ids'
layers: 'count'
sc.pp.normalize_total(ad, target_sum=1e4)
sc.pp.log1p(ad)
smtx = ad.X.tocsr().asfptype()
smtx.data
array([1.6352079, 1.6352079, 2.2258174, ..., 1.7980369, 1.7980369,
2.779648 ], dtype=float32)
ad.write_h5ad('data/pbmc3k_norm.h5ad')
write out as sparse matrix
mmwrite('data/scaled.mtx', smtx[1:10,])
In jupyter
Input Anndata
scdenorm('data/pbmc3k_norm.h5ad',fout='data/pbmc3k_denorm.h5ad',verbose=1)
INFO:my_logger:Reading input file: data/pbmc3k_norm.h5ad
/home/huang_yin/anaconda3/envs/sc/lib/python3.9/site-packages/anndata/__init__.py:51: FutureWarning: `anndata.read` is deprecated, use `anndata.read_h5ad` instead. `ad.read` will be removed in mid 2024.
warnings.warn(
INFO:my_logger:The dimensions of this data are (2700, 32738).
INFO:my_logger:Selecting base
INFO:my_logger:Denormlizing ...the base is 2.718281828459045
b is 2.718281828459045
100%|██████████| 2700/2700 [00:02<00:00, 1071.27it/s]
INFO:my_logger:Writing output file: data/pbmc3k_denorm.h5ad
return a new anndata if there is no output path.
new_ad=scdenorm('data/pbmc3k_norm.h5ad')
new_ad
View of AnnData object with n_obs × n_vars = 2700 × 32738
var: 'gene_ids'
uns: 'log1p'
ad.layers['count'].data
array([1., 1., 2., ..., 1., 1., 3.], dtype=float32)
new_ad.X.data
array([1. , 1. , 2.0000002, ..., 1. , 1. ,
3. ], dtype=float32)
Input sparse matrix with cell by gene
If it is gene by cell, set gxc=True.
scdenorm('data/scaled.mtx',fout='data/scd_scaled.h5ad')
100%|██████████| 9/9 [00:00<00:00, 2883.12it/s]
In command line
Input Anndata
!scdenorm data/pbmc3k_norm.h5ad --fout data/pbmc3k_denorm.h5ad
/home/huang_yin/anaconda3/envs/sc/lib/python3.9/site-packages/anndata/__init__.py:51: FutureWarning: `anndata.read` is deprecated, use `anndata.read_h5ad` instead. `ad.read` will be removed in mid 2024.
warnings.warn(
b is 2.718281828459045
100%|█████████████████████████████████████| 2700/2700 [00:02<00:00, 1090.85it/s]
Input sparse matrix with cell by gene
!scdenorm data/scaled.mtx --fout data/scd_scaled_c.h5ad
100%|███████████████████████████████████████████| 9/9 [00:00<00:00, 1333.31it/s]
or output mtx format.
!scdenorm data/scaled.mtx --fout data/scd_scaled_c.mtx
100%|███████████████████████████████████████████| 9/9 [00:00<00:00, 1290.78it/s]
Citation
Yin Huang, Anna Vathrakokili Pournara, Ying Ao, Lirong Yang, Hui Zhang, Yongjian Zhang, Sheng Liu, Alvis Brazma, Irene Papatheodorou, Xinlu Yang, Ming Shi, Zhichao Miao “scDenorm: a denormalisation tool for integrating single-cell transcriptomics data”(Under review)
Metadata
Release files for scDenorm 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scDenorm-1.0.1.tar.gz | 13.0 kB | Without provenance | Details for scDenorm-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scDenorm-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for scDenorm-1.0.1-py3-none-any.whl |
Total release size: 25.3 kB
Release files / scDenorm-1.0.1.tar.gz
| Download URL | scDenorm-1.0.1.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7dc6e8e491df7342c9a057697a59d8023e111b2a2c0b6e71891be6c3f42d4d15
|
|
BLAKE2b-256 checksum How to use checksums |
61e59c191f39716a6f210486a9eea0ae8d456edac4b9c9837ca73c0175e56145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Release files / scDenorm-1.0.1-py3-none-any.whl
| Download URL | scDenorm-1.0.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a855cead765bcfd6291c3df3cfcc9cd40bcea9a6987b3622b038f723764c33d5
|
|
BLAKE2b-256 checksum How to use checksums |
101da79dd41aa72ccdcff5995ad7ef52c5ce3d92f818d3535359c3c81fb97ecb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Security for scDenorm 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.