pcntoolkit.util.data_utils#
Utilities for data operations.
This module is the shared home for programming operations (e.g., from NumPy, pandas, xarray, itertools packages). The goal is to keep the main codebase focused on Bayesian statistics while moving reusable programming operations to a shared utility module.
Functions#
|
Yield batch-effect combinations together with observation masks. |
Module Contents#
- iter_batch_combinations(batch_values: numpy.ndarray, unique_batch_effects: dict[str, list[str | int]], batch_dims: list[str]) Generator[tuple[dict[str, str | int], numpy.ndarray]]#
Yield batch-effect combinations together with observation masks.
- Parameters:
batch_values (
np.ndarray) – Observed batch-effect values with shape(n_observations, n_batch_dims).unique_batch_effects (
dict[str,list[str | int]]) – Allowed values for each batch-effect dimension.batch_dims (
list[str]) – Ordered batch-effect dimensions used to interpret bothbatch_valuesandunique_batch_effects.
- Yields:
tuple[dict[str,str | int],np.ndarray]– A dictionary describing one batch-effect combination and a boolean mask that selects observations in that combination.- Raises:
KeyError – If
unique_batch_effectsis missing a requested batch dimension.