skbio.stats.distance.DistanceMatrix.filter

DistanceMatrix.filter(ids, strict=True)[source]

Filter the dissimilarity matrix by IDs.

State: Experimental as of 0.4.0.

Parameters:
  • ids (iterable of str) – IDs to retain. May not contain duplicates or be empty. Each ID must be present in the dissimilarity matrix.
  • strict (bool, optional) – If strict is True and an ID that is not found in the distance matrix is found in ids, a MissingIDError exception will be raised, otherwise the ID will be ignored.
Returns:

Filtered dissimilarity matrix containing only the IDs specified in ids. IDs will be in the same order as they appear in ids.

Return type:

DissimilarityMatrix

Raises:

MissingIDError – If an ID in ids is not in the object’s list of IDs.