Skip to content

parklab/Sonata

Repository files navigation

Sonata

Python versions supported License Code style

Sonata is a Python toolkit for fitting and analyzing mutational signatures. It fits signatures and exposures in AnnData objects and provides analysis and plotting APIs for signature workflows.

Installation

pip install sonata-tools

The package is installed as sonata-tools and imported as sonata.

Quickstart

import sonata as so

model = so.models.NMF(n_signatures=6)
model.fit(adata)

so.pl.barplot(model.asignatures)
so.pl.stacked_barplot(model.exposures)

so.tl.reduce_dimension(
    model.adata,
    basis="exposures",
    method="umap",
)
so.pl.embedding(model.adata, basis="umap")

Data Format

Sonata expects mutation counts in an AnnData object:

  • adata.X: count matrix with shape n_samples x n_mutation_types.
  • adata.obs: optional sample annotations.
  • adata.var: optional mutation-type annotations.

After fitting, the model stores learned signatures in model.asignatures and sample exposures in model.adata.obsm["exposures"].

Documentation

For a complete workflow covering data preparation, NMF, visualization, fixed signatures, Cornet, and simple model selection, see the Markdown tutorial. A runnable notebook with the same analysis and figure-generation code is available at docs/tutorial.ipynb.

Models

Sonata currently exposes three algorithms:

  • so.models.NMF: NMF with the generalized Kullback-Leibler divergence.
  • so.models.MvNMF: minimum-volume NMF.
  • so.models.Cornet: correlated NMF with joint sample and signature embeddings.

License

MIT

About

Python toolkit for mutational signature analysis using NMF algorithms.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages