calour.filtering.filter_by_data

calour.filtering.filter_by_data(exp: calour.experiment.Experiment, predicate, axis=1, field=None, negate=False, inplace=False, **kwargs)[source]

Filter samples or features by the data matrix.

Note

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

Parameters:
  • exp (Experiment) – Input experiment object.
  • predicate (str or callable) –

    The callable accepts a list of numeric and return a bool. Alternatively it also accepts the following strings to filter along the specified axis:

    • ’abundance’: calls is_abundant(), filter by abundance;
    • ’prevalence’: calls is_prevalent(), filter by prevalence;
    • ’freq_ratio’: calls freq_ratio(), filter if there is a dominant unique value;
    • ’unique_cut’: calls unique_cut(), filter by how diversified the values.
  • axis (0, 1, 's', or 'f', optional) – Apply predicate on each row (ie samples) (0, ‘s’) or each column (ie features) (1, ‘f’)
  • field (str or None, optional) – The column in the sample_metadata (or feature_metadata, depending on axis). If it is None, the predicate operates on the whole data set; if it is not None, the data set is divided into groups according to the sample_metadata (feature_metadata) column and the predicate operates on each partition of data - only the features (or samples) that fail to pass every partition will be filtered away.
  • negate (bool) – negate the predicate for selection
  • kwargs (dict) – keyword argument passing to predicate function.
Returns:

the filtered object

Return type:

Experiment