skbio.stats.distance.
pwmantel
(dms, labels=None, method='pearson', permutations=999, alternative='twosided', strict=True, lookup=None)[source]¶Run Mantel tests for every pair of given distance matrices.
State: Experimental as of 0.4.0.
Runs a Mantel test for each pair of distance matrices and collates the
results in a DataFrame
. Distance matrices do not need to be in the same
ID order if they are DistanceMatrix
instances. Distance matrices will
be reordered prior to running each pairwise test, and if strict=False
,
IDs that don’t match between a pair of distance matrices will be dropped
prior to running the test (otherwise a ValueError
will be raised if
there are nonmatching IDs between any pair of distance matrices).
Parameters:  dms : iterable of DistanceMatrix objects, array_like objects, or filepaths
labels : iterable of str or int, optional
method : {‘pearson’, ‘spearman’}
permutations : int, optional
alternative : {‘twosided’, ‘greater’, ‘less’}
strict : bool, optional
lookup : dict, optional


Returns:  pandas.DataFrame

See also
Notes
Passing a list of filepaths can be useful as it allows for a smaller amount of memory consumption as it only loads two matrices at a time as opposed to loading all distance matrices into memory.
Examples
Import the functionality we’ll use in the following examples:
>>> from skbio import DistanceMatrix
>>> from skbio.stats.distance import pwmantel
Define three 3x3 distance matrices:
>>> x = DistanceMatrix([[0, 1, 2],
... [1, 0, 3],
... [2, 3, 0]])
>>> y = DistanceMatrix([[0, 2, 7],
... [2, 0, 6],
... [7, 6, 0]])
>>> z = DistanceMatrix([[0, 5, 6],
... [5, 0, 1],
... [6, 1, 0]])
Run Mantel tests for each pair of distance matrices (there are 3 possible pairs):
>>> pwmantel((x, y, z), labels=('x', 'y', 'z'),
... permutations=0)
statistic pvalue n method permutations alternative
dm1 dm2
x y 0.755929 NaN 3 pearson 0 twosided
z 0.755929 NaN 3 pearson 0 twosided
y z 0.142857 NaN 3 pearson 0 twosided
Note that we passed permutations=0
to suppress significance tests; the
pvalues in the output are labelled NaN
.