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'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:
for line in hcl_file:
substrings = (len(line))
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"]))
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.
来源:https://stackoverflow.com/questions/52433424/p-value-adjustment-mann-whitney-u-test-in-python