skbio.stats.distance.pwmantel¶
- skbio.stats.distance.pwmantel(dms, labels=None, method='pearson', permutations=999, alternative='two-sided', strict=True, lookup=None)[源代码]¶
对每对给定的距离矩阵运行Mantel测试。
状态:从0.4.0开始实验。
对每对距离矩阵运行Mantel测试,并在
DataFrame
。如果距离矩阵具有相同的ID顺序,则它们不需要具有相同的ID顺序DistanceMatrix
实例。在运行每个成对测试之前,距离矩阵将重新排序,并且如果strict=False
,在运行测试之前将丢弃在距离矩阵对之间不匹配的ID(否则为ValueError
如果任何一对距离矩阵之间存在不匹配的ID,则将引发)。- 参数:
dms (iterable of DistanceMatrix objects, array_like objects, or filepaths) -- 到距离矩阵。如果他们是
array_like
,则不会执行ID的重新排序或匹配。labels (iterable of str or int, optional) -- 中每个距离矩阵的标签 dms 。这些将在结果中使用
DataFrame
以确定在成对Mantel检验中使用的距离矩阵对。如果None
,默认为从零开始的单调递增的整数。method ({'pearson', 'spearman'}) -- 相关法。看见
mantel
函数以了解更多详细信息。permutations (int, optional) -- 排列的数量。看见
mantel
函数以了解更多详细信息。alternative ({'two-sided', 'greater', 'less'}) -- 另一种假设。看见
mantel
函数以了解更多详细信息。strict (bool, optional) -- 处理不匹配的ID。看见
mantel
函数以了解更多详细信息。lookup (dict, optional) -- 将现有ID映射到新ID。看见
mantel
函数以了解更多详细信息。
- 返回:
DataFrame
包含每个配对测试的结果(每行一个)。包括每个测试中考虑的对象数作为列n
(申请后 lookup 和过滤不匹配的ID,如果strict=False
)。列p-value
将p值显示为NaN
如果无法计算p值(它们存储为np.nan
在DataFrame
;请参阅mantel
以了解更多详细信息)。- 返回类型:
备注
传递文件路径列表可能很有用,因为它一次只加载两个矩阵,而不是将所有距离矩阵加载到内存中,因此允许较少的内存消耗。
示例
导入我们将在以下示例中使用的功能:
>>> from skbio import DistanceMatrix >>> from skbio.stats.distance import pwmantel
定义三个3x3距离矩阵:
>>> 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]])
对每对距离矩阵(可能有3对)运行Mantel测试:
>>> pwmantel((x, y, z), labels=('x', 'y', 'z'), ... permutations=0) statistic p-value n method permutations alternative dm1 dm2 x y 0.755929 NaN 3 pearson 0 two-sided z -0.755929 NaN 3 pearson 0 two-sided y z -0.142857 NaN 3 pearson 0 two-sided
注意,我们通过了
permutations=0
取消显着性检验;输出中的p值被标记NaN
。