skbio.stats.distance.
DissimilarityMatrix
(data, ids=None)[source]¶Store dissimilarities between objects.
A DissimilarityMatrix instance stores a square, hollow, two-dimensional matrix of dissimilarities between objects. Objects could be, for example, samples or DNA sequences. A sequence of IDs accompanies the dissimilarities.
Methods are provided to load and save dissimilarity matrices from/to disk, as well as perform common operations such as extracting dissimilarities based on object ID.
data (array_like or DissimilarityMatrix) – Square, hollow, two-dimensional numpy.ndarray
of dissimilarities
(floats), or a structure that can be converted to a numpy.ndarray
using numpy.asarray
or a one-dimensional vector of dissimilarities
(floats), as defined by scipy.spatial.distance.squareform. Can
instead be a DissimilarityMatrix (or subclass) instance,
in which case the instance’s data will be used.
Data will be converted to a float dtype
if necessary. A copy will
not be made if already a numpy.ndarray
with a float dtype
.
ids (sequence of str, optional) – Sequence of strings to be used as object IDs. Must match the number of
rows/cols in data. If None
(the default), IDs will be
monotonically-increasing integers cast as strings, with numbering
starting from zero, e.g., ('0', '1', '2', '3', ...)
.
See also
DistanceMatrix
, scipy.spatial.distance.squareform
Notes
The dissimilarities are stored in redundant (square-form) format 1.
The data are not checked for symmetry, nor guaranteed/assumed to be symmetric.
References
Attributes
|
Transpose of the dissimilarity matrix. |
|
Array of dissimilarities. |
|
|
|
Data type of the dissimilarities. |
|
Tuple of object IDs. |
|
Display heatmap in IPython Notebook as PNG. |
|
Two-element tuple containing the dissimilarity matrix dimensions. |
|
Total number of elements in the dissimilarity matrix. |
|
Display heatmap in IPython Notebook as SVG. |
Built-ins
Check if the specified ID is in the dissimilarity matrix. |
|
Compare this dissimilarity matrix to another for equality. |
|
Slice into dissimilarity data by object ID or numpy indexing. |
|
Determine whether two dissimilarity matrices are not equal. |
|
Return a string representation of the dissimilarity matrix. |
Methods
|
Obtain the distances between the two groups of IDs |
|
Return a deep copy of the dissimilarity matrix. |
|
Filter the dissimilarity matrix by IDs. |
|
Create DissimilarityMatrix from an iterable given a metric. |
|
Return the index of the specified ID. |
|
Creates a heatmap of the dissimilarity matrix |
|
Create a new |
Return an array of dissimilarities in redundant format. |
|
Create a |
|
Return the transpose of the dissimilarity matrix. |
|
|
Obtain all the distances among the set of IDs |
|
Write an instance of |