calour.filtering.filter_by_metadata

calour.filtering.filter_by_metadata(exp: calour.experiment.Experiment, field, select, axis=0, negate=False, inplace=False)[source]

Filter samples or features by metadata.

Note

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

Parameters:
  • exp (Experiment) – Input experiment object.
  • field (str) – the column name of the sample or feature metadata tables
  • select (None, Callable, or list/set/tuple-like) – select what to keep based on the value in the specified field. if it is a callable, it accepts a 1D array and return a boolean array of the same length; if it is a list/set/tuple-like object, keep the samples with the values in the field column included in the select; if it is None, filter out the NA.
  • axis (0, 1, 's', or 'f', optional) – the field is on samples (0 or ‘s’) or features (1 or ‘f’) metadata
  • negate (bool, optional) – discard instead of keep the select if set to True
  • inplace (bool, optional) – do the filtering on the original Experiment object or a copied one.
Returns:

the filtered object

Return type:

Experiment