-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable MBAR to do bootstrap error estimation #322
Changes from all commits
1a853ab
8277280
ee1d4fb
fb4b659
89f855f
9cf90c7
18ded44
0ca40c4
d959393
74df776
b887659
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,10 @@ class MBAR(BaseEstimator, _EstimatorMixOut): | |
available via :func:`scipy.optimize.minimize` or | ||
:func:`scipy.optimize.root`. | ||
|
||
n_bootstraps : int, optional | ||
Whether to use bootstrap to estimate uncertainty. `0` means use analytic error | ||
estimation. 50~200 is a reasonable range to do bootstrap. | ||
|
||
verbose : bool, optional | ||
Set to ``True`` if verbose debug output from :mod:`pymbar` is desired. | ||
|
||
|
@@ -59,6 +63,8 @@ class MBAR(BaseEstimator, _EstimatorMixOut): | |
`delta_f_`, `d_delta_f_`, `states_` are view of the original object. | ||
.. versionchanged:: 2.0.0 | ||
default value for `method` was changed from "hybr" to "robust" | ||
.. versionchanged:: 2.1.0 | ||
`n_bootstraps` option added. | ||
""" | ||
|
||
def __init__( | ||
|
@@ -67,13 +73,15 @@ def __init__( | |
relative_tolerance=1.0e-7, | ||
initial_f_k=None, | ||
method="robust", | ||
n_bootstraps=0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd add a reminder comment n_bootstraps=0, # release 2.2: change to 50 (see PR #322) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So my feeling is that for the MBAR estimator, we retain the current behaviour unless people manually turn it on as bootstrap does come with a computational cost. It is only for the estimate method in workflow.ABFE where I know that the input is decorrelated and I'm prepared to pay the computational cost, I will set the default to 50. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's ok, we just can't make the default behave differently without a minimal warning period. |
||
verbose=False, | ||
): | ||
self.maximum_iterations = maximum_iterations | ||
self.relative_tolerance = relative_tolerance | ||
self.initial_f_k = initial_f_k | ||
self.method = method | ||
self.verbose = verbose | ||
self.n_bootstraps = n_bootstraps | ||
|
||
# handle for pymbar.MBAR object | ||
self._mbar = None | ||
|
@@ -108,8 +116,15 @@ def fit(self, u_nk): | |
verbose=self.verbose, | ||
initial_f_k=self.initial_f_k, | ||
solver_protocol=self.method, | ||
n_bootstraps=self.n_bootstraps, | ||
) | ||
if self.n_bootstraps == 0: | ||
uncertainty_method = None | ||
else: | ||
uncertainty_method = "bootstrap" | ||
out = self._mbar.compute_free_energy_differences( | ||
return_theta=True, uncertainty_method=uncertainty_method | ||
) | ||
out = self._mbar.compute_free_energy_differences(return_theta=True) | ||
self._delta_f_ = pd.DataFrame( | ||
out["Delta_f"], columns=self._states_, index=self._states_ | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a deprecation for using analytical error estimate as the default in ABFE, will change to using 50 bootstraps in 2.3 (see other comments)