Skip to main content

BULLKpy 🧬

BULLKpy is a Python pipeline for bulk OMICs analysis, based on AnnData objects and inspired by Scanpy/scverse but adapted for bulk transcriptomics. It integrates QC, normalization, clustering, correlation and association utilities, differential expression, gene set enrichment analysis (GSEA), metaprograms, and rich visualization utilities (oncoprints, etc.).


📄 Documentation

BULLKpy documentation in Read The Docs:

https://bullkpy.readthedocs.io/en/latest/


🚀 Installation

Clone the repository:

git clone https://github.com/malumbres/BULLKpy.git
cd BULLKpy

Install from Pypi:
https://pypi.org/project/bullkpy/

pip install bullkpy

BULLKpy requires Python 3.10 or newer.

Optional extras:

pip install "bullkpy[umap]"      # bk.tl.umap / bk.pl.umap
pip install "bullkpy[leiden]"    # bk.tl.cluster(method="leiden")

🛠️ Development

git clone https://github.com/malumbres/BULLKpy.git
cd BULLKpy
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,docs,umap,leiden]"

pytest                                  # run the test suite
ruff check src/                         # lint
python -m sphinx -b html docs docs/_build/html   # build the docs

🚀 Tutorials

Use this initial Jupyter notebook for a practical presentation of BULLKpy functions:

https://bullkpy.readthedocs.io/en/latest/notebooks/BULLKpy_TCGA_example_notebook.html

More functions and field-specific tutorials to come...


📦 Project structure

bullkpy-skeleton/
├── src/                # BULLKpy Python package
│   └── bullkpy/
|       ├── io.py.      # input/output tools
│       ├── pp/         # preprocessing
│       ├── tl/         # tools (DE, clustering, GSEA, associations)
│       ├── pl/         # plotting
│       └── settings.py
│
├── notebooks/          # analysis notebooks (examples, use cases)
├── data/               # large input datasets (NOT tracked by git)
├── docs/		# Read the Docs at `https://bullkpy.readthedocs.io/en/latest/` 
├── results/            # analysis outputs (NOT tracked by git)
│
├── pyproject.toml      # package configuration
├── README.md
├── CHANGELOG.md
├── LICENSE
├── .gitignore
└── .readthedocs.yaml

🧪 Quick start

import bullkpy as bk

# ---- load -------------------------------------------------------------
adata = bk.io.read_counts("counts.tsv", sep="\t", orientation="genes_by_samples")
bk.io.add_metadata(adata, "metadata.tsv", sep="\t", index_col="sample")

# ---- QC and normalisation --------------------------------------------
bk.pp.set_raw_counts(adata)
bk.pp.qc_metrics(adata)
bk.pl.qc_metrics(adata)
bk.pp.normalize_cpm(adata)
bk.pp.log1p(adata)

# ---- dimensionality reduction and clustering -------------------------
bk.pp.highly_variable_genes(adata, n_top_genes=2000)
bk.tl.pca(adata, n_comps=30, use_highly_variable=True)
bk.pl.pca_scatter(adata, color="Subtype")
bk.tl.neighbors(adata, n_neighbors=15)
bk.tl.cluster(adata, method="leiden", resolution=1.0)   # -> adata.obs["clusters"]
bk.tl.cluster_metrics(adata, true_key="Subtype")

# ---- differential expression -----------------------------------------
bk.tl.de(adata, groupby="Subtype", group="Basal", reference="Luminal")
res = adata.uns["de"]["Subtype_Basal_vs_Luminal"]["results"]
bk.pl.volcano(res)
bk.pl.heatmap_de(adata, contrast="Subtype_Basal_vs_Luminal", groupby="Subtype")

# ---- associations and survival ---------------------------------------
bk.tl.gene_categorical_association(adata, groupby="Subtype", genes=["MKI67", "TP53"])
bk.tl.cox_gene_association(adata, time_col="OS.time", event_col="OS", genes=["MKI67"])

# ---- save -------------------------------------------------------------
bk.pp.make_h5ad_safe(adata)          # rename keys HDF5 cannot represent
adata.write("results.h5ad", compression="gzip")

Every call above is checked against the real signatures by the test suite.


📚 Function index

A map of what is available, grouped by task. See the API reference for the arguments each one takes.

# Load data
adata = bk.io.read_counts("counts.tsv", sep="\t")
# Load metadata
adata = bk.add_metadata(adata, "metadata.tsv", sep="\t")
# QC
bk.pp.qc_metrics(adata)
bk.pl.qc_metrics(adata)
bk.pp.filter_genes(adata)
bk.pp.filter_samples(adata)
# PCA + UMAP
bk.pp.highly_variable_genes(adata)
bk.tl.pca(adata)
bk.pl.pca_scatter(adata)
bk.pl.pca_variance_ratio(adata)
bk.tl.pca_loadings(adata)
bk.pl.pca_loadings_bar(adata)
bk.pl.pca_loadings_heatmap(adata)
bk.tl.neighbors(adata)
bk.tl.umap(adata)
bk.tl.umap_graph(adata)
bk.pl.umap(adata)
# Clustering
bk.tl.leiden_resolution_scan(adata)
bk.pl.ari_resolution_heatmap(adata)
bk.tl.cluster(adata, method="leiden")
bk.tl.cluster(adata, method="means")
bk.tl.cluster_metrics(adata)
# Genes and gene signatures
bk.tl.score_genes(adata, signature)
bk.tl.score_genes_cell_cycle(adata)
# Correlations and associations
bk.pl.corr_heatmap(adata)
bk.tl.gene_gene_correlations(adata)
bk.tl.gene_gene_correlations(adata)
bk.tl.top_gene_obs_correlations(adata)
bk.tl.obs_obs_corr_matrix(adata)
bk.pl.corrplot(adata)
bk.tl.plot_corr_scatter(adata)
bk.tl.gene_categorical_association(adata)
bk.pl.association_heatmap(dfg)
bk.tl.categorical_association(adata)
bk.pl.boxplot_with_stats(adata)
bk.pl.categorical_confusion(adata)
bk.pl.gene_association(adata)
bk.pl.gene_association_volcano(adata)
bk.tl.pairwise_posthoc(y, method="mwu")
bk.pl.dotplot_association(df_all)
bk.pl.heatmap_association(df_all)
bk.tl.rank_genes_groups_fast(adata)
bk.pl.rankplot_association(dfo)
bk.pl.volcano_categorical(res)
bk.tl.posthoc_per_gene(adata)
# Marker genes and Differential expression
bk.tl.de(adata)
bk.tl.de_glm(adata)  # DESeq-like   
bk.pl.volcano(res)
bk.pl.rankplot(res)
bk.pl.ma(res)
# GSEA, genesets and pathway analysis
bk.tl.gsea_preranked(adata)
bk.pl.gsea_bubbleplot(df_gsea)
bk.pl.gsea_leading_edge_heatmap(adata)
bk.pl.leading_edge_jaccard_heatmap(pre_res)
bk.pl.leading_edge_overlap_matrix(pre_res)
bk.tl.list_enrichr_libraries()
# Metaprograms
bk.tl.score_metaprograms(adata)
bk.tl.metaprogram_heterogeneity(adata)
bk.pl.metaprogram_corr(adata)
bk.pl.metaprogram_heatmap(adata)
bk.tl.metaprogram_sample_metrics(adata)
bk.tl.metaprogram_dispersion_by_group(adata)
bk.tl.metaprogram_ne_enrichment(adata)
bk.tl.metaprogram_topk_contribution(adata)
bk.pl.metaprogram_dispersion_heatmap(adata)
bk.pl.metaprogram_metrics_summary(adata)
bk.pl.metaprogram_ne_scatter(adata)
bk.pl.metaprogram_dominance_ridgeplot_like(adata)
bk.pl.metaprogram_rank1_composition_stackedbar(adata)
# Survival analysis
bk.tl.cox_univariate(adata)
bk.pl.cox_forest_from_uns(adata)
bk.pl.run_cox_per_group(adata)
bk.tl.cox_interaction(adata)
bk.pl.km_univariate(adata)
bk.pl.km_2x2_interaction(adata)
# Plots
bk.pl.violin(adata)
bk.pl.dotplot(adata)
bk.pl.heatmap_de(adata)
bk.pl.sample_distances(adata)
bk.pl.sample_correlation_clustergram(adata)
bk.pl.gene_plot(adata)
bk.pl.oncoprint(adata)
# Other Utilities
bk.pp.make_h5ad_safe(adata)
bk.pp.find_bad_obs_cols_by_write(adata)
bk.pp.find_bad_var_cols_by_write(adata)
bk.pp.make_obs_h5ad_safe_strict(adata)
bk.pp.make_var_h5ad_safe_strict(adata)
bk.pp.batch_correct_combat(adata)

📊 Features

•	Bulk RNA-seq, small and large projects. QC & filtering
•	PCA, UMAP, Leiden, k-means clustering
•	Gene scores and signatures
•	Gene–obs and obs–obs associations and correlations
•	Differential expression from counts or log data
•	GSEA preranked pipeline (GSEApy)
•	Leading-edge GSEA analysis
•	Oncoprint-style mutation plots
•	Scanpy-like API (pp, tl, pl)

⚠️ Notes

•	data/ and results/ are not versioned
•	Designed for small or large datasets (TCGA-scale)
•	Requires Python ≥ 3.10

Upgrading to 0.2.0

0.2.0 fixes several defects that silently produced wrong results, so re-running existing analyses is worthwhile. Two changes affect existing code:

  • io.read_counts() no longer casts non-integer matrices to int64. It previously truncated them without warning (10.77 became 10), which corrupts any file distributed as log2(count+1) — UCSC Xena's tables among them. Such files are now loaded unchanged, with a warning.
  • Parameters that defaulted to one study's column names are now required. Calls relying on defaults such as time_key="OS.time", groupby="Project_ID" or label_col="PFS_6m" must now name the column explicitly. A missing argument raises TypeError naming the parameter.

See CHANGELOG.md for the full list.


Changelog

See CHANGELOG.md for a full list of changes.


📄 Publication & License

BSD 3-Clause License

Please cite:
Malumbres M. (2026) BULLKpy: An AnnData-Inspired Unified Framework for Comprehensive Bulk OMICs Analysis. BioRxiv 10.64898/2026.01.26.701768v1. doi: https://doi.org/10.64898/2026.01.26.701768.

https://www.biorxiv.org/content/10.64898/2026.01.26.701768v1.

Metadata

Release files for bullkpy 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bullkpy 0.2.0
File Size Uploaded Provenance Actions
bullkpy-0.2.0.tar.gz 231.3 kB With provenance Details for bullkpy-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bullkpy 0.2.0
File Interpreter ABI Platform Actions
bullkpy-0.2.0-py3-none-any.whl Python 3 none any Details for bullkpy-0.2.0-py3-none-any.whl

Total release size: 484.8 kB

Release files / bullkpy-0.2.0.tar.gz

Download URL bullkpy-0.2.0.tar.gz
Size 231.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3e63ce345de011b68b2031942b7dbeab3ae9814767da2cd311221c6a3c46d137
BLAKE2b-256 checksum
How to use checksums
b50d5385c0863480dd353644d412b505e4fd040235103616a9b5d07991244a49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / bullkpy-0.2.0-py3-none-any.whl

Download URL bullkpy-0.2.0-py3-none-any.whl
Size 253.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae5a2823dbc9c06f9bb1da13f4765aa54d897758302beb40493f20fc7aefa5b9
BLAKE2b-256 checksum
How to use checksums
00e9d491aeaa57513e2931b409c78592616c026626401d9d212a373bf8d95c99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for bullkpy 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bullkpy-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page