Skip to content

Commit 2f87730

Browse files
authored
Merge pull request #152 from markovmodel/revision-th
Revision TH
2 parents fbd695f + 422276d commit 2f87730

6 files changed

+298
-19
lines changed

manuscript/literature.bib

+47
Original file line numberDiff line numberDiff line change
@@ -630,3 +630,50 @@ @article{pcca++
630630
URL = {https://doi.org/10.1007/s11634-013-0134-6},
631631
DOI = {10.1007/s11634-013-0134-6}
632632
}
633+
@article{plattner_protein_2015,
634+
title = {Protein conformational plasticity and complex ligand-binding kinetics explored by atomistic simulations and {Markov} models},
635+
volume = {6},
636+
url = {http://www.nature.com/ncomms/2015/150702/ncomms8653/full/ncomms8653.html},
637+
doi = {10.1038/ncomms8653},
638+
journal = {Nat. Commun.},
639+
author = {Plattner, Nuria and Noé, Frank},
640+
year = {2015},
641+
pages = {7653}
642+
}
643+
@article{plattner_complete_2017,
644+
title = {Complete protein–protein association kinetics in atomic detail revealed by molecular dynamics simulations and {Markov} modelling},
645+
volume = {9},
646+
issn = {1755-4349},
647+
url = {https://www.nature.com/articles/nchem.2785},
648+
doi = {10.1038/nchem.2785},
649+
number = {10},
650+
journal = {Nat. Chem.},
651+
author = {Plattner, Nuria and Doerr, Stefan and Fabritiis, Gianni De and Noé, Frank},
652+
month = oct,
653+
year = {2017},
654+
pages = {1005}
655+
}
656+
@inproceedings{aggarwal_surprising_2001,
657+
series = {Lecture {Notes} in {Computer} {Science}},
658+
title = {On the {Surprising} {Behavior} of {Distance} {Metrics} in {High} {Dimensional} {Space}},
659+
isbn = {978-3-540-44503-6},
660+
booktitle = {Database {Theory} — {ICDT} 2001},
661+
publisher = {Springer Berlin Heidelberg},
662+
author = {Aggarwal, Charu C. and Hinneburg, Alexander and Keim, Daniel A.},
663+
editor = {Van den Bussche, Jan and Vianu, Victor},
664+
year = {2001},
665+
pages = {420--434},
666+
}
667+
@article{banushkina_nonparametric_2015,
668+
title = {Nonparametric variational optimization of reaction coordinates},
669+
volume = {143},
670+
issn = {0021-9606},
671+
url = {https://aip.scitation.org/doi/10.1063/1.4935180},
672+
doi = {10.1063/1.4935180},
673+
number = {18},
674+
journal = {J. Chem. Phys.},
675+
author = {Banushkina, Polina V. and Krivov, Sergei V.},
676+
month = nov,
677+
year = {2015},
678+
pages = {184108}
679+
}

manuscript/manuscript.tex

+15
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,21 @@ \subsection{Summary}
410410
For the full analysis, please refer to the first notebook (00).
411411
All notebooks as well as detailed installation instructions are available on \githubrepository{}.
412412

413+
\subsection{Modeling large systems}
414+
When estimating MSMs for large systems, challenges may arise that are mostly system dependent.
415+
416+
A case in point is the curse of dimensionality:~it is difficult to discretize a high dimensional feature space. While it is somewhat computationally demanding, more importantly, Euclidean distances become less meaningful with increasing dimensionality~\cite{aggarwal_surprising_2001} and thus cluster assignments based on that norm may yield a poor discretization.
417+
Especially for large systems, it is thus particularly important to first find a suitable set of features, and to further apply dimensionality reduction techniques (e.g.~TICA, VAMP, if applicable) to obtain a low dimensional representation of the slow dynamics.
418+
Hidden Markov models (HMMs) might further mitigate poor discretization to a certain extent~\cite{noe-proj-hid-msm}.
419+
420+
Furthermore, the slowest process in a system as identified by an MSM or HMM might not be the one a modeler is interested in~\cite{banushkina_nonparametric_2015}.
421+
For instance, the slowest process might correspond to a biologically irrelevant side chain flip that only occurred once in the data set.
422+
This problem may be mitigated by choosing a more specific set of features.
423+
424+
Additional technical challenges for large systems include high demands on memory and computation time; we explain how to deal with those in the tutorials.
425+
426+
More details on how to model complex systems with the techniques presented here are described e.g.~by~\cite{plattner_protein_2015,plattner_complete_2017}.
427+
413428
\subsection{Advanced Methods}
414429

415430
While the present tutorial is intended to cover Markov State Modeling 101, we encourage the user to explore other, more recent extensions of the methodology.

notebooks/00-pentapeptide-showcase.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@
16361636
"name": "python",
16371637
"nbconvert_exporter": "python",
16381638
"pygments_lexer": "ipython3",
1639-
"version": "3.6.5"
1639+
"version": "3.6.3"
16401640
},
16411641
"toc": {
16421642
"base_numbering": 1,

notebooks/02-dimension-reduction-and-discretization.ipynb

+111-12
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
"import matplotlib.pyplot as plt\n",
2929
"import numpy as np\n",
3030
"import mdshare\n",
31-
"import pyemma\n",
32-
"\n",
33-
"## Case 1: preprocessed, two-dimensional data (toy model)"
31+
"import pyemma"
3432
]
3533
},
3634
{
@@ -298,7 +296,7 @@
298296
"outputs": [],
299297
"source": [
300298
"fig, ax = plt.subplots()\n",
301-
"i = ax.imshow(tica.feature_TIC_correlation)\n",
299+
"i = ax.imshow(tica.feature_TIC_correlation, cmap='bwr', vmin=-1, vmax=1)\n",
302300
"\n",
303301
"ax.set_xticks([0])\n",
304302
"ax.set_xlabel('IC')\n",
@@ -363,8 +361,8 @@
363361
"for ax, cls in zip(axes.flat, [cluster_kmeans, cluster_regspace]):\n",
364362
" pyemma.plots.plot_density(*data_concatenated.T, ax=ax, cbar=False, alpha=0.1, logscale=True)\n",
365363
" ax.scatter(*cls.clustercenters.T, s=15, c='C1')\n",
366-
" ax.set_xlabel('$x$')\n",
367-
" ax.set_ylabel('$y$')\n",
364+
" ax.set_xlabel('$\\Phi$')\n",
365+
" ax.set_ylabel('$\\Psi$')\n",
368366
"fig.tight_layout()"
369367
]
370368
},
@@ -525,9 +523,104 @@
525523
"cell_type": "markdown",
526524
"metadata": {},
527525
"source": [
528-
"TICA, by default, uses a lag time of $10$ steps and a kinetic variance cutoff of $95\\%$ to determine the number of ICs. We observe that this projection does resolve some metastability in both ICs.\n",
526+
"TICA, by default, uses a lag time of $10$ steps, kinetic mapping and a kinetic variance cutoff of $95\\%$ to determine the number of ICs. We observe that this projection does resolve some metastability in both ICs. Whether these projections are suitable for building Markov state models, though, remains to be seen in later tests.\n",
527+
"\n",
528+
"As we discussed in the first example, the physical meaning of the TICA projection is not directly clear. We can analyze the feature TIC correlation as we did above:"
529+
]
530+
},
531+
{
532+
"cell_type": "code",
533+
"execution_count": null,
534+
"metadata": {},
535+
"outputs": [],
536+
"source": [
537+
"fig, ax = plt.subplots(figsize=(3, 8))\n",
538+
"i = ax.imshow(tica.feature_TIC_correlation, cmap='bwr')\n",
539+
"\n",
540+
"ax.set_xticks(range(tica.dimension()))\n",
541+
"ax.set_xlabel('IC')\n",
542+
"\n",
543+
"ax.set_yticks(range(feat.dimension()))\n",
544+
"ax.set_yticklabels(feat.describe())\n",
545+
"ax.set_ylabel('input feature')\n",
546+
"\n",
547+
"fig.colorbar(i);"
548+
]
549+
},
550+
{
551+
"cell_type": "markdown",
552+
"metadata": {},
553+
"source": [
554+
"This is not very helpful as it only shows that some of our $x, y, z$-coordinates correlate with the TICA components. Since we rather expect the slow processes to happen in backbone torsion space, this comes to no surprise. \n",
555+
"\n",
556+
"To understand what the TICs really mean, let us do a more systematic approach and scan through some angular features. We add some randomly chosen angles between heavy atoms and the backbone angles that we already know to be a good feature:"
557+
]
558+
},
559+
{
560+
"cell_type": "code",
561+
"execution_count": null,
562+
"metadata": {},
563+
"outputs": [],
564+
"source": [
565+
"feat_test = pyemma.coordinates.featurizer(pdb)\n",
566+
"feat_test.add_backbone_torsions(periodic=False)\n",
567+
"feat_test.add_angles(feat_test.select_Heavy()[:-1].reshape(3, 3), periodic=False)\n",
568+
"data_test = pyemma.coordinates.load(files, features=feat_test)\n",
569+
"data_test_concatenated = np.concatenate(data_test)"
570+
]
571+
},
572+
{
573+
"cell_type": "markdown",
574+
"metadata": {},
575+
"source": [
576+
"For the sake of simplicity, we use scipy's implementation of Pearson's correlation coefficient which we compute between our test features and TICA projected $x, y, z$-coordinates:"
577+
]
578+
},
579+
{
580+
"cell_type": "code",
581+
"execution_count": null,
582+
"metadata": {},
583+
"outputs": [],
584+
"source": [
585+
"from scipy.stats import pearsonr\n",
586+
"test_feature_TIC_correlation = np.zeros((feat_test.dimension(), tica.dimension()))\n",
587+
"\n",
588+
"for i in range(feat_test.dimension()):\n",
589+
" for j in range(tica.dimension()):\n",
590+
" test_feature_TIC_correlation[i, j] = pearsonr(data_test_concatenated[:, i], \n",
591+
" tica_concatenated[:, j])[0]"
592+
]
593+
},
594+
{
595+
"cell_type": "code",
596+
"execution_count": null,
597+
"metadata": {},
598+
"outputs": [],
599+
"source": [
600+
"vm = abs(test_feature_TIC_correlation).max()\n",
601+
"\n",
602+
"fig, ax = plt.subplots()\n",
603+
"i = ax.imshow(test_feature_TIC_correlation, vmin=-vm, vmax=vm, cmap='bwr')\n",
529604
"\n",
530-
"Whether these projections are suitable for building Markov state models, though, remains to be seen in later tests.\n",
605+
"ax.set_xticks(range(tica.dimension()))\n",
606+
"ax.set_xlabel('IC')\n",
607+
"\n",
608+
"ax.set_yticks(range(feat_test.dimension()))\n",
609+
"ax.set_yticklabels(feat_test.describe())\n",
610+
"ax.set_ylabel('input feature')\n",
611+
"\n",
612+
"fig.colorbar(i);"
613+
]
614+
},
615+
{
616+
"cell_type": "markdown",
617+
"metadata": {},
618+
"source": [
619+
"From this simple analysis, we find that features that correlated most with our TICA projection are indeed the backbone torsion angles used previously. We might thus expect the dynamics in TICA space to be similar to the one in backbone torsion space. Please note that in general, we do not know which feature would be a good observable. Thus, a realistic scenario might require a much broader scan of a large set of different features.\n",
620+
"\n",
621+
"However, it should be mentioned that TICA projections do not necessarily have a simple physical interpretation. The above analysis might very well end with feature TIC correlations that show no significant contributor and rather hint towards a complicated linear combination of input features.\n",
622+
"\n",
623+
"As an alternative to understanding the projection in detail at this stage, one might go one step further and extract representative structures e.g. from an MSM, as shown in [Notebook 05 📓](05-pcca-tpt.ipynb).\n",
531624
"\n",
532625
"#### Exercise 3: PCA parameters\n",
533626
"\n",
@@ -667,7 +760,15 @@
667760
"\n",
668761
"## Case 3: another molecular dynamics data set (pentapeptide)\n",
669762
"\n",
670-
"We fetch the pentapeptide data set, load several different input features into memory and perform a VAMP estimation/scoring of each. Since we want to evaluate the VAMP score on a disjoint test set, we split the available files into a train and test set."
763+
"Before we start to load and discretize the pentapeptide data set, let us discuss what the difficulties with larger protein systems are. The goal of this notebook is to find a state space discretization for MSM estimation. This means that an algorithm such as $k$-means has to be able to find a meaningful state space partitioning. In general, this works better in lower dimensional spaces because Euclidean distances become less meaningful with increasing dimensionality <a id=\"ref-4\" href=\"#cite-aggarwal_surprising_2001\">aggarwal-01</a>. The modeler should be aware that a discretization of hundreds of dimensions will be computationally expensive and most likely yield unsatisfactory results. \n",
764+
"\n",
765+
"The first goal is thus to map the data to a reasonable number of dimensions, e.g. with a smart choice of features and/or by using TICA. Large systems often require significant parts of the kinetic variance to be discarded in order to obtain a balance between capturing as much of the kinetic variance as possible and achieving a reasonable discretization.\n",
766+
"\n",
767+
"Another point about discretization algorithms is that one should bear in mind the distribution of density. The $k$-means algorithm tends to conserve density, i.e. data sets that incorporate regions of extremely high density as well as poorly sampled regions might be problematic, especially in high dimensions. For those cases, a regular spatial clustering might be worth a try. \n",
768+
"\n",
769+
"More details on problematic data situations and how to cope with them are explained in [Notebook 08 📓](08-common-problems.ipynb).\n",
770+
"\n",
771+
"Now, we fetch the pentapeptide data set, load several different input features into memory and perform a VAMP estimation/scoring of each. Since we want to evaluate the VAMP score on a disjoint test set, we split the available files into a train and test set."
671772
]
672773
},
673774
{
@@ -1036,9 +1137,7 @@
10361137
" ax.scatter(*cluster.clustercenters[:, [i, j]].T, s=15, c='C1')\n",
10371138
" ax.set_xlabel('IC {}'.format(i + 1))\n",
10381139
" ax.set_ylabel('IC {}'.format(j + 1))\n",
1039-
"fig.tight_layout()\n",
1040-
"\n",
1041-
"## Wrapping up"
1140+
"fig.tight_layout()"
10421141
]
10431142
},
10441143
{

notebooks/03-msm-estimation-and-validation.ipynb

+12-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@
140140
"source": [
141141
"We can see a perfect agreement between models estimated at higher lag times and predictions of the model at lag time $1$ step. Thus, we have estimated a valid MSM according to basic model validation.\n",
142142
"\n",
143-
"Should a CK test fail, it means that the dynamics in the space of metastable states is not Markovian. This can have multiple reasons since it is the result of the combination of all steps in the pipeline. In practice, one would attempt to find a better model by tuning hyper-parameters such as the number of metastable states, the MSM lag time or the number of cluster centers. Back-tracking the error by following the pipeline in an upstream direction is usually advised. A failing CK test might further hint at poor sampling.\n",
143+
"Should a CK test fail, it means that the dynamics in the space of metastable states is not Markovian. This can have multiple causes since it is the result of the combination of all steps in the pipeline. In practice, one would attempt to find a better model by tuning hyper-parameters such as the number of metastable states, the MSM lag time or the number of cluster centers. Back-tracking the error by following the pipeline in an upstream direction, i.e. by starting with the number of metastable states, is usually advised. \n",
144+
"\n",
145+
"A failing CK test might further hint at poor sampling. This case is explained in more detail in [Notebook 08 📓](08-common-problems.ipynb#poorly_sampled_dw).\n",
144146
"\n",
145147
"## Case 2: low-dimensional molecular dynamics data (alanine dipeptide)\n",
146148
"We fetch the alanine dipeptide data set, load the backbone torsions into memory and directly discretize the full space using $k$-means clustering. In order to demonstrate how to adjust the MSM lag time, we will first set the number of cluster centers to $200$ and justify this choice later."
@@ -238,7 +240,15 @@
238240
"source": [
239241
"We can see from this analysis that the ITS curves indeed converge towards the $200$ centers case and we can continue with estimating/validating an MSM.\n",
240242
"\n",
241-
"We estimate an MSM at lag time $10$ ps and, given that we have three slow processes, perform a CK test for four metastable states. In general, the number of metastable states is a modeler's choice and will be explained in further notebooks."
243+
"Before we continue with MSM estimation, let us discuss implied timescales convergence for large systems. Given sufficient sampling, the task is often to find a discretization that captures the process of interest well enough to obtain implied timescales that converge within the trajectory length. \n",
244+
"\n",
245+
"As we see in the above example with $k=20$ cluster centers, increasing the MSM lag time compensates for poor discretization to a certain extent. In a more realistic system, however, trajectories have a finite length that limits the choice of our MSM lag time. Furthermore, our clustering might be worse than the one presented above, so convergence might not be reached at all. Thus, we aim to converge the implied timescales at a low lag time by fine-tuning not only the number of cluster centers, but also feature selection and dimension reduction measures. This additionally ensures that our model has the maximum achievable temporal resolution.\n",
246+
"\n",
247+
"Please note that choosing an appropriate MSM lag time variationally (e.g. using VAMP scoring) is as far as we know not possible.\n",
248+
"\n",
249+
"Further details on how to account for poor discretization can be found in our notebook about hidden Markov models [Notebook 07 📓](07-hidden-markov-state-models.ipynb). An example on how implied timescales behave in the limit of poor sampling is shown in [Notebook 08 📓](08-common-problems.ipynb).\n",
250+
"\n",
251+
"Now, let's continue with the alanine dipeptide system. We estimate an MSM at lag time $10$ ps and, given that we have three slow processes, perform a CK test for four metastable states. In general, the number of metastable states is a modeler's choice and will be explained in further notebooks."
242252
]
243253
},
244254
{

0 commit comments

Comments
 (0)