calour.amplicon_experiment.AmpliconExperiment.sort_by_data

AmpliconExperiment.sort_by_data(axis=0, subset=None, key='log_mean', inplace=False, reverse=False, **kwargs)[source]

Sort features based on their mean frequency.

Sort the 2-d array by sample (axis=0) or feature (axis=0). key will be applied to subset of each feature (axis=0) or sample (axis=1) and return a comparative value.

Parameters:
  • axis (0, 1, 's', or 'f') – Apply key function on row (sort the samples) (0 or ‘s’) or column (sort the features) (1 or ‘f’)
  • subset (None, boolean mask, slice, or int indices, optional) – Sorting using only subset of the data. The subsetting occurs on the opposite of the specified axis. Default is to use the whole data set.
  • key (str or callable) –

    If it is a callable, it should be a function accepts 1-D array of numeric and returns a comparative value (like key in builtin sorted(). For example, you can use numpy.mean() or numpy.media(). Alternatively it accepts the following strings:

    • ’log_mean’: sort by the mean of the log;
    • ’prevalence’: sort by the prevalence;
  • inplace (bool, optional) – False (default) to create a copy. True to modify in place.
  • reverse (bool, optional) – True to reverse the order of the sort. Similar to sorted()
  • kwargs (dict) – keyword parameters passed to key
Returns:

Return type:

Experiment