A package for fast diversity-preserving subsampling of large-scale single-cell transcriptomic data
Project description
scSampler
Overview
scSampler is a Python pacakge for fast diversity-preserving subsampling of large-scale single-cell transcriptomic data.
Installation
Please install it from PyPI:
pip install scsampler
Quick start
First we load all modules.
import numpy as np
import pandas as pd
import scanpy as sc
from time import time
from scsampler import scsampler
sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.logging.print_header()
sc.settings.set_figure_params(dpi=80, facecolor='white')
Read in data
The example data can be downloaded from https://doi.org/10.5281/zenodo.5811787 in the anndata format by scanpy. Here we use the ~68'000 PBMC cells. Please modify the path as your own path.
adata = sc.read_h5ad('/home/dongyuan/scSampler/data/final_h5ad/pbmc68k.h5ad')
anndata as input
Subsample 10% cells and return a new anndata. The space is top PCs.
adata_sub = scsampler(adata, fraction = 0.1, copy = True)
If you want to speed it up, you can use the random_split. It will lead to slightly less optimal result, of course.
start = time()
adata_sub = scsampler(adata, fraction = 0.1, obsm = 'X_pca', copy = True, random_split = 16)
end = time()
print(end - start)
matrix as input
You can also use the numpy.ndarray as the input.
mat = adata.obsm['X_pca']
print(type(mat))
res = scsampler(mat, fraction = 0.1, copy = True, random_split = 16)
subsample_index = res[1]
subsample_mat = res[0]
Contact
Any questions or suggestions on scSampler are welcomed! If you have any questions, please report it on issues or contact Dongyuan (dongyuansong@ucla.edu).
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
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 scsampler-1.0.0.tar.gz.
File metadata
- Download URL: scsampler-1.0.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e59ed62f90d197c12cb6e49718d020f8888411e34072e5103a9106bde9f2d42
|
|
| MD5 |
058cd294c5b9e7b8808336f6c8eba017
|
|
| BLAKE2b-256 |
07c449c9dee204d4d1895a6e0400d81684c724fc54dc7c0ed6e065413d329b05
|
File details
Details for the file scsampler-1.0.0-py3-none-any.whl.
File metadata
- Download URL: scsampler-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14a50db071088489d35c66d6d19ae89b788f8d06d341bbaaf1ed393f05beb8b1
|
|
| MD5 |
c2c4ffc39a0b5bb50900643bfe6a3619
|
|
| BLAKE2b-256 |
45c442549e1c3850a2c3e671752448d80afc4df4f036c0bd2db986dcc63de33d
|