Skip to main content

A Python toolkit for fitting and analyzing mutational signatures

Project description

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-learn

The package is installed as sonata-learn 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

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

sonata_learn-0.1.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sonata_learn-0.1.0-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file sonata_learn-0.1.0.tar.gz.

File metadata

  • Download URL: sonata_learn-0.1.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.4 Linux/6.8.0-117-generic

File hashes

Hashes for sonata_learn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bd3df9b0e075c5f139d869f5827755195280a1afa5d2acac01f5050d0756e7a8
MD5 0d0b5568c25745fe7b8d4fe1b51892e5
BLAKE2b-256 100b8520c06a00e9acb1046fc55ea480321d5fc6004d41877aab263627e312f3

See more details on using hashes here.

File details

Details for the file sonata_learn-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sonata_learn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.4 Linux/6.8.0-117-generic

File hashes

Hashes for sonata_learn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1385c23ba844c647127e66e38bdad25e06e131279de39aec1b31d8f8915a416d
MD5 cfad64123e7ab114a60ea44a61b3ec56
BLAKE2b-256 1c00e401b34d533871279a81c5996faae63b05cd63780775b5d8c33ab716182e

See more details on using hashes here.

Supported by

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