markovmodel / PyEMMA

🚂 Python API for Emma's Markov Model Algorithms 🚂
http://pyemma.org
GNU Lesser General Public License v3.0
307 stars 118 forks source link

minflux in plot_markov_model seems to be malfunctioning #1551

Closed orthonalmatrix closed 2 years ago

orthonalmatrix commented 2 years ago

Hi all, As I play with the minflux to get something easy to interpret, I've noticed that it brakes somehow. See the examples below

fig, ax = plt.subplots(figsize=(40, 20)) pyemma.plots.plot_markov_model(hmms[model], arrow_label_format = '%1.0e',
pos=pos, state_scale=0.7, arrow_scale=3.5, minflux=1e-10, state_labels=state_labels,

state_colors='yellow',

                           ax=ax);

download

fig, ax = plt.subplots(figsize=(40, 20)) pyemma.plots.plot_markov_model(hmms[model], arrow_label_format = '%1.0e',
pos=pos, state_scale=0.7, arrow_scale=3.5, minflux=2e-3, state_labels=state_labels,

state_colors='yellow',

                           ax=ax);

download

pyemma.plots.plot_markov_model(hmms[model], arrow_label_format = '%1.0e',
pos=pos, state_scale=0.7, arrow_scale=3.5, minflux=1e-3, state_labels=state_labels,

state_colors='yellow',

                           ax=ax);

download

Seems to be most predominant with the large values of the minflux.

thempel commented 2 years ago

I don't understand what is broken. If you choose a minflux that is lower than the lowest flux in your network, the plotting function does not plot any edge - if that's what you mean.

orthonalmatrix commented 2 years ago

In the second example, the minflux is 2e-3 but no lines show up. There are clearly fluxes that are larger than that (1e-2 for instance), but these do not show up. But when I reduce the minflux from 2e-3 to 1e-3 (last example) then a few more lines show up (even though less should show) but the largest lines are still left out.

In the first diagram 3-->4, 5-->4 are listed as 1e-2 and so should show up in all the next examples but do not.

thempel commented 2 years ago

The printed labels are elements of the transition matrix, but the cutoff is applied on a flux that is computed as the product of stationary distribution and transition matrix (np.dot(np.diag(stationary_distribution(P)), P)). So the cutoff is not applied on the printed values, unfortunately. If I'm not confusing things here, you have a flux f (let me assume that it's symmetric for the moment) that is both f > 1e-3 (3rd figure) and f < 2e-3 (2nd figure), i.e., 1e-3 < f < 2e-3.

When ordering the plots according to the minflux 1e-10 (Fig. 1) < 1e-3 (Fig. 3) < 2e-3 (Fig. 2), things seem to make more sense to me as we just exclude more and more links with a growing minflux: all links -> 1 link -> 0 links.

thempel commented 2 years ago

Closing this as I assume it has been resolved. Feel free to re-open.