msmbuilder / msmexplorer

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

plot_free_energy_2d.py fails with "ValueError: a and p must have same size" #114

Closed mabianchet closed 6 years ago

mabianchet commented 6 years ago

Greatings: When I run plot_free_energy_2d.py or any script based on it. I got the error below I am using python:

Python 3.6.2 | packaged by conda-forge | (default, Jul 23 2017, 22:59:30) [GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux msmbuilder 3.8.0 numpy 1.12.1

matplotlib.version '2.0.2'

python plot_free_energy_2d.py /home-3/mbianch1@jhu.edu/miniconda2/envs/3/lib/python3.6/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20. "This module will be removed in 0.20.", DeprecationWarning) /home-3/mbianch1@jhu.edu/miniconda2/envs/3/lib/python3.6/site-packages/sklearn/grid_search.py:42: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. This module will be removed in 0.20. DeprecationWarning) /home-3/mbianch1@jhu.edu/miniconda2/envs/3/lib/python3.6/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead. from pandas.core import datetools /home-3/mbianch1@jhu.edu/miniconda2/envs/3/lib/python3.6/site-packages/seaborn/apionly.py:6: UserWarning: As seaborn no longer sets a default style on import, the seaborn.apionly module is deprecated. It will be removed in a future version. warnings.warn(msg, UserWarning) MSM contains 2 strongly connected components above weight=0.03. Component 1 selected, with population 98.921375% Traceback (most recent call last): File "plot_free_energy_2d.py", line 41, in cbar_kwargs={'format': '%.1f', 'label': 'Free energy (kcal/mol)'} File "/home-3/mbianch1@jhu.edu/miniconda2/envs/3/lib/python3.6/site-packages/msmexplorer/utils.py", line 101, in wrapper return func(*args, **kwargs) File "/home-3/mbianch1@jhu.edu/miniconda2/envs/3/lib/python3.6/site-packages/msmexplorer/plots/projection.py", line 122, in plot_free_energy idx = random_state.choice(range(data.shape[0]), size=n_samples, p=pi) File "mtrand.pyx", line 1126, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:17641) ValueError: a and p must have same size

msultan commented 6 years ago

How are you calling the function? My guess is that your data array is not the same size as your probability pi.

msultan commented 6 years ago

The pi vector has to be the same size as the data.

mabianchet commented 6 years ago

Hi msultant hanks for your answer

The error appears running the example file of the distribution % python plot_free_energy_2d.py

msultan commented 6 years ago

Is this from the examples page?

msultan commented 6 years ago

@cxhernandez Is there some disconnectivity issue with the FS-peptide dataset?

msultan commented 6 years ago

I am not getting this error on my mac mini

python plot_free_energy_2d.py 
fs_peptide already is cached
/Users/muneeb/anaconda/lib/python3.5/site-packages/mdtraj-1.9.0.dev0-py3.5-macosx-10.6-x86_64.egg/mdtraj/formats/pdb/pdbfile.py:196: UserWarning: Unlikely unit cell vectors detected in PDB file likely resulting from a dummy CRYST1 record. Discarding unit cell vectors.
  warnings.warn('Unlikely unit cell vectors detected in PDB file likely '
loading trajectory-1.xtc...
loading trajectory-10.xtc...
loading trajectory-11.xtc...
loading trajectory-12.xtc...
loading trajectory-13.xtc...
loading trajectory-14.xtc...
loading trajectory-15.xtc...
loading trajectory-16.xtc...
loading trajectory-17.xtc...
loading trajectory-18.xtc...
loading trajectory-19.xtc...
loading trajectory-2.xtc...
loading trajectory-20.xtc...
loading trajectory-21.xtc...
loading trajectory-22.xtc...
loading trajectory-23.xtc...
loading trajectory-24.xtc...
loading trajectory-25.xtc...
loading trajectory-26.xtc...
loading trajectory-27.xtc...
loading trajectory-28.xtc...
loading trajectory-3.xtc...
loading trajectory-4.xtc...
loading trajectory-5.xtc...
loading trajectory-6.xtc...
loading trajectory-7.xtc...
loading trajectory-8.xtc...
loading trajectory-9.xtc...
/Users/muneeb/anaconda/lib/python3.5/site-packages/sklearn/cluster/k_means_.py:1279: DeprecationWarning: This function is deprecated. Please call randint(0, 279999 + 1) instead
  0, n_samples - 1, init_size)
MSM contains 1 strongly connected component above weight=0.50. Component 0 selected, with population 100.000000%
/Users/muneeb/anaconda/lib/python3.5/site-packages/numpy/ma/core.py:6385: MaskedArrayFutureWarning: In the future the default for ma.maximum.reduce will be axis=0, not the current None, to match np.maximum.reduce. Explicitly pass 0 or None to silence this warning.
  return self.reduce(a)
/Users/muneeb/anaconda/lib/python3.5/site-packages/numpy/ma/core.py:6385: MaskedArrayFutureWarning: In the future the default for ma.minimum.reduce will be axis=0, not the current None, to match np.minimum.reduce. Explicitly pass 0 or None to silence this warning.
  return self.reduce(a)
mabianchet commented 6 years ago

Dear msultant,

Shame on me, i introduced a typo in the example script that coincidentally reproduce the error in my script. A fresh copy of the script works well.

The problem was with my use of msmbuilder, changing the clustering methods fix it.

I apologize again.

cxhernandez commented 6 years ago

Glad to hear you figured out the issue!