Skip to main content

MuVI: A multi-view latent variable model with domain-informed structured sparsity for integrating noisy feature sets.

Project description

MuVI

A multi-view latent variable model with domain-informed structured sparsity, that integrates noisy domain expertise in terms of feature sets.

Examples | Paper | BibTeX

Build Coverage

Basic usage

The MuVI class is the main entry point for loading the data and performing the inference:

import numpy as np
import pandas as pd
import anndata as ad
import mudata as md
import muvi

# Load processed input data (missing values are allowed)
# Matrix of dimensions n_samples x n_rna_features
rna_df = pd.read_csv(...)
# Matrix of dimensions n_samples x n_prot_features
prot_df = pd.read_csv(...)

# Load prior feature sets, e.g. gene sets
gene_sets = muvi.fs.from_gmt(...)
# Binary matrix of dimensions n_gene_sets x n_rna_features
gene_sets_mask = gene_sets.to_mask(rna_df.columns)

# Create a MuVI object by passing both input data and prior information
model = muvi.MuVI(
    observations={"rna": rna_df, "prot": prot_df},
    prior_masks={"rna": gene_sets_mask},
    ...
    device=device,
)

# Alternatively, create a MuVI model from AnnData (single-view)
rna_adata = ad.AnnData(rna_df, dtype=np.float32)
rna_adata.varm['gene_sets_mask'] = gene_sets_mask.T
model = muvi.tl.from_adata(
    adata, 
    prior_mask_key="gene_sets_mask", 
    ..., 
    device=device
)

# Alternatively, create a MuVI model from MuData (multi-view)
mdata = md.MuData({"rna": rna_adata, "prot": prot_adata})
model = muvi.tl.mdata(
    mdata, 
    prior_mask_key="gene_sets_mask", 
    ..., 
    device=device
)

# Fit the model for a given number of training epochs
model.fit(batch_size, n_epochs, ...)

# Continue with the downstream analysis (see below)

Submodules

The package consists of three additional submodules for analysing the results post-training:

  • muvi.tl provides tools for downstream analysis, e.g.,
    • compute muvi.tl.variance_explained across all factors and views
    • muvi.tl.test the significance between the prior feature sets and the inferred factors
    • apply clustering on the latent space such as muvi.tl.leiden
    • muvi.tl.save the model in order to muvi.tl.load it at a later point in time
  • muvi.pl works in tandem with muvi.tl by providing visualization methods such as
    • muvi.pl.variance_explained (see above)
    • plotting the latent space via muvi.pl.tsne, muvi.pl.scatter or muvi.pl.stripplot
    • investigating factors in terms of their inferred loadings with muvi.pl.inspect_factor
  • muvi.fs serves the data structure and methods for loading, processing and storing the prior information from feature sets

Tutorials

Check out our basic tutorial to get familiar with MuVI, or jump straight to a single-cell multiome analysis!

R users can readily export a trained MuVI model into R with a single line of code and resume the analysis with the MOFA2 package.

muvi.ext.save_as_hdf5(model, "muvi.hdf5", save_metadata=True)

See this vignette for more details!

Installation

We suggest using conda to manage your environments, and pip to install muvi as a python package. Follow these steps to get muvi up and running!

  1. Create a python environment in conda:
conda create -n muvi python=3.9
  1. Activate freshly created environment:
source activate muvi
  1. Install muvi with pip:
python3 -m pip install muvi
  1. Alternatively, install the latest version with pip:
python3 -m pip install git+https://github.com/MLO-lab/MuVI.git

Make sure to install a GPU version of PyTorch to significantly speed up the inference.

Citation

If you use MuVI in your work, please use this BibTeX entry:

Encoding Domain Knowledge in Multi-view Latent Variable Models: A Bayesian Approach with Structured Sparsity

Arber Qoku and Florian Buettner

International Conference on Artificial Intelligence and Statistics (AISTATS) 2023

https://proceedings.mlr.press/v206/qoku23a.html

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

muvi-0.1.5.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

muvi-0.1.5-py3-none-any.whl (54.1 kB view details)

Uploaded Python 3

File details

Details for the file muvi-0.1.5.tar.gz.

File metadata

  • Download URL: muvi-0.1.5.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for muvi-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2bb64850cdf580500191c4afffcc6d1b852e5caea5c827679c208b87ec0ab0f8
MD5 64c0e24820ae94b755abcc95e84838cd
BLAKE2b-256 b8d60519c6961bc0ce99982326c4351f95016a97bbdd8cb662b81c2987d5e8a6

See more details on using hashes here.

File details

Details for the file muvi-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: muvi-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 54.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for muvi-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cb8f46484dea11fb72c9a8501e22b08c61e6684cc6010b899e200fa8cb7ad13d
MD5 aba83fc572856a131d47aa82497e62ee
BLAKE2b-256 cfb4a1349fe11eb5534c97ef42feae50e21df0847116dbb020140864a2be3f92

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page