I have data dataframe with two groups, Tumor and Normal. for each site/row i want calculate fischer exact for using Methyl UnMethy
between Tumor and Normal
I'm looking for how to transform data to calculate fisher exact for each site using dplyr approach.
methyl_dat <- data.frame(loci = c("site1", "site2", "site3", "site4"),
Methy.tumor = c(50, 5, 60, 12),
UnMethy.tumor = c(60, 0, 65, 5),
Methy.Normal = c(13, 5, 22, 3),
UnMethy.Normal = c(86, 0, 35, 3) )
Here is Fischer exact strategy for site 1
Normal
Tumor Methyl UnMethy
Methy 50 13
UnMethy 60 86
consider doing:
apply(methyl_dat[-1], 1, \(x)fisher.test(matrix(x,2)), simplify = F)