I have a large matrix (12 rows, 53 columns) with counts of how many times genes in my clusters "A", "B", "C", etc. overlap with clusters created by someone else "0", "1", "2", etc. I am only providing a preview of the data to not overcrowd the post, but can provide the dput() info for the full data if needed.
What I want, is to apply fisher.test() in R to identify which of "0", "1", "2", etc. clusters are significantly enriched by which of my own clusters "A", "B", "C", etc. I'm imagining this may require some kind of loop, but I'm not sure where to begin. Would my matrix of overlap counts be the correct input for fisher.test()?
Also, I would like to output each result to a different table/matrix so that I can later create some sort of heat map like this:
Thank you in advance for any of your help.
["0"] ["1"] ["2"]["3"]["4"]
["A"] 2370 1261 229 103 737
["B"] 414 81 9 21 148
["C"] 110 30 50 19 24
["D"] 55 5 4 0 10
["E"] 864 193 138 45 345
structure(c(2370, 414, 110, 55, 864, 1261, 81, 30, 5, 193, 229,
9, 50, 4, 138, 103, 21, 19, 0, 45, 737, 148, 24, 10, 345), .Dim = c(5L,
5L), .Dimnames = list(c("A", "B", "C", "D", "E"), c("0", "1",
"2", "3", "4")))