Gaussian Mixture VAE for multi-modal biological module discovery in omics data.
Project description
BSVAE: Gaussian Mixture VAE for Module Discovery
BSVAE is a PyTorch package centered on GMMModuleVAE, a Gaussian-mixture variational autoencoder for feature-level module discovery in omics data.
What It Does
- Trains a two-phase GMM-VAE (
bsvae-train) - Extracts feature-feature networks from trained models (
bsvae-networks) - Extracts module assignments and optional eigengenes (
bsvae-networks) - Exports latents (
mu,logvar,gamma) as.npz - Simulates synthetic datasets and benchmarks module recovery (
bsvae-simulate)
Installation
From PyPI:
pip install bsvae
From source:
git clone https://github.com/heart-gen/BSVAE.git
cd BSVAE
pip install -e .
CLI Entry Points
bsvae-trainbsvae-networksbsvae-simulate
Quickstart
For a full walkthrough (minimal run, production run, post-training analysis, simulation benchmark, troubleshooting, and migration), see docs/tutorial.md.
1. Train
Input matrix must be features x samples with feature IDs in row index and sample IDs in columns.
bsvae-train exp1 \
--dataset data/expression.csv \
--epochs 100 \
--n-modules 20 \
--latent-dim 32
2. Extract networks
bsvae-networks extract-networks \
--model-path results/exp1 \
--dataset data/expression.csv \
--output-dir results/exp1/networks \
--methods mu_cosine gamma_knn
3. Extract modules
bsvae-networks extract-modules \
--model-path results/exp1 \
--dataset data/expression.csv \
--output-dir results/exp1/modules
4. Export latents
bsvae-networks export-latents \
--model-path results/exp1 \
--dataset data/expression.csv \
--output results/exp1/latents.npz
5. Simulate and benchmark
bsvae-simulate generate \
--output data/sim_expr.csv \
--save-ground-truth data/sim_truth.csv
bsvae-simulate benchmark \
--dataset data/sim_expr.csv \
--ground-truth data/sim_truth.csv \
--model-path results/exp1 \
--output results/exp1/sim_metrics.json
Training Outputs
bsvae-train writes to results/<experiment>/:
model.pt(weights)specs.json(metadata and run args)train_losses.csv(epoch/component losses)model-<epoch>.ptcheckpoints when--checkpoint-everyis set
Data Formats
The loader supports:
.csv/.csv.gz.tsv/.tsv.gz.h5/.hdf5.h5ad(optionalanndatadependency)
Python API (Minimal)
from bsvae.utils.modelIO import load_model
from bsvae.networks.extract_networks import create_dataloader_from_expression, run_extraction
model = load_model("results/exp1", is_gpu=False)
loader, feature_ids, _ = create_dataloader_from_expression("data/expression.csv", batch_size=128)
results = run_extraction(model, loader, feature_ids=feature_ids, methods=["mu_cosine"], top_k=50)
print(results[0].method, results[0].adjacency.shape)
License
This project is licensed under the GNU General Public License v3.0.
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 bsvae-0.3.0.tar.gz.
File metadata
- Download URL: bsvae-0.3.0.tar.gz
- Upload date:
- Size: 68.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.10.9 Linux/4.18.0-553.22.1.el8_10.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e60c6e44d4e1fea8112cb278e12850cb310ac1721362a9c5c4b95e826bf0d25
|
|
| MD5 |
2f298cda1cfed1eaac4f433d9207bba4
|
|
| BLAKE2b-256 |
28da3a51e808fcc454cd5940b3b83e41b1311bdee5df99f8a4f5341d18ec456d
|
File details
Details for the file bsvae-0.3.0-py3-none-any.whl.
File metadata
- Download URL: bsvae-0.3.0-py3-none-any.whl
- Upload date:
- Size: 83.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.10.9 Linux/4.18.0-553.22.1.el8_10.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
051ccd2993214221d138d59d3ca1417e97b4b0577db52743e7ba1931f9fe1ebf
|
|
| MD5 |
983d2c8b281bc365ef003b5ecef7cbfb
|
|
| BLAKE2b-256 |
0f7a0b346d8828bf0dc3ca0ff4afcf812fc37d0e3902aa2702f85911f207111c
|