choderalab / pymbar

Python implementation of the multistate Bennett acceptance ratio (MBAR)
http://pymbar.readthedocs.io
MIT License
240 stars 93 forks source link

Unreasonable fes.generate_fes KeyError #531

Open cecilia-hong opened 6 months ago

cecilia-hong commented 6 months ago

In the umbrella_sampling.py when I try to run the following:

fes.generate_fes(u_kn, chi_n, fes_type="histogram", histogram_parameters=histogram_parameters) on my data, I get this error:

KeyError: (0,)

It was unclear what the problem was but I have gotten it down to the fact that some of the bins for making the histograms were empty and instead of plotting a 0 height bin, I got the above error.

Is fixing range and number of bins used for my analysis the correct fix or should the program figure this out itself?

mrshirts commented 6 months ago

Just checking - did you modify the code or data, or is this running the precise example provided? Thanks!

cecilia-hong commented 6 months ago

Hi, so when I run the example on the data provided it was fine so I used the same script for my data and only edited things like:

Up until the fes.generate_fes part everything looked fine and similar to that of the examples

mrshirts commented 6 months ago

Ah, OK, so really, this is probably about improving the error handling when some of the bins are empty.

What I would say is 1) longer term, I need to look into providing better error messages, and 2) short, term, you should either use fewer bins (note that the number of BINS and BIASED SIMULATIONS are completely separate - you only need to adjust the number of bins in the REPRESENTATION of the PMF, not in the generation of data), or you could go back and add additional biased simulations so that the area where the bin was empty has samples. OR also use kernel density representation of the PMF instead.

TODO @mrshirts: improve error handling when bins are empty!

Lnaden commented 6 months ago

This might be a bug related to #511 (with #502) and #528. @mrshirts can you check those over and see if the report there and see if the proposed solutions look good for resolving this?

cecilia-hong commented 6 months ago

Thank you for your help! :)