Skip to content

Commit 54244ce

Browse files
committed
feat: added analyses
1 parent 5b3c81d commit 54244ce

57 files changed

Lines changed: 8152 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

adaptyv/adaptyv_analyses/Readme.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
Adaptyv Competition – Annotation and plotting
2+
3+
Directory layout
4+
- src: core code for binding property analysis and utilities
5+
- scripts/plotting_r: R analysis and plotting scripts
6+
- scripts/plotting_python: Python plotting utilities (Matplotlib)
7+
- barplots.py: standalone CLI for stacked barplots
8+
- blog_post_theme.py: theme and palettes (no plotting)
9+
- data: raw, processed, and intermediate datasets
10+
- plots: generated figures
11+
12+
Python setup
13+
1) Create environment and install deps
14+
```bash
15+
python3 -m venv .venv
16+
source .venv/bin/activate
17+
python -m pip install --upgrade pip
18+
python -m pip install -r requirements.txt
19+
```
20+
21+
2) Generate barplots (Python CLI)
22+
```bash
23+
python scripts/plotting_python/barplots.py \
24+
--input ./data/processed/all_submissions_new.csv \
25+
--x_column design_category \
26+
--color_column selected \
27+
--output ./plots/barplots \
28+
--format svg --width 2600 --height 2200 --dpi 300 \
29+
--round both --title "Design category" \
30+
--top_n 10 --subtitle "Number of designs submitted vs. selected for validation" \
31+
--sort size
32+
```
33+
34+
Optional programmatic use of the theme/palettes
35+
```python
36+
from scripts.plotting_python.blog_post_theme import (
37+
set_adaptyv_matplotlib_theme,
38+
get_adaptyv_palettes,
39+
apply_adaptyv_blog_post_theme,
40+
)
41+
import matplotlib.pyplot as plt
42+
43+
set_adaptyv_matplotlib_theme()
44+
palettes = get_adaptyv_palettes()
45+
fig, ax = plt.subplots()
46+
# ... draw your plot ...
47+
apply_adaptyv_blog_post_theme(
48+
fig, ax, title="My Title", subtitle="My Subtitle",
49+
x_label="X", y_label="Y", legend_title="Legend"
50+
)
51+
fig.savefig("./plots/example.svg")
52+
```
53+
54+
R setup
55+
Install R packages used in the scripts:
56+
```bash
57+
Rscript ./install_packages.R
58+
```
59+
60+
Run R barplots
61+
```bash
62+
Rscript scripts/plotting_r/barplots.R \
63+
--input ./data/processed/all_submissions_new.csv \
64+
--x_column design_category \
65+
--color_column selected \
66+
--output ./plots/barplots \
67+
--format svg \
68+
--width 2600 --height 2200 --res 300 \
69+
--round both --title "Design category" \
70+
--top_n 10 --subtitle "Number of designs submitted vs. selected for validation" \
71+
--sort size
72+
```
73+
74+
Optional programmatic use of the theme/palettes (R)
75+
```r
76+
# Load theme and palettes
77+
source("scripts/plotting_r/blog_post_theme.R")
78+
library(ggplot2)
79+
80+
# Example plot using the theme and a palette
81+
df <- data.frame(
82+
x = factor(c("A","B","C","D"), levels = c("A","B","C","D")),
83+
y = c(10, 15, 7, 12),
84+
group = c("De novo", "Optimized binder", "Diversified binder", "Hallucination")
85+
)
86+
87+
ggplot(df, aes(x = x, y = y, fill = group)) +
88+
geom_col(color = "black") +
89+
scale_fill_manual(values = design_category_colors, name = "Design category") +
90+
labs(
91+
title = "My Title",
92+
subtitle = "My Subtitle",
93+
x = "X",
94+
y = "Y"
95+
) +
96+
adaptyv_theme()
97+
```
98+
99+
100+
Amino acid composition (R)
101+
```bash
102+
Rscript scripts/plotting_r/aa_composition.R \
103+
--input ./data/processed/all_submissions.csv \
104+
--output ./plots/aa_composition \
105+
--format svg --width 8400 --height 3200 --res 600 \
106+
--round both --title "Amino acid composition comparison" \
107+
--subtitle "Distribution across de novo and existing binders"
108+
```
109+
110+
More R plotting scripts
111+
```bash
112+
# Density plots by category (e.g., metric distribution by round)
113+
Rscript scripts/plotting_r/density.R \
114+
--input ./data/processed/all_submissions.csv \
115+
--output ./plots/densities \
116+
--metric sequence_length \
117+
--category round \
118+
--format svg --width 1600 --height 1200 --res 300 \
119+
--round both
120+
121+
# Pairwise correlations with colored groups
122+
Rscript scripts/plotting_r/correlation_plots.R \
123+
--input ./data/processed/all_submissions.csv \
124+
--output ./plots/correlations \
125+
--x_column iptm \
126+
--y_column kd \
127+
--color_by design_category \
128+
--round both \
129+
--format svg --width 4000 --height 3600 --res 600
130+
131+
# Violin plots (e.g., KD across rounds)
132+
Rscript scripts/plotting_r/violin_plots.R \
133+
--input ./data/processed/all_submissions.csv \
134+
--output ./plots/violin \
135+
--y_column kd \
136+
--x_column round \
137+
--color_by round \
138+
--round both \
139+
--format svg --width 1600 --height 1200 --res 300 \
140+
--show_anova TRUE --binders_only FALSE
141+
142+
# Binding affinity ordered scatter with references
143+
Rscript scripts/plotting_r/binding_affinity_plot.R \
144+
--input ./data/processed/all_submissions.csv \
145+
--output ./plots/binding_affinity \
146+
--format svg --width 6000 --height 4000 --res 600
147+
148+
# 2x2 combined correlations vs KD
149+
Rscript scripts/plotting_r/combined_metrics_plot.R \
150+
--input ./data/processed/all_submissions.csv \
151+
--output ./plots/combined_metrics \
152+
--y_column kd \
153+
--color_by design_category \
154+
--round both \
155+
--format png --width 8000 --height 6000 --res 600 \
156+
--main_title "Correlation of Protein Metrics with Binding Affinity"
157+
158+
# Barplots for model types per round
159+
Rscript scripts/plotting_r/barplots_model_types.R \
160+
--input ./data/processed/all_submissions_new.csv \
161+
--x_column round \
162+
--color_column RFdiffusion \
163+
--output ./plots/barplots_model_types \
164+
--format svg \
165+
--width 1600 --height 1400 --res 300 \
166+
--round both --title "Expressed" \
167+
--top_n 10 --subtitle "Number of expressed designs per round" \
168+
--sort alpha
169+
170+
# Interface property violins (multiple metrics)
171+
Rscript scripts/plotting_r/violin_properties.R \
172+
--input ./data/processed/all_submissions.csv \
173+
--output ./plots/interface_violins \
174+
--format svg --width 5000 --height 3800 --res 600 \
175+
--round both
176+
177+
# Radar plots for top binders
178+
Rscript scripts/plotting_r/radar_plot.R \
179+
--input ./data/processed/all_submissions.csv \
180+
--output ./plots/radar_plots \
181+
--format png --width 3600 --height 3600 --res 600 \
182+
--round 2 \
183+
--binder_type both \
184+
--top_n 5 \
185+
--title "Interface metrics for the top binders" \
186+
--subtitle "Comparing De novo and Existing binders"
187+
```
188+
189+
Binding property annotation pipeline
190+
Two components exist: structure/interface annotation and ESM PLL scoring. Both are defined as Modal functions.
191+
192+
1) Interface/binding properties (Modal)
193+
- Requirements are captured in `annotate_binding_properties.py` via a Modal `Image` builder. It installs utilities, sets up PyRosetta, and clones BindCraft.
194+
- Customize local directories if needed:
195+
- `data/raw/structures/001_2024`, `002_2024`
196+
- `data/processed`
197+
```bash
198+
python annotate_binding_properties.py
199+
```
200+
This will batch process submissions, relax structures (if enabled), compute interface metrics, and produce CSVs under `data/processed`/Modal volume outputs.
201+
202+
2) ESM PLL scoring (Modal, GPU)
203+
```bash
204+
python annotate_esm_pll.py
205+
```
206+
This reads `data/processed/all_submissions.csv` (or the mounted path inside Modal), computes PLL scores, and writes results under the Modal volume.
207+
208+
209+

0 commit comments

Comments
 (0)