calour.transforming.subsample_count

calour.transforming.subsample_count(exp: calour.experiment.Experiment, total, replace=False, inplace=False, random_seed=None)[source]

Randomly subsample each sample to the same number of counts.

Warning

This function will change the Experiment.data object from sparse to dense. The input Experiment object should not have been normalized by total sum and its data should be discrete count. The samples that have few total count than total will be dropped.

Note

This function may not work on Windows OS. It relies on the skbio.stats.subsample_counts() which have ValueError: Buffer dtype mismatch, expected ‘int64_t’ but got ‘long’ in _subsample_counts_without_replacement function of skbio/stats/__subsample.pyx

Note

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

Parameters:
  • exp (Experiment) – Input experiment object.
  • total (int, optional) – cap the tiny values and then clr transform the data.
  • replace (bool, optional) – If True, subsample with replacement. If False (the default), subsample without replacement
  • inplace (bool, optional) – False (default) to create a new experiment, True to do it in place
  • random_seed (int or None, optional, default=None) – passed to numpy.random.seed()
Returns:

The subsampled experiment.

Return type:

Experiment

See also

skbio.stats.subsample_counts()