python中的p值调整Mann-Whitney U检验 [英] p -value adjustment Mann-Whitney U test in python
问题描述
我有一个二维列表文件(名称-'hcl_file').为了清楚起见,该文件的缩写版本.垂直观测,水平实验编号:
I have a two-dimensional list file(name - 'hcl_file'). A shortened version of the file for clarity. Vertical-observations, horizontal-experiment number:
ID type First Second Third
gerg I 0.02695 0 0.00135 0.31312
11P I 0.02695 0 0.00135 0.31312
112HP II 0.02695 0 0.00135 0.31312
1454HP II 0.02695 0 0.00135 0.31312
11544H III 0.02695 0 0.00135 0.31312
657BF III 0.02695 0 0.00135 0.31312
785DS III 0.02695 0 0.00135 0.31312
我是编程新手.您能否告诉我如何计算出I,II,III型之间差异的显着性,然后进行BH(Bennamini和Hochbberg)调整?为避免误解,让我澄清一下,我们正在对不同的组(I,II,III)进行实验,并找到它们的p值,然后对需要调整p值以进行多次比较的其他数据重复此操作.我很难周期性地执行此操作,请告知进一步运动的方向.我的脚本:
I'm new to programming. Could you please tell me how I can calculate the significance of the differences between the type I,II,III, and then make an BH(Bennamini and Hochbberg) adjustment ? To avoid misunderstandings, let me clarify that we are conducting an experiment for different groups(I,II,III) and find the p-value for them, but then we repeat this for other data that requires adjustment of p-value for multiple comparisons. I have difficulty doing this in a cycle, please advise the direction of further movement. My script:
对于hcl_file中的行:
for line in hcl_file:
substrings = (len(line))
而j<子字符串:
while j < substrings:
k1 = [] # list of values in I-st group
k2 = [] II
k3 = [] III
for line in hcl_file:
if line[1] == 'I':
v1 = float(line[j])
k1.append(v1)
elif line[1] == 'II':
v2 = float(line[j])
k2.append(v2)
elif line[1] == 'III':
v3 = float(line[j])
k3.append(v3)
import pandas
from scipy.stats import mannwhitneyu
print(mannwhitneyu(k1, k2))
j += 1
推荐答案
如果您要使用熊猫,也可以使用熊猫加载数据.
If you're gonna use pandas, use pandas to load the data too.
import pandas
from scipy.stats import mannwhitneyu
hcl_data = pandas.read_table(hcl_file, sep="\t")
print(mannwhitneyu(hcl_data.loc[hcl_data['type'] == "II"], hcl_data.loc[hcl_data['type'] == "III"]))
我不确定您要测试哪些列,因此我无法更具体地说明.在将数据传递给scipy之前,您可能需要先将其弄平.
I'm not entirely sure which columns you're trying to test so I can't be more specific. You might need to flatten the data before you pass it to scipy.
这篇关于python中的p值调整Mann-Whitney U检验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!