calour.sorting.sort_abundance

calour.sorting.sort_abundance(exp: calour.experiment.Experiment, subgroup=None, **kwargs)[source]

Sort features based on their abundance in a subset of the samples.

This is a convenience wrapper for sort_by_data().

Note

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

Parameters:
  • exp (Experiment) – Input experiment object.
  • subgroup (dict or None (default)) – None (default) to sort on all samples. Subset samples by columns (specified by dict keys) in sample metadata matching the dict values (a list). sorting is only on samples matching this list
Keyword Arguments:
 
  • 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:

with features sorted by abundance

Return type:

Experiment

See also

sort_by_data()