calour.filtering.downsample

calour.filtering.downsample(exp: calour.experiment.Experiment, field, axis=0, num_keep=None, inplace=False, random_state=None)[source]

Downsample the data set.

This down samples all the samples/features to have the same number of samples/features for each categorical value of the field in sample_metadata or feature_metadata.

Note

This function is also available as a class method Experiment.downsample()

Parameters:
  • exp (Experiment) – Input experiment object.
  • field (str) – The name of the column in samples metadata table. This column should has categorical values
  • axis (0, 1, 's', or 'f', optional) – 0 or ‘s’ (default) to filter samples; 1 or ‘f’ to filter features
  • num_keep (int or None, optional) – None (default) to downsample to minimal group size. int : downsample to num_keep samples/features per group, drop values with < num_keep
  • inplace (bool, optional) – False (default) to do the filtering on a copy. True to do the filtering on the original Experiment
Returns:

Return type:

Experiment