Skip to content
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

Back-jump probability and survival function #184

Merged
merged 35 commits into from
Oct 26, 2023

Conversation

andthum
Copy link
Owner

@andthum andthum commented Oct 26, 2023

Back-jump probability and survival function

Type of change

  • Change of core package.
  • Change of scripts.
  • Bug fix.
  • New feature.
  • Code refactoring.
  • Dependency update.
  • Documentation update.
  • Maintenance.
  • Other: Description.
  • Non-breaking (backward-compatible) change.
  • Breaking (non-backward-compatible) change.

Proposed changes

Breaking changes

  • Remove the script scripts/discretization/state_probs_around_trans.py, because its core functionality is now covered by the scripts scripts/discretization/back_jump_prob.py and scripts/discretization/kaplan_meier.py.

Bug fixes

  • Scripts sripts/discretization/state_lifetime.py and sripts/discretization/state_lifetime_discrete.py: Calculate the transition information of the discrete trajectory after the trajectory was corrected for intermittency.

New features

New scripts

  • Create new scripts scripts/discretization/back_jump_prob.py and scripts/discretization/back_jump_prob_discrete.py that calculate the probability to return back to the initial state after a state transition as function of the time that has passed since the state transition.
  • Create new scripts scripts/discretization/kaplan_meier.py and scripts/discretization/kaplan_meier_discrete.py that calculate the state survival function using the Kaplan-Meier estimator.

New functions

  • Create a functions mdtools.dtrj.back_jump_prob and mdtools.dtrj.back_jump_prob_discrete that take a discrete trajectory and calculate the probability to return back to the initial state at time t0+dt, given that a state transition has occurred at time t0.
  • Create a function mdtools.dtrj.kaplan_meier and mdtools.dtrj.kaplan_meier_discrete that estimate the state survival function using the Kaplan-Meier estimator.
  • Create a functions mdtools.dtrj.leave_prob and mdtools.dtrj.leave_prob_discrete that take a discrete trajectory and calculate the probability that a compound leaves its state at time t0+dt given that it has entered the state at time t0.
  • Create a functions mdtools.dtrj.n_leaves_vs_time and mdtools.dtrj.n_leaves_vs_time_discrete that take a discrete trajectory and calculate the total number of compounds that leave their state at time t0+dt given that they have entered the state at time t0.

PR checklist

  • I followed the guidelines in the Developer's guide.
  • New/changed code is properly tested.
  • New/changed code is properly documented.
  • The CI workflow is passing.

* Finish the docstring.
* Minor code refactoring.
* Format code, comments and docstrings.
Removed calculations:

* `prob_same_sym`: Probability that a compound is at time t0-dt in the
  same state as at time t0+dt.

Added calculation:

* `prob_b_as_b_con`: Probability that a compound is from time t0-dt
  until t0 *continuously* in the same state.
* `prob_b_as_a_con`: Probability that a compound is at time t0-dt in the
  same state as directly after the state transition under the condition
  that it has *continuously* been in the same state as directly before
  the state transition from time t0-dt until t0.

* `prob_a_as_a_con`: Probability that a compound is from time t0 until
  t0+dt *continuously* in the same state
* `prob_a_as_b_con`: Probability that a compound is at time t0+dt in the
  same state as directly before the state transition under the condition
  that it has *continuously* been in the same state as directly after
  the state transition during the time t0+dt

* `prob_back`: Probability that a compound returns at time t0+dt back to
  the same state as directly before the state transition
* `prob_back_con`: Probability that a compound returns at time t0+dt
  back to the same state as directly before the state transition under
  the condition that it has *continuously* been in the same state as
  directly after the state transition from time t0 until t0+dt
Create a new function `mdtools.dtrj.back_jump_prob` that takes a
discrete trajectory and calculates the probability to return back to the
initial state at time t0+dt, given that a state transition has occurred
at time t0.
Create a new function `mdtools.dtrj.back_jump_prob_discrete` that takes
a discrete trajectory and calculates the probability to return back to
the initial state at time t0+dt, given that a state transition has
occurred at time t0 and given that the compound was in a specific state
of another discrete trajectory at time t0.
Create a new script `scripts/discretization/back_jump_prob.py` that
calculates the probability to return back to the initial state after a
state transition as function of the time that has passed since the state
transition.
Create a new script `scripts/discretization/back_jump_prob_discrete.py`
that calculates the probability to return back to the initial state
after a state transition as function of the time that has passed since
the state transition given that the compound was in a specific state of
another discrete trajectory at the time of the state transition.
Create a new function `mdtools.dtrj.surv_func` that takes a discrete
trajectory and calculates the probability that a compound is still (or
again) in the new state at time t0+dt given that a state transition has
occurred at time t0.
Update the docstring of the function `mdtools.dtrj.remain_prob_discrete`
Create a new function `mdtools.dtrj.n_leaves_vs_time` that takes a
discrete trajectory and calculates the total number of compounds that
leave their state at time t0+dt given that they have entered the state
at time t0.

Additionally, it calculates the number of compounds that are at risk to
leave the state at time t0+dt, i.e. the number of compounds that have
continuously been in the state from time t0 to t0+dt.
Add the arguments `discard_neg_start` and `discard_all_neg` to the
function `mdtools.dtrj.n_leaves_vs_time` that allow the user to discard
negative states in the discrete trajectory in two different ways.
Create a new function `mdtools.dtrj.leave_prob` that takes a discrete
trajectory and calculates the probability that a compound leaves its
state at time t0+dt given that it has entered the state at time t0.
Create a new function `mdtools.dtrj.kaplan_meier` that estimates the
state survival function using the Kaplan-Meier estimator.
Delete the function `mdtools.dtrj.surv_func`, because it is replaced by
the more accurate Kaplan-Meier estimator of the survival function
implemented in the the function `mdtools.dtrj.kaplan_meier`.
Create a new Function `mdtools.dtrj.n_leaves_vs_time_discrete` that
takes a discrete trajectory and calculates the total number of compounds
that leave their state at time t0+dt given that they have entered the
state at time t0 and given that they were in a specific state of another
discrete trajectory at time t0.
Create a new function that takes a discrete trajectory and calculates
the probability that a compound leaves its state at time t0+dt given
that it has entered the state at time t0 and given that it was in a
specific state of another discrete trajectory at time t0.
Create a new function `mdtools.dtrj.kaplan_meier_discrete` that takes a
discrete trajectory and calculates the probability that a compound is
still in the new state at time t0+dt given that a state transition has
occurred at time t0 and given that the compound was in a specific state
of another discrete trajectory at time t0.
Add new arguments `discard_neg` and `discard_neg_btw` to the function
`mdtools.dtrj.back_jump_prob` that allow the user to ignore negative
states in two different ways.
Add new arguments `discard_neg` and `discard_neg_btw` to the function
`mdtools.dtrj.back_jump_prob_discrete` that allow the user to ignore
negative states in two different ways.
Add new command-line options `--discard-neg` and `--discard-neg-btw` to
the script `scripts/discretization/back_jump_prob.py` that allow the
user to discard negative states in different ways.
Add new command-line options `--discard-neg` and `--discard-neg-btw` to
the script `scripts/discretization/back_jump_prob_discrete.py` that
allow the user to discard negative states in different ways.
Check the format of the scripts `scripts/discretization/back_jump.py`
and `scripts/discretization/back_jump_discrete.py` with black during the
CI workflow.
Include the docstring of the scripts
`scripts/discretization/back_jump.py` and
`scripts/discretization/back_jump_discrete.py` in the official MDTools
documentation.
Extend the "See Also" section of various scripts.
Calculate the transition information of the discrete trajectory
(with `mdt.rti.dtrj_trans_info_str`) *after* the trajectory was
corrected for intermittency.
Add the command-line option `--intermittency` to the script template
`scripts/templates/script_template_dtrj.py`.
@github-actions github-actions bot added breaking Breaking changes documentation Improvements or additions to documentation labels Oct 26, 2023
@github-actions github-actions bot added enhancement New feature or request major-core Breaking change in the core package major-scripts Breaking change in one ore more scripts labels Oct 26, 2023
Create a script `scripts/discretization/kaplan_meier.py` that calculates
the state survival function using the Kaplan-Meier estimator.
Create a new script `scripts/discretization/kaplan_meier_discrete.py`
that calculates the state survival function using the Kaplan-Meier
estimator resolved with respect to the states in the second discrete
trajectory.
Include the docstrings of the scripts
`scripts/discretization/kaplan_meier.py` and
`scripts/discretization/kaplan_meier_discrete.py` in the official
MDTools documentation.
Check the format of the scripts `scripts/discretization/kaplan_meier.py`
and `scripts/discretization/kaplan_meier_discrete.py` with black during
the CI workflow.
Remove the script `scripts/discretization/state_probs_around_trans.py`,
because its core functionality is now covered by
`scripts/discretization/back_jump_prob.py` and
`scripts/discretization/kaplan_meier.py`.
@andthum andthum force-pushed the ref/scripts/discretization/state_probs_around_trans branch from 17891e6 to dec50b1 Compare October 26, 2023 16:50
@andthum andthum merged commit 67ea248 into main Oct 26, 2023
30 checks passed
@andthum andthum deleted the ref/scripts/discretization/state_probs_around_trans branch October 26, 2023 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking changes documentation Improvements or additions to documentation enhancement New feature or request major-core Breaking change in the core package major-scripts Breaking change in one ore more scripts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant