I would like to perform multiple fisher.test() for each tax and each column (ABCB1 and ABL1 in the example below) in the data frame below.
The contingency tables should be extracted from the rows like shown below.
EDIT:
The contingency table should be calculated as shown below in the example:
data_frame(c(42,1),c(20,3))
contingency example:
ABCB1 NotABCB1
tax1Present 42 1
tax1NotPresent 20 3
42 is 43-1
1 is the cell value Present:tax1Present
20 is 23-3
3 is the cell value in NotPresent: tax1NotPresent
data:
structure(list(group = c("tax1Present", "tax1NotPresent", "tax2Present",
"tax2NotPresent", "tax3Present", "tax3NotPresent", "tax4Present",
"tax4NotPresent", "tax5Present", "tax5NotPresent"), ABCB1 = c(1L,
3L, 4L, 5L, 3L, 6L, 6L, 3, 2, 6L), ABL1 = c(18L, 14, 12L,
9L, 1L, 5L, 0L, 0L, 7L, 0L), Present = c(43L, 43, 23L, 23,
9L, 9, 7L, 7, 20, 20L),NotPresent = c(23, 23, 18, 18,
7L, 7L, 10L, 10L, 10, 10L), tax = c("tax1", "tax1", "tax2",
"tax2", "tax3", "tax3", "tax4", "tax4", "tax5", "tax5")), row.names = c(NA,
10L), class = "data.frame")
> df
group ABCB1 ABL1 Present NotPresent tax
1 tax1Present 1 18 43 23 tax1
2 tax1NotPresent 3 14 43 23 tax1
3 tax2Present 4 12 23 18 tax2
4 tax2NotPresent 5 9 23 18 tax2
5 tax3Present 3 1 9 7 tax3
6 tax3NotPresent 6 5 9 7 tax3
7 tax4Present 6 0 7 10 tax4
8 tax4NotPresent 3 0 7 10 tax4
9 tax5Present 2 7 20 10 tax5
10 tax5NotPresent 6 0 20 10 tax5