我如何将fisher.test在r中应用于大型矩阵,然后将p值提取到新矩阵中?
我有一个很大的矩阵(12行,53列),其中群集中的基因“ a”,“ b”,“ c”等数量是多少次,等等。与其他人创建的群集重叠,“ 0”,“ 1” ,“ 2”等。我仅提供数据的预览,以免帖子过度拥挤,但可以在需要时提供完整数据的DPUT()信息。
我想要的是在r中应用fisher.test()以识别“ 0”,“ 1”,“ 2”等的哪个。簇非常丰富我自己的哪个群集“ a”,“”,“”,“” B“,“ C”等。我想象这可能需要某种循环,但我不确定从哪里开始。我的重叠计数矩阵是否是Fisher.test()的正确输入?
另外,我想将每个结果输出到另一个表/矩阵,以便以后可以创建某种热图:
预先感谢您的任何帮助。
["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")))
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")))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够使用称为“ GeneoverLap”的R软件包对两个重叠数据集进行成对的Fisher测试。我必须在基因组1,基因组2的原始数据中进食,以及为背景考虑的基因数量。该软件包创建了自己的应急表,进行了成对的Fisher测试,并可以选择提取包括P值在内的各种结果。
尽管我得到的结果正在寻找,但感觉苦乐参半,因为它更像是解决问题的方法。但是,我不再需要回答我的问题。
I was able to conduct a pairwise fisher test on the two overlapping datasets using an R package called 'GeneOverlap'. I had to feed in the raw data for gene set 1, gene set 2, and the number of genes to be considered for the background. The package created its own contingency table, performed the pairwise fisher tests, and had an option for me to extract various results including p-values.
Although I got the result I was looking for, it feels bittersweet in that it feels more like a workaround to my problem. However, I no longer need my question answered.