lib5c.util.grouping module¶
Module for constructing groups of points with particular properties.
-
lib5c.util.grouping.
group_obs_by_exp
(obs, exp, num_groups=100, group_fractional_tolerance=0.1, log=True, min_group_count=2, exclude_offdiagonals=5)[source]¶ Groups observed points according to their expected values.
Parameters: - obs (np.ndarray or dict of np.ndarray) – Vector, matrix, or counts dict of observed values.
- exp (np.ndarray or dict of np.ndarray) – Vector, matrix, or counts dict of expected values.
- num_groups (int) – The number of groups to make.
- group_fractional_tolerance (float) – The width of each group, specified as a fractional tolerance in the expected value.
- log (bool) – Pass True to space the groups out logarithmically.
- min_group_count (int) – Discard groups that have fewer than this many values in them.
- exclude_offdiagonals (int) – If obs and exp are not already vectors, discard this many off-diagonals from their square matrices before flattening. Pass 0 to exclude only the exact diagonal, and pass -1 to exclude nothing.
Returns: The first array contains the expected values chosen as the centers of the groups. The list contains each group as an array of observed values.
Return type: np.ndarray, list of np.ndarray