msmbuilder / msmexplorer

Data visualizations for biomolecular dynamics
http://msmbuilder.org/msmexplorer/
MIT License
17 stars 17 forks source link

plot_msm_network and plot_tpaths problems when msm is not 100% ergodic #109

Closed jeiros closed 6 years ago

jeiros commented 6 years ago

I'm trying to replicate the last figure of the Fs-Peptide notebook with an msm that is not 100% ergodic (for instance, my msm recovers an ergodic subspace of 259 microstates when my clustering was done with 500 states).

First question

This code:

pos = dict(zip(range(clusterer.n_clusters), clusterer.cluster_centers_))
_ = msme.plot_msm_network(msm, pos=pos,
                          with_labels=False)

fails with the following (long) Traceback but it does show (all?) the microstates:

download

I've also tried building an 'alternative' msm_pos dictionary using the msm.mapping_ dictionary, to see if that fixed the problem:

msm_pos = {}
for c_id, msm_id in msm.mapping_.items():
    msm_pos[msm_id] = clusterer.cluster_centers_[c_id]

but this also fails with a similar Traceback, yielding the ValueError: 'vertices' must be a 2D list or array with shape Nx2:


_ = msme.plot_msm_network(msm, pos=msm_pos,
                          with_labels=False)

download 1

Second Question

For the plot_tpath function, the sources and sinks that are provided as arguments, are they numbered with the ids from the clusterer object or the internal numbering of the msm object?

msultan commented 6 years ago

For the first try unpacking the dictionary to be a 2D array so that the first row is the position for the first state.

For the second, the sources and sinks are the mapped MSM states since the MSM object has no memory of the unmapped states. It is only concerned with the state graph that it operates on.

jeiros commented 6 years ago

Thanks @msultan ! That did the trick