META-SiM: A Foundation Model for Efficient Biological Discovery in Single-Molecule Time Traces
Single-molecule fluorescence microscopy (SMFM) is a powerful tool for revealing rare biological intermediates, but the resulting data often requires time-consuming manual inspection, hindering systematic analysis. We introduce META-SiM, a transformer-based foundation model designed to accelerate biological discovery from SMFM data. Pre-trained on diverse SMFM analysis tasks, META-SiM excels at various analyses, including trace selection, classification, segmentation, idealization, and photobleaching analysis.
Beyond individual trace analysis, META-SiM generates high-dimensional embedding vectors for each trace, enabling efficient whole-dataset visualization, labeling, comparison, and sharing. Combined with the objective metric of Local Shannon Entropy, this visualization facilitates rapid identification of condition-specific behaviors, even subtle or rare ones. Application of META-SiM to existing smFRET data revealed a previously unobserved intermediate state in pre-mRNA splicing, demonstrating its potential to remove bottlenecks, improve objectivity, and accelerate biological discovery in complex single-molecule data.
The metasim Python Library
The metasim Python library provides a user-friendly interface for leveraging the power of the META-SiM foundation model. It offers tools for data loading, processing, embedding generation, visualization, and building machine learning models for classification and regression tasks.
metasim is particularly well-suited for researchers working with FRET data who want to:
- Generate embeddings using the META-SiM model.
- Visualize embeddings using UMAP and smFRET Atlas.
- Discover condition-specific traces using Local Shannon Entropy.
- Train and evaluate machine learning models for time-trace analysis.
- Evaluate the consistency of human labels for time traces.
Installation
Install metasim using pip:
pip install metasim
Getting Started
This example demonstrates a basic workflow for building a classification model using META-SiM embeddings:
import openfret
import metasim
import numpy as np
# Load data using the OpenFRET library.
data = metasim.fret.data.TwoColorDataset(
openfret.read_data("<path_to_your_openfret_data>")
)
# Load the pre-trained META-SiM model.
model = metasim.fret.Model()
# Generate embeddings for the time traces.
embeddings = model(data)
# Prepare labels for supervised fine-tuning.
labels = np.array([trace.metadata["your_label_name"] for trace in data.traces])
# Train a task-specific classification model.
task_model = metasim.fret.tuning.train_classification(
embeddings, labels
)
# Generate predictions using the trained model.
predictions = task_model.predict(embeddings)
The example below shows how to create Atlas and data-specific UMAPs using META-SiM:
import openfret
import metasim
import numpy as np
# Load data using the OpenFRET library.
data = metasim.fret.data.TwoColorDataset(
openfret.read_data("<path_to_your_openfret_data>")
)
# Load the pre-trained META-SiM model.
model = metasim.fret.Model()
# Generate embeddings for the time traces.
embeddings = model(data)
# Prepare labels for supervised fine-tuning.
labels = np.array([trace.metadata["your_label_name"] for trace in data.traces])
# Get the local Shannon Entropy
entropy = metasim.fret.get_entropy(
embedding,
label,
)
# Plot the smFRET Atlas with data
metasim.fret.tools.viz.plot_atlas(
embedding=embedding,
label=label,
color=entropy,
color_name='Entropy',
)
# Plot the data-specific UMAP
reducer = metasim.fret.tools.viz.get_umap_reducer(embedding)
umap_coord = reducer.transform(embedding)
metasim.fret.tools.viz.plot_umap(
umap_coord=umap_coord,
label=label,
color=entropy,
color_name='Entropy',
);
# Plot the FRET histograms
idealized_states = metasim.fret.tools.idealize.idealize(dataset)
efficiency = metasim.fret.tools.idealize.get_fret_efficiency(
dataset,
idealized_states,
)
metasim.fret.tools.viz.plot_fret_histograms(
efficiency,
label,
)
For more detailed examples and tutorials, please refer to the documentation and examples available in the metasim repository.
Contributing
Contributions to metasim are welcome! Please see the repository for more information.
License
metasim is licensed under the MIT License.
Citation
Li J, Zhang L, Johnson-Buck A, Walter NG. Foundation model for efficient biological discovery in single-molecule data. Res Sq [Preprint]. 2024 Oct 17:rs.3.rs-4970585/v1. doi: 10.21203/rs.3.rs-4970585/v1. PMID: 39483892; PMCID: PMC11527229.
Metadata
Release files for metasim 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| metasim-1.0.1.tar.gz | 34.3 MB | Without provenance | Details for metasim-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metasim-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for metasim-1.0.1-py3-none-any.whl |
Total release size: 68.7 MB
Release files / metasim-1.0.1.tar.gz
| Download URL | metasim-1.0.1.tar.gz |
|---|---|
| Size | 34.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c4d41a0a613f5e8e6273f488cbfaa336014cc44ba594e53f97fda8bebdb277e
|
|
BLAKE2b-256 checksum How to use checksums |
6385f5441652a1ca0e567e2a14e987013542dbbefb0f0c5942b5ba0242b297fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.6
|
Release files / metasim-1.0.1-py3-none-any.whl
| Download URL | metasim-1.0.1-py3-none-any.whl |
|---|---|
| Size | 34.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d30ccf5ccbb5eb7b45da76a7b85280e5cc459ecb026fc0a2202aa9c7cd53def
|
|
BLAKE2b-256 checksum How to use checksums |
2edf7219f655cf48159f177031fc8bb81c10dc065d61a919887ff430a570f571
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.6
|
Security for metasim 1.0.1
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.