calour.amplicon_experiment.AmpliconExperiment.subsample_count

AmpliconExperiment.subsample_count(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

Parameters:
  • 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()