A collection of cheminformatics utility functions for use with marimo, an open-source reactive notebook for Python.
You can install marimo-chem-utils using pip:
pip install marimo-chem-utils| Demo | Description | Open in molab |
|---|---|---|
| Clustering | View clustering results | |
| Scatterplot | Interactive scatterplot with chemical structures | |
| REOS Filtering | Review functional group filtering |
Here is an example of how to use some of the functions in this library.
import pandas as pd
import marimo as mo
from marimo_chem_utils import (
add_fingerprint_column,
add_image_column,
add_inchi_key_column,
add_tsne_columns,
interactive_chart
)
# Load some data
df = pd.read_csv("https://raw.githubusercontent.com/PatWalters/datafiles/refs/heads/main/carbonic.csv")
# Add fingerprints, images, and InChI keys
df = add_fingerprint_column(df, fp_type="counts_fp")
df = add_image_column(df, smiles_column="SMILES")
df = add_inchi_key_column(df, smiles_column="SMILES")
# Generate t-SNE coordinates
df = add_tsne_columns(df)
# Create an interactive plot
chart = interactive_chart(df, x_col="TSNE_x", y_col="TSNE_y", color_col="PIC50", image_col="image")
# In a marimo cell, you would display the chart like this:
# mo.ui.altair_chart(chart)This will create a pandas.DataFrame with additional columns for fingerprints, images, and InChI keys, and then generate an interactive t-SNE plot that you can explore in your marimo notebook. The plot will display molecule images in the tooltips.
The examples directory contains marimo notebooks that demonstrate how to use marimo-chem-utils. You can run them from the command line.
- clustering.py: An example of clustering molecules and viewing the cluster members.
marimo edit examples/clustering.py- scatterplot.py: An interactive scatterplot that shows chemical structures as tooltips. Selections on the plot are used to display a grid of molecules.
marimo edit examples/scatterplot.py- reos.py: An viewer for functional group filters
marimo edit examples/reos.py