Search
Question: getting global Fisher score for overlap of 3 GRanges object by element-wise [solved]
0
2.3 years ago by
Italy
Jurat Shahidin60 wrote:

Dear all:

I want to get fisher score of this following tabular data by element wise. I know this question is not related to any Bioconductor problems, and I also tried to find similar post from stackoverflow, but can't find possible solution. My apology to ask this statistical question from this community. However, my data contains list of overlap' significance score of 3 GRanges objects, I want to get its global fisher score by element-wise. How can I get this?

This is the data that I want to get global fisher score by element wise:

[[1]]
NumericList of length 7
[[1]] 1e-22
[[2]] 1e-19
[[3]] 1e-18
[[4]] 1e-16
[[5]] 1e-24
[[6]] 1e-20
[[7]] 1e-15

[[2]]
NumericList of length 7
[[1]] 1e-24
[[2]] 1e-24
[[3]] 1e-20
[[4]] 1e-25
[[5]] 0.1
[[6]] 1e-19
[[7]] 1e-18

[[3]]
NumericList of length 7
[[1]] 1e-11
[[2]] 1e-11
[[3]] 1e-10
[[4]] numeric(0)
[[5]] numeric(0)
[[6]] 1e-15
[[7]] numeric(0)

# reproducible example:

 data <- DataFrame(
v1=c(1e-22,1e-19,1e-18,1e-16,1e-24,1e-20, 1e-15),
v2=c(1e-24,1e-24,1e-20,1e-25,0.1,1e-19,1e-18),
v3=c(1e-11,1e-11,1e-10,numeric(0),numeric(0),1e-15,numeric(0)))

if you wonder third list element contains numeric(0), which refers to non-overlapped regions, so I can replace it with zero:

v3 <- <- lapply(data[[3]], function(x) {
res <- ifelse(length(x)>0, x, 0)
})

then:

 data <- DataFrame(
v1=c(1e-22,1e-19,1e-18,1e-16,1e-24,1e-20, 1e-15),
v2=c(1e-24,1e-24,1e-20,1e-25,0.1,1e-19,1e-18),
v3=c(1e-11,1e-11,1e-10,0,0,1e-15,0)))

#Finally, my desired output something like (just example by element wise) :

global fisher score of  (1e-22, 1e-24, 1e-11) = ?
global fisher score of  (1e-19, 1e-24, 1e-11) = ?
...
global fisher score of  (1e-24, 1e-01, numeric(0)) = ?

I want to get global fisher score by element wise. How can I get this in R? Alternatively, If I used chisq.test, How can I get chi-square statistics by element wise for above data table? I will be grateful if anyone can teach me how to do this in R.

Jurat

modified 2.3 years ago • written 2.3 years ago by Jurat Shahidin60

Hi Jurat,

Just a few questions/clarifications:

1. The code above won't run as-is: you need to replace "DataFrame" with "data.frame", and all instances of "numeric(0)" with "0" for it to construct the dataframe properly.

2. "li.3" is not defined in the example. Should that be "data"?

3. For FET, you usually need two sets of multiple items. In the above output example, it looks as if you are trying to compare three sets of single entries? Can you give a specific example of a call to "fisher.exact()" that you would form part of your result?

2
2.3 years ago by
Italy
Jurat Shahidin60 wrote:

Dear Keith:

I updated my thread and fixed the issue that you mentioned. Plus, I got wrong with using Fisher' exact test, instead I actually need to use Fisher' method to get global score. I got solution now. This is solution:

library(metap)
data <- as.data.frame(DataFrame(v1, v2, v3))
data$global = apply(data[1:3], 1, function(df) sumlog(df)$p)

cheers

Jurat