sbmutils
A collection of SBM functions.
Installation
pip install sbmutils
Features
Preprocessing
Normalization
quantilenorm: Performs 2D quantile normalization over columns- Supports both mean and median averaging methods
- Handles missing values (NaN)
- Input validation and error handling
stacked_quantilenorm: Performs quantile normalization on stacked data with batch informationreferenced_quantilenorm: Normalizes data using reference quantilesstandardize: Standardizes data by centering and scaling
Biological Normalization
comba/combat_seqt: Batch effect correction using ComBatcounts_to_fpkm: Converts count data to FPKM
Filtering
parse_gtf: Parses GTF files for gene informationget_gene_id_to_entrez_mapper: Maps gene IDs to Entrez IDsentrez_filtering: Filters data based on Entrez IDsprotein_coding_filtering: Filters for protein-coding genes
Decomposition
NMF: Non-negative Matrix Factorization implementation
Usage
import numpy as np
import pandas as pd
from sbmutils.preprocess import quantilenorm, standardize, combat
from sbmutils.decomp import NMF
# Quantile normalization example
data = pd.DataFrame([[1, 4], [2, 5], [3, 6]])
normalized_data = quantilenorm(data, average="mean")
# Batch effect correction
counts = pd.DataFrame(...) # Your count data
batch = [1, 1, 2, 2, ...] # Batch information
corrected_data = combat(counts, batch)
# NMF decomposition
nmf = NMF(num_components=3)
nmf.fit(data)
Requirements
- Python >= 3.6
- NumPy >= 1.19.0
- SciPy >= 1.7.0
- inmoose >= 0.1.0
- pyranges >= 0.0.100
- gtfparse >= 1.2.1
- pybiomart >= 0.1.0
How to check MATLAB compatibility
- Intall MATLAB engine for python
cd "mablab_root/extern/engines/python"
python setup.py install
- Start MATLAB engine
import matlab
import matlab.engine
eng = matlab.engine.start_matlab()
- Test with MATLAB function
x_matlab = matlab.double(x_python.tolist())
result_python = function(x_python)
result_matlab = eng.function(x_matlab)
np.testing.assert_array_almost_equal(result_python, result_matlab)
License
This project is licensed under the MIT License.
import matlab
import matlab.engine
"""
test code for NMF
"""
eng = matlab.engine.start_matlab()
x = np.random.randn(1000, 200)
x.ravel()[np.random.choice(x.size, 128, replace=False)] = np.nan
w = np.random.uniform(size=[1000, 4])
h = np.random.uniform(size=[4, 400])
nmf = NMF(num_components=4, num_iter=10, nmf_iter=10)
nmf.fit(x, init_w=w, init_h=h)
coph_cor_py = nmf.correlation_coefficient
ave_C_py = nmf.consensus_matrix
x_matlab = matlab.double(x.tolist())
w_matlab = matlab.double(w.tolist())
h_matlab = matlab.double(h.tolist())
out_m = eng.aoNMF_subtyping_NaN(x_matlab, 4, 10., 10., w_matlab, h_matlab, nargout=4)
coph_cor_m = np.array(out_m[0])
ave_C_m = np.array(out_m[1])
np.testing.assert_array_almost_equal(coph_cor_py, coph_cor_m)
np.testing.assert_array_almost_equal(ave_C_py, ave_C_m)
Metadata
Release files for sbmutils 0.2.3
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 |
|---|---|---|---|---|
| sbmutils-0.2.3.tar.gz | 10.5 kB | Without provenance | Details for sbmutils-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sbmutils-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for sbmutils-0.2.3-py3-none-any.whl |
Total release size: 21.2 kB
Release files / sbmutils-0.2.3.tar.gz
| Download URL | sbmutils-0.2.3.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f27c0908bf7cf74c92e12a13a7f8d283655edac1c4e57c4f4730d05f5c7a82e6
|
|
BLAKE2b-256 checksum How to use checksums |
ec159e9a51e427b3affdb152ca404207e798a14c394b7624b771d36efae6b56d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / sbmutils-0.2.3-py3-none-any.whl
| Download URL | sbmutils-0.2.3-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
396bd2f7b053688787e97c12ca9cd26382dcca8749e8560d6486b99cb630beec
|
|
BLAKE2b-256 checksum How to use checksums |
e2e66bd13971bb588d923c87d87b343c6ad6a679d83410bbf4117e4e16589ed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for sbmutils 0.2.3
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.