calour.filtering.is_abundant

calour.filtering.is_abundant(data, axis, cutoff=0.01, strict=False, mean_or_sum='mean')[source]

Check if the mean or sum abundance larger than cutoff.

Can be used to keep features with means at least “cutoff” in all samples

Parameters:
  • data (numpy.ndarray or scipy.sparse.csr_matrix) –
  • axis (int) – 0 to average each column, 1 to average each row. passed to numpy.mean()
  • cutoff (float) – the mean threshold
  • strict (bool, optional) – False (default) to use mean >= cutoff; True to use mean > cutoff
  • mean_or_sum (str) – what abundance to compute: ‘mean’ or ‘sum’
Returns:

bool array with True if mean >= cutoff.

Return type:

np.ndarray

Examples

>>> is_abundant(np.array([[0, 0, 1], [1, 1, 1]]), axis=1, cutoff=0.51).tolist()
[False, True]
>>> is_abundant(np.array([0, 0, 1, 1]), axis=0, cutoff=0.5)
True
>>> is_abundant(np.array([0, 0, 1, 1]), axis=0, cutoff=0.5, strict=True)
False
>>> is_abundant(np.array([[0, 1, 1]]), axis=1, cutoff=2, mean_or_sum='sum').tolist()
[True]
>>> is_abundant(np.array([0, 1, 1]), axis=0, cutoff=2, strict=True, mean_or_sum='sum')
False
>>> is_abundant(np.array([[0, 1, 1]]), axis=1, cutoff=2.01, mean_or_sum='sum').tolist()
[False]