Skip to content
Advertisement

Create a for loop of wilcoxon rank sum tests in python to generate a list of p-values?

I have a dataframe that follows this format:

JavaScript

It is much larger (it has about 1000 genes, i.e., columns). Each number corresponds to an mRNA abundance value.

I need to compare AC and SCC subtypes for each gene using the Wilcoxon rank sum test. I need to do this for every gene in my dataset, so I essentially need to do this 1000 times. Where group1 is the mRNA values for the AC subtype for a gene and group2 is the mRNA values for the SCC subtype for the same gene.

JavaScript

I need to create a for loop that will compare mRNA values using the rank sum test between two subtypes/groups: AC and SCC, and generate a list of p-values. I essentially need to do the wilcoxon rank sum test 1000 times to generate a long list of p-values that I have computed for each gene (there are 1000 of them, each column is a gene) comparing AC vs. SCC.

How can I achieve this in python? This is what I have tried with no luck.

JavaScript

print(p_vals)

I need to do something similar, but instead of calculating a p-value I need to calculate the fold-change (FC) of mean mRNA abundances between the AC and SCC subtypes for every gene (using the AC value in the numerator of FC). I need to combine gene FC and p-values from the rank sum test into a single table. In addition I also need to add to this table a column for the corrected p-values using

JavaScript
JavaScript

Advertisement

Answer

I think I have a working solution, though I’m not sure why the pvalues it returns are all the exact same. Is that a property of the data you provided?

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement