PRISM - Pathway Representation via Intrinsic Structural Medoids
July 7, 2026 ยท View on GitHub
Overview
PRISM (Pathway Representation via Intrinsic Structural Medoids) is a state-aware pathway clustering framework designed for comparing and classifying multiple molecular pathways or trajectories.
PRISM proceeds in three stages:
-
Representative-set construction (structural medoids): Each pathway is mapped to a compact set of representative conformations (medoids) obtained from k-means clustering in your chosen feature space. Three construction strategies are supported:
-
Option 1 (Global medoid sharing): Pool all frames across all pathways, cluster into
kclusters, compute one medoid per cluster, then assign each pathway the subset of global medoids whose clusters contain frames from that pathway. -
Option 2 (Per-pathway independent medoids): Cluster each pathway independently into
kclusters and compute its medoids. Representatives are pathway-specific with no enforced sharing. -
Option 3 (Two-stage refinement): First perform Option 2 to obtain local medoids, pool all local medoids, cluster into
k_finalclusters, compute refined global medoids, then assign each pathway the refined medoids matching its local medoids.
-
-
Pathway dissimilarity (weighted average Hausdorff distance): For two pathways represented by sets A and B of medoids, PRISM computes a symmetric dissimilarity based on mean nearest-neighbor distances in both directions.
-
Hierarchical clustering: The resulting pathway dissimilarity matrix is clustered using hierarchical agglomerative clustering (HAC), enabling flexible pathway grouping and dendrogram visualization.
When to use PRISM
PRISM is ideal for:
- Enhanced sampling analysis: Comparing pathways from enhanced sampling simulations.
- Multi-trajectory comparison: Clustering multiple independent MD simulations to identify similar dynamics pathways.
- Pathway classification: Grouping trajectory ensembles into biologically meaningful pathway classes.
- Conformational pathway analysis: Summarizing complex multi-frame trajectories with compact medoid sets for efficient comparison.
- Large-scale trajectory studies: Handling hundreds or thousands of pathways with minimal memory overhead.
Tutorial
1. Input Preparations
Each pathway (trajectory) should be prepared as a 2D numpy array with shape (n_frames, n_features). All pathways must have the same number of features (columns).
Supported input formats:
- CSV files: Load with
np.genfromtxt(file, delimiter=',') - NumPy files (.npy): Load with
np.load(file) - Other formats: Adapt the parsing logic in the script as needed
Example dataset:
MDANCE includes a sample dataset of 80 alanine dipeptide pathways with dihedral angle features at src/mdance/data/ala_pathways/. These files (pathway_dih_0.csv through pathway_dih_79.csv) contain phi and psi dihedral angles from multiple MD simulations of alanine dipeptide, making them ideal for testing PRISM.
Important:
- Ensure all trajectories are aligned and/or centered if needed before clustering.
- All pathways must share the same feature space (same number of columns).
For Molecular Dynamics trajectories, see scripts/inputs/preprocessing.ipynb for step-by-step trajectory preprocessing.
2. PRISM Clustering
A runnable example is provided in:
This script:
- Loads multiple pathway files from a directory pattern
- Constructs medoid representations for each pathway
- Computes pathway dissimilarities
- Performs hierarchical clustering
- Writes pathway cluster assignments and medoid indices
Parameters to edit in run_prism.py
System Parameters:
file_pattern = '/data/*.csv' # Pattern pointing to trajectory files
metric = 'MSD' # Metric for medoid computation (e.g., 'MSD', 'RMSD')
file_pattern: glob pattern pointing to your input files. Each match is treated as a separate pathway.metric: Feature space metric identifier used during medoid selection (e.g., 'MSD' for mean-square deviation).
PRISM Parameters:
option = 2 # Medoid construction: 1=global, 2=per-traj, 3=two-stage
k = 20 # Number of clusters for medoid construction
k_final = k # Second-stage cluster count (used only if option == 3)
weight_scheme = 'weighted_avg' # Average Hausdorff normalization scheme:
# 'unnormalized', 'weighted_avg', 'sym_avg', 'product_avg'
option: Strategy for building medoid sets (1, 2, or 3; see Overview).k: Number of clusters used when building representative medoids.k_final: Number of clusters in the second refinement stage (only foroption==3).weight_scheme: Weighting method for the Hausdorff distance calculation.
Hierarchical Clustering Parameters:
t = 2 # Threshold for fcluster (interpreted by criterion)
criterion = 'maxclust' # fcluster criterion: 'maxclust', 'distance', etc.
linkage_method = 'ward' # HAC linkage method: 'ward', 'average', 'complete', etc.
t: Threshold parameter passed toscipy.cluster.hierarchy.fcluster. Forcriterion='maxclust',tis the maximum number of pathway clusters.criterion: Clustering criterion (e.g.,'maxclust'for fixed max cluster count).linkage_method: Linkage method for hierarchical clustering (e.g.,'ward'minimizes variance).
Output Parameters:
save_medoid_indices = True # Save medoid frame indices as CSV
Data Loading
Modify the data loading section to match your file format:
# For CSV files (default):
for file in glob.glob(file_pattern):
traj = file.split('_')[-1].split('.')[0]
frame = np.genfromtxt(file, delimiter=',')
frames_all.append((traj, frame))
# For NumPy files:
for file in glob.glob(file_pattern, recursive=True):
traj = file.split('/')[-1].split('.')[0]
frame = np.load(file)
frames_all.append((traj, frame))
Each entry in frames_all is a tuple: (unique_pathway_id, 2D_array).
Quick start with example data: To run PRISM on the included alanine dipeptide pathway dataset:
file_pattern = '/path/to/MDANCE/src/mdance/data/ala_pathways/*.csv'
This will load all 80 alanine dipeptide pathways for clustering.
Execution
cd scripts/prism
python run_prism.py
3. Outputs
The script generates the following files:
Cluster assignments:
prism_opt{option}_k{k}_labels.csv- Columns:
traj_id,cluster - Each row assigns a pathway to a cluster
- Columns:
Dendrogram visualization:
prism_opt{option}_k{k}.png- Hierarchical clustering dendrogram showing pathway relationships
Medoid frame indices (if enabled):
prism_opt{option}_k{k}_medoid_indices.csv- Columns:
assigned_traj,source_traj,frame_index - Maps medoid frames back to their source trajectories
- Columns:
4. Pathway Medoid Analysis (Optional)
After obtaining medoid indices from Step 3, you can extract and analyze representative frames for each medoid:
- Use the medoid frame indices CSV to identify key frames in each pathway.
- Extract these frames from the original trajectory files.
- Perform structural analysis (RMSD, visualization, etc.) on the medoids.
- Compare medoid sets across pathways to understand pathway differences.
For MD trajectory post-processing, see postprocessing notebook.
Notes and Tips
-
Memory efficiency: PRISM avoids computing full pairwise distance matrices between frames by using compact medoid representations, making it suitable for large-scale pathway analysis.
-
Medoid selection strategy: Choose
optionbased on your use case:option=1: Use when pathways are likely to share similar structural features.option=2: Use when pathways are expected to be distinct (recommended starting point).option=3: Use for refined comparison after identifying pathway families with option 2.
-
Number of medoids (k): Higher
kcaptures finer structural details but increases computational cost and medoid set complexity. Start withk=10-20and adjust based on your insights. -
Dendrogram interpretation: Heights in the dendrogram indicate the dissimilarity level at which pathways merge. Large vertical gaps suggest distinct pathway clusters.
-
Clustering criterion: Use
criterion='maxclust'withtset to your desired number of pathway clusters. Alternatively, usecriterion='distance'to cut at a specific dissimilarity threshold.