Skip to content

Commit efba0d0

Browse files
Merge pull request #39 from dominiquesydow/update-dyno-notebook
Update dyno notebook
2 parents 47d62b2 + c730fab commit efba0d0

5 files changed

Lines changed: 2053 additions & 1881 deletions

File tree

docs/tutorials/dynophore.ipynb

Lines changed: 1933 additions & 1824 deletions
Large diffs are not rendered by default.

docs/tutorials/explore_view3d.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,7 @@
412412
}
413413
],
414414
"source": [
415-
"view = view3d.show(\n",
416-
" dynophore, pdb_path, visualization_type=\"spheres\", select_cloud_range=[900, 1000]\n",
417-
")\n",
415+
"view = view3d.show(dynophore, pdb_path, visualization_type=\"spheres\", frame_range=[900, 1000])\n",
418416
"view.display(gui=True, style=\"ngl\")"
419417
]
420418
},

dynophores/notebooks/dynophore.ipynb

Lines changed: 104 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,38 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Dynophore notebook\n",
7+
"# Dynophore notebook"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"## Introduction"
15+
]
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {},
20+
"source": [
21+
"### What is a dynophore?\n",
822
"\n",
9-
"This notebook contains the following dynophore analyses:\n",
23+
"* A **dynophore** is a collection of so-called superfeatures. \n",
24+
"* A **superfeature** is defined as a pharmacophore feature on the ligand side — defined by a feature type and one or more ligand atoms — that occurs at least once during an MD simulation. Example: HBA[4618] (feature type, ligand atom numbers)\n",
25+
"* A superfeature has a **point cloud**, where each point corresponds to the centroid of feature during one frame of the trajectory.\n",
26+
"* A superfeature can have one or more interaction partner(s) on the macromolecule side. These interaction partners are called **environmental partners**. Example: GLN-131-A[2057] (residue name, residue number, chain, atom serial numbers)."
27+
]
28+
},
29+
{
30+
"cell_type": "markdown",
31+
"metadata": {},
32+
"source": [
33+
"### How to work with a dynophore?\n",
1034
"\n",
11-
"- __2D view__ of the dynophore's superfeatures mapped onto the structure-bound ligand using `rdkit`.\n",
12-
"- __3D view__ of the dynophore's point clouds (one cloud per superfeature) using `nglview` allows easy visual inspection of the dynamic macromolecule-ligand interactions. Point clouds are rendered alongside the topology and (optionally) the trajectory underlying the dynophore.\n",
13-
"- __Statistics__ cover the occurrence of superfeatures and their environmental partners as well as distances between them.\n",
14-
"- __Dynophore data__ can be further analyzed conveniently right here in this notebook by working with the `Dynophore` class."
35+
"* **Dynophore raw data** can be analyzed conveniently right here in this notebook by working with the `Dynophore` class.\n",
36+
"* **Dynophore 2D view** shows all superfeatures on a 2D view of the structure-bound ligand using `rdkit`.\n",
37+
"* **Dynophore 3D view** maps each superfeature's point cloud in 3D using `nglview`, allowing for an easy visual inspection of the dynamic macromolecule-ligand interactions. Point clouds are rendered alongside the complex structure's topology and (optionally) the trajectory underlying the dynophore.\n",
38+
"* **Dynophore statistics** cover the occurrence of superfeatures and their environmental partners as well as distances between them."
1539
]
1640
},
1741
{
@@ -44,17 +68,14 @@
4468
"import nglview as nv\n",
4569
"\n",
4670
"# Import Dynophore class - contains all dynophore data\n",
47-
"from dynophores import Dynophore\n",
48-
"\n",
49-
"# Load modules for 3D viewing and plotting\n",
50-
"from dynophores import view2d, view3d, plot"
71+
"import dynophores as dyno"
5172
]
5273
},
5374
{
5475
"cell_type": "markdown",
5576
"metadata": {},
5677
"source": [
57-
"## Set paths"
78+
"## Set data paths"
5879
]
5980
},
6081
{
@@ -79,7 +100,11 @@
79100
"cell_type": "markdown",
80101
"metadata": {},
81102
"source": [
82-
"## Load data as `Dynophore` object"
103+
"## Load data as `Dynophore` object\n",
104+
"\n",
105+
"You can load the dynophore data as `Dynophore` object. We will need this object below for visualization purposes but you can also use the raw data for your own customized analyses.\n",
106+
"\n",
107+
"__Note__: Check out [this tutorial](https://dynophores.readthedocs.io/en/latest/tutorials/explore_data.html) on the dynophore's data structure."
83108
]
84109
},
85110
{
@@ -88,21 +113,16 @@
88113
"metadata": {},
89114
"outputs": [],
90115
"source": [
91-
"dynophore = Dynophore.from_dir(dyno_path)"
116+
"dynophore = dyno.Dynophore.from_dir(dyno_path)"
92117
]
93118
},
94119
{
95120
"cell_type": "markdown",
96121
"metadata": {},
97122
"source": [
98-
"__Note__: Check out [this tutorial](https://dynophores.readthedocs.io/en/latest/tutorials/explore_data.html) on the dynophore's data structure."
99-
]
100-
},
101-
{
102-
"cell_type": "markdown",
103-
"metadata": {},
104-
"source": [
105-
"## 2D view"
123+
"## 2D view\n",
124+
"\n",
125+
"Investigate the dynophore's superfeatures in 2D; display the atom serial numbers (those will show up in the superfeatures' identifiers in the plots below)."
106126
]
107127
},
108128
{
@@ -111,14 +131,34 @@
111131
"metadata": {},
112132
"outputs": [],
113133
"source": [
114-
"view2d.interactive.show(dynophore)"
134+
"dyno.view2d.interactive.show(dynophore)"
115135
]
116136
},
117137
{
118138
"cell_type": "markdown",
119139
"metadata": {},
120140
"source": [
121-
"## 3D view"
141+
"## 3D view\n",
142+
"\n",
143+
"Investigate the dynophore in 3D - you have different options that you can change in the method signature below:\n",
144+
"\n",
145+
"* `pdb_path` and `dcd_path` have been defined at the beginning of this notebook; these are the file paths to your complex structure's topology and trajectory (if you do not want to load the trajectory, set `dcd_path=None`).\n",
146+
"* `visualization_type`: `spheres` or `points`\n",
147+
" * [Default] Show each frames features as small spheres with `visualization_type=spheres`.\n",
148+
" * [Work-In-Progress] Render the dynophore cloud as more burred and connected points using `visualization_type=points` (still has some NGL rendering issues that we cannot fix on our end, see [NGL GitHub issue](https://github.com/nglviewer/ngl/issues/868))\n",
149+
"* `color_cloud_by_frame`: `False` or `True`\n",
150+
" * [Default] Color cloud by superfeature type. Example: The points belonging to a HBA-based superfeature will all be colored red.\n",
151+
" * Color cloud by superfeature type *and* frame index. Example: The points belonging to a HBA-based superfeauture will be colored from red (first frame) to light red (last frame).\n",
152+
"* `macromolecule_color`: Set a color for the macromolecule; defaults to blue.\n",
153+
"* `frame_range`: Show a selected frame range only, e.g. `frame_range=[100, 1000]`. By default, all frames are shown with `frame_range=None`.\n",
154+
"\n",
155+
"Interact directly with the 3D visualization using the NGL GUI:\n",
156+
"\n",
157+
"* Toogle on/off macromolecule > *cartoon*\n",
158+
"* Toogle on/off ligand > *hyperball*\n",
159+
"* Toogle on/off pocket residue side chains > *licorice*\n",
160+
"* Toogle on/off superfeatures > superfeature identifier e.g. *HBA[4618]*\n",
161+
"* Run trajectory if loaded"
122162
]
123163
},
124164
{
@@ -127,16 +167,23 @@
127167
"metadata": {},
128168
"outputs": [],
129169
"source": [
130-
"view = view3d.show(dynophore, pdb_path, dcd_path)\n",
131-
"view.display(gui=True, style=\"ngl\")\n",
132-
"# NOTE: You might need to run this cell twice for the content to show up"
170+
"view = dyno.view3d.show(\n",
171+
" dynophore,\n",
172+
" pdb_path=pdb_path,\n",
173+
" dcd_path=dcd_path,\n",
174+
" visualization_type=\"spheres\",\n",
175+
" color_cloud_by_frame=False,\n",
176+
" macromolecule_color=\"#005780\",\n",
177+
" frame_range=None,\n",
178+
")\n",
179+
"view.display(gui=True, style=\"ngl\")"
133180
]
134181
},
135182
{
136183
"cell_type": "markdown",
137184
"metadata": {},
138185
"source": [
139-
"In case a trajectory is Load the `TrajectoryPlayer` for more visualization options:"
186+
"In case a trajectory is loaded, use the `TrajectoryPlayer` for more visualization options:"
140187
]
141188
},
142189
{
@@ -157,9 +204,13 @@
157204
},
158205
{
159206
"cell_type": "markdown",
160-
"metadata": {},
207+
"metadata": {
208+
"tags": []
209+
},
161210
"source": [
162-
"### Plot interactions overview (heatmap)"
211+
"### Plot interactions overview (heatmap)\n",
212+
"\n",
213+
"Check how often each superfeature interacts with which environmental partners throughout the MD simulation (in %)."
163214
]
164215
},
165216
{
@@ -168,14 +219,18 @@
168219
"metadata": {},
169220
"outputs": [],
170221
"source": [
171-
"plot.interactive.superfeatures_vs_envpartners(dynophore)"
222+
"dyno.plot.interactive.superfeatures_vs_envpartners(dynophore)"
172223
]
173224
},
174225
{
175226
"cell_type": "markdown",
176227
"metadata": {},
177228
"source": [
178-
"### Plot superfeature occurrences (time series)"
229+
"### Plot superfeature occurrences (time series)\n",
230+
"\n",
231+
"Check when (barcode) and how often (in %) a superfeature $S$ occurs throughout the MD simulation.\n",
232+
"\n",
233+
"$S\\,\\text{occurrence [%]} = \\frac{\\text{Number of frames in which}\\,S\\,\\text{occurs}}{\\text{Number of frames}} \\times 100$"
179234
]
180235
},
181236
{
@@ -184,7 +239,7 @@
184239
"metadata": {},
185240
"outputs": [],
186241
"source": [
187-
"plot.interactive.superfeatures_occurrences(dynophore)"
242+
"dyno.plot.interactive.superfeatures_occurrences(dynophore)"
188243
]
189244
},
190245
{
@@ -198,7 +253,11 @@
198253
"cell_type": "markdown",
199254
"metadata": {},
200255
"source": [
201-
"#### Interaction occurrence"
256+
"#### Interaction occurrence\n",
257+
"\n",
258+
"Check when (barcode) and how often (in %\\) each environmental partner $E$ interacts in context of a superfeature $S$ ($E_S$).\n",
259+
"\n",
260+
"$E_S\\,\\text{occurrence [%]} = \\frac{\\text{Number of frames where}\\,E\\,\\text{interacts in context of}\\,S}{\\text{Number of frames where}\\,S\\,\\text{occurs}} \\times 100$"
202261
]
203262
},
204263
{
@@ -207,14 +266,19 @@
207266
"metadata": {},
208267
"outputs": [],
209268
"source": [
210-
"plot.interactive.envpartners_occurrences(dynophore)"
269+
"dyno.plot.interactive.envpartners_occurrences(dynophore)"
211270
]
212271
},
213272
{
214273
"cell_type": "markdown",
215274
"metadata": {},
216275
"source": [
217-
"#### Interaction distances"
276+
"#### Interaction distances\n",
277+
"\n",
278+
"Check for each superfeature, the distances to all environmental partners throughout the MD simulation. \n",
279+
"\n",
280+
"* **Time series**: Distances are shown for all frames regardless of whether that frame shows an interaction between the environmental partner and the superfeature's ligand atoms or not. Interactions are indicated with a dot in the plot.\n",
281+
"* **Histogram**: Only distances are shown that belong to frames in which an interaction between the environmental partner and the superfeature's ligand atoms ocurrs."
218282
]
219283
},
220284
{
@@ -223,14 +287,16 @@
223287
"metadata": {},
224288
"outputs": [],
225289
"source": [
226-
"plot.interactive.envpartners_distances(dynophore)"
290+
"dyno.plot.interactive.envpartners_distances(dynophore)"
227291
]
228292
},
229293
{
230294
"cell_type": "markdown",
231295
"metadata": {},
232296
"source": [
233-
"#### Interaction profile (all-in-one)"
297+
"#### Interaction profile (all-in-one)\n",
298+
"\n",
299+
"This is a summary of the plots shown above. Note that in this case *all* distances throughout the MD simulation are shown (regardless of whether the frame shows an interaction or not)."
234300
]
235301
},
236302
{
@@ -239,7 +305,7 @@
239305
"metadata": {},
240306
"outputs": [],
241307
"source": [
242-
"plot.interactive.envpartners_all_in_one(dynophore)"
308+
"dyno.plot.interactive.envpartners_all_in_one(dynophore)"
243309
]
244310
}
245311
],

dynophores/tests/viz/test_view3d_interactive.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
@pytest.mark.parametrize(
21-
"pdb_path, dcd_path, visualization_type, color_cloud_by_frame, select_cloud_range",
21+
"pdb_path, dcd_path, visualization_type, color_cloud_by_frame, frame_range",
2222
[
2323
(PATH_TEST_DATA / "in/startframe.pdb", None, "spheres", False, None),
2424
(
@@ -33,20 +33,20 @@
3333
],
3434
)
3535
def test_show(
36-
dynophore, pdb_path, dcd_path, visualization_type, color_cloud_by_frame, select_cloud_range
36+
dynophore, pdb_path, dcd_path, visualization_type, color_cloud_by_frame, frame_range
3737
):
3838
view3d.show(
3939
dynophore,
4040
pdb_path,
4141
dcd_path=dcd_path,
4242
visualization_type=visualization_type,
4343
color_cloud_by_frame=color_cloud_by_frame,
44-
select_cloud_range=select_cloud_range,
44+
frame_range=frame_range,
4545
)
4646

4747

4848
@pytest.mark.parametrize(
49-
"pdb_path, dcd_path, visualization_type, color_cloud_by_frame, select_cloud_range",
49+
"pdb_path, dcd_path, visualization_type, color_cloud_by_frame, frame_range",
5050
[
5151
(PATH_TEST_DATA / "in/startframe.pdb", None, "xxx", None, None), # Unknown viz type
5252
(
@@ -66,7 +66,7 @@ def test_show(
6666
],
6767
)
6868
def test_show_raises(
69-
dynophore, pdb_path, dcd_path, visualization_type, color_cloud_by_frame, select_cloud_range
69+
dynophore, pdb_path, dcd_path, visualization_type, color_cloud_by_frame, frame_range
7070
):
7171

7272
with pytest.raises(ValueError):
@@ -76,5 +76,5 @@ def test_show_raises(
7676
dcd_path=dcd_path,
7777
visualization_type=visualization_type,
7878
color_cloud_by_frame=color_cloud_by_frame,
79-
select_cloud_range=select_cloud_range,
79+
frame_range=frame_range,
8080
)

0 commit comments

Comments
 (0)