Skip to main content

Molecular Systems Automated Identification of Cooperativity

MoSAIC is an unsupervised method for correlation analysis which automatically detects the collective motion in MD simulation data, while simultaneously identifying uncorrelated coordinates as noise. Hence, it can be used as a feature selection scheme for Markov state modeling or simply to obtain a detailed picture of the key coordinates driving a biomolecular process. It is based on the Leiden community detection algorithm which is used to bring a correlation matrix in a block-diagonal form.

The method was published in:

Correlation-Based Feature Selection to Identify Functional Dynamics in Proteins
G. Diez, D. Nagel, and G. Stock,
J. Chem. Theory Comput. 2022 18 (8), 5079-5088,
doi: 10.1021/acs.jctc.2c00337

If you use this software package, please cite the above mentioned paper.

Features

  • Intuitive usage via module and via CI
  • Sklearn-style API for fast integration into your Python workflow
  • No magic, only a single parameter which can be optimized via cross-validation
  • Extensive documentation and detailed discussion in publication
  • Step by step tutorial to follow

Installation

The package is called mosaic-clustering and is available via PyPI or conda. To install it, simply call:

python3 -m pip install --upgrade mosaic-clustering

or

conda install -c conda-forge mosaic-clustering

or for the latest dev version

# via ssh key
python3 -m pip install git+ssh://git@github.com/moldyn/MoSAIC.git

# or via password-based login
python3 -m pip install git+https://github.com/moldyn/MoSAIC.git

In case one wants to use the deprecated UMAPSimilarity or the module mosaic umap one needs to specify the extras_require='umap', so

python3 -m pip install --upgrade moldyn-mosaic[umap]

Shell Completion

Using the bash, zsh or fish shell click provides an easy way to provide shell completion, checkout the docs. In the case of bash you need to add following line to your ~/.bashrc

eval "$(_MOSAIC_COMPLETE=bash_source mosaic)"

Usage

In general one can call the module directly by its entry point $ MoSAIC or by calling the module $ python -m mosaic. The latter method is preferred to ensure using the desired python environment. For enabling the shell completion, the entry point needs to be used.

CI - Usage Directly from the Command Line

The module brings a rich CI using click. Each module and submodule contains a detailed help, which can be accessed by

$ python -m mosaic
Usage: python -m mosaic [OPTIONS] COMMAND [ARGS]...

  MoSAIC motion v0.5.0

  Molecular systems automated identification of collective motion, is
  a correlation based feature selection framework for MD data.
  Copyright (c) 2021-2025, Georg Diez and Daniel Nagel

Options:
  --help  Show this message and exit.

Commands:
  clustering  Clustering similarity matrix of coordinates.
  similarity  Creating similarity matrix of coordinates.
  tui         Open Textual TUI for interactive usage.

For more details on the submodule one needs to specify one of the two commands, or by opening the terminal user interface (tui).

A simple workflow example for clustering the input file input_file using correlation and Leiden with CPM and the default resolution parameter:

# creating correlation matrix
$ python -m mosaic similarity -i input_file -o output_similarity --metric correlation -v

MoSAIC SIMILARITY
~~~ Initialize similarity class
~~~ Load file input_file
~~~ Fit input
~~~ Store similarity matrix in output_similarity

# clustering with CPM and default resolution parameter
# the latter needs to be fine-tuned to each matrix
$ python -m mosaic clustering -i output_similarity -o output_clustering --plot -v

MoSAIC CLUSTERING
~~~ Initialize clustering class
~~~ Load file output_similarity
~~~ Fit input
~~~ Store output
~~~ Plot matrix

This will generate the similarity matrix stored in output_similarity, the plotted result in output_clustering.matrix.pdf, the raw data of the matrix in output_clustering.matrix and a file containing in each row the indices of a cluster.

Module - Inside a Python Script

import mosaic

# Load file
# X is np.ndarray of shape (n_samples, n_features)

sim = mosaic.Similarity(
    metric='correlation',  # or 'NMI', 'GY', 'JSD'
)
sim.fit(X)


# Cluster matrix
clust = mosaic.Clustering(
    mode='CPM',  # or 'modularity', 'linkage'
)
clust.fit(sim.matrix_)

clusters = clust.clusters_
clusterd_X = clust.matrix_
...

Metadata

Release files for mosaic-clustering 0.5.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 mosaic-clustering 0.5.0
File Size Uploaded Provenance
mosaic_clustering-0.5.0.tar.gz 31.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mosaic-clustering 0.5.0
File Interpreter ABI Platform
mosaic_clustering-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.9 kB

Release files / mosaic_clustering-0.5.0.tar.gz

Download URL mosaic_clustering-0.5.0.tar.gz
Size 31.0 kB
Tags Source
SHA-256 checksum
How to use checksums
684ce3598387ed2f67da7f75e0ffe0334fccf88955b9e8c884ad6e89790997fd
BLAKE2b-256 checksum
How to use checksums
b2ff63259af565f4fd5ed1784ecaca6fe0f0da4b787a69cb156c57183f5db6ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / mosaic_clustering-0.5.0-py3-none-any.whl

Download URL mosaic_clustering-0.5.0-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08c2860236340f624ba8cd2143e201b841368f0d7afddb556a5ee824e638bf03
BLAKE2b-256 checksum
How to use checksums
6eec5ae30d030753525966b51ae656eca2a74a565876a6643d83e30a73fdd60e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for mosaic-clustering 0.5.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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