wepy.analysis.transitions module

Collection of routines for counting transitions and calculating transition probability matrices.

There are two basic data structures used in this module for edge transitions: dictionary based and matrix based.

The dictionary based approach is used to interface with graph representations, like in the ~wepy.analysis.network.MacroStateNetwork~.

Arrays are used as an interface to numerical libraries which use this to calculate other properties such as steady-state probabilities.

Wepy is primarily meant to support expedient data structuring and will not support the latter numerical calculations and is left up to external libraries and domain specific code.

Routines

transition_countsGiven a structured array of assignments of

microstate to macrostate labels and a listing of all kinetic transitions over the microstates returns the counts of transitions between each macrostate as a dictionary mapping macrostate transition edges to the total counts each microstate transition.

counts_d_to_matrixConverts a dictionary mapping macrostate

transition edges to a asymmetric transition matrix.

normalize_countsNormalizes outgoing transition counts from each

macrostate to 1 for a transition counts matrix.

transition_counts_matrixGiven a structured array of assignments of

microstate to macrostate labels and a listing of all kinetic transitions over the microstates returns the counts of transitions between each macrostate as an assymetric transition counts matrix.

transition_probability_matrixGiven a structured array of assignments of

microstate to macrostate labels and a listing of all kinetic transitions over the microstates returns the probability of transitions between each macrostate as an assymetric transition probability matrix.

run_transition_counts_matrixGenerates an asymmetric transition

counts matrix directly from a single WepyHDF5 run.

run_transition_probability_matrixGenerates an asymmetric transition

probability matrix directly from a single WepyHDF5 run.

wepy.analysis.transitions.transition_counts(assignments, transitions, weights=None)[source]

Make a dictionary of the count of microstate transitions between macrostates.

If weights are given counts are the weight instead of 1.

Parameters
  • assignments (mixed array_like of dim (n_run, n_traj, n_cycle) type int) – Assignment of microstates to macrostate labels, where N_runs is the number of runs, N_traj is the number of trajectories, and N_cycle is the number of cycles.

  • transitions (list of list of tuples of ints (run_idx, traj_idx, cycle_idx)) – List of run traces corresponding to transitions. Only the first and last trace elements are used.

  • weights (mixed array_like of dim (n_run, n_traj, n_cycle) type float or None) –

    Same shape as the assignments, but gives the weight of the walker at this time.

    (Optional)

Returns

transition_counts – Dictionary mapping transitions between macrostate labels to the count of microstate transitions between them. If weights are given this is the weighted counts.

Return type

dict of (int, int): int

wepy.analysis.transitions.counts_d_to_matrix(counts_d)[source]

Convert a dictionary of counts for macrostate transitions to an assymetric transitions counts matrix.

Parameters

counts_d (dict of (int, int): int) – Dictionary mapping transitions between macrostate labels to the count of microstate transitions between them. The first value is the ‘source’ node and the second value is the ‘target’ node of a directed graph.

Returns

counts_matrix – Assymetric counts matrix of dim (n_macrostates, n_macrostates). The 0-th axis corresponds to the ‘source’ node and the 1-st axis corresponds to the ‘target’ nodes, i.e. the dimensions mean: (source, target).

Return type

numpy.ndarray of int

wepy.analysis.transitions.normalize_counts(transition_counts_matrix)[source]

Normalize the macrostate outgoing transition counts to 1.0 for each macrostate.

Parameters

transition_counts_matrix (numpy.ndarray of int) – Assymetric counts matrix of dim (n_macrostates, n_macrostates).

Returns

transition_probability_matrix – Assymetric transition probability matrix of dim (n_macrostates, n_macrostates).

Return type

numpy.ndarray of float

wepy.analysis.transitions.transition_counts_matrix(assignments, transitions)[source]

Make an asymmetric array of the count of microstate transitions between macrostates.

Parameters
  • assignments (mixed array_like of dim (n_run, n_traj, n_cycle) type int) – Assignment of microstates to macrostate labels, where N_runs is the number of runs, N_traj is the number of trajectories, and N_cycle is the number of cycles.

  • transitions (list of list of tuples of ints (run_idx, traj_idx, cycle_idx)) – List of run traces corresponding to transitions. Only the first and last trace elements are used.

Returns

transition_counts_matrix – Assymetric counts matrix of dim (n_macrostates, n_macrostates).

Return type

numpy.ndarray of int

wepy.analysis.transitions.transition_probability_matrix(assignments, transitions)[source]

Make an asymmetric array of macrostates transition probabilities from microstate assignments.

Parameters
  • assignments (mixed array_like of dim (n_run, n_traj, n_cycle) type int) – Assignment of microstates to macrostate labels, where N_runs is the number of runs, N_traj is the number of trajectories, and N_cycle is the number of cycles.

  • transitions (list of list of tuples of ints (run_idx, traj_idx, cycle_idx)) – List of run traces corresponding to transitions. Only the first and last trace elements are used.

Returns

transition_probability_matrix – Assymetric transition probability matrix of dim (n_macrostates, n_macrostates).

Return type

numpy.ndarray of float

wepy.analysis.transitions.run_transition_counts_matrix(wepy_hdf5, run_idx, assignment_key, transitions)[source]

Generates an asymmetric transition counts matrix directly from a single WepyHDF5 run.

Parameters
  • wepy_hdf5 (WepyHDF5 object) –

  • run_idx (int) –

  • assignment_key (str) – Field from trajectory data to use as macrostate label.

  • transitions (list of list of tuples of ints (run_idx, traj_idx, cycle_idx)) – List of run traces corresponding to transitions. Only the first and last trace elements are used.

Returns

transition_counts_matrix – Assymetric counts matrix of dim (n_macrostates, n_macrostates).

Return type

numpy.ndarray of int

wepy.analysis.transitions.run_transition_probability_matrix(wepy_hdf5, run_idx, assignment_key, transitions)[source]

Generates an asymmetric transition counts matrix directly from a single WepyHDF5 run.

Parameters
  • wepy_hdf5 (WepyHDF5 object) –

  • run_idx (int) –

  • assignment_key (str) – Field from trajectory data to use as macrostate label.

  • transitions (list of list of tuples of ints (run_idx, traj_idx, cycle_idx)) – List of run traces corresponding to transitions. Only the first and last trace elements are used.

Returns

transition_probability_matrix – Assymetric transition probability matrix of dim (n_macrostates, n_macrostates).

Return type

numpy.ndarray of float