I have a data frame of p-values. Other than p-values it has some zero entries also.
data
V1 V3 V4 V5 V6 V7
1 ADAM32 0.001 0 0 0 0
2 ADAM32 0.001 0.65 0.001 0.001 0.65
3 ADAM32 0.65 0 0 0 0
4 CCL5 0.000491 0.000491 0.000491 0 0
5 CILP2 0.500000024 0.500000024 0.500000024 0 0
6 EPHB3 0.000562 0.000562 0.000562 0.000562 0.000562
7 EPHB3 0.000562 0 0 0 0
8 GUCA1A 0.002006 0.602006 0.002006 0.602006 0.002006
9 GUCA1A 0.602006 0 0 0 0
10 HSPA6 0.000322 0.000322 0.000322 0.000322 0.000322
11 HSPA6 0.000322 0 0 0 0
12 MAPK1 0.002 0.002 0.002 0 0
I use the following code to apply Fisher's method to combine the p-values of each row.
## Fisher's Method
Fisher.test <- function(p) {
Xsq <- -2*sum(log(p))
p.val <- pchisq(Xsq, df = 2*length(p), lower.tail = FALSE)
return(c(Xsq = Xsq, p.value = p.val))
}
for(k in 1 : nrow(data))
{
p <- as.numeric(data[j,-1])
fisher <- Fisher.test(p)
print(fisher)
}
I want to skip zeros from adding to the row-sum, as it leads to an infinite value after the log transformation of the p-value.