首页 > 解决方案 > 如何计算每个基因的关联数

问题描述

我有一个eqtl分析的输出文件MatrixEQTL

SNP gene    beta    t-stat  p-value FDR
ch01_76563780   GW_06g072920    0.049942008791647   932.306067766817    2.2250738585072e-308    1.60416093688267e-302
ch02_36905357   GW_06g072920    -0.049942008791647  -932.306067766817   2.2250738585072e-308    1.60416093688267e-302
ch07_69573723   GW_06g072920    0.049942008791647   932.306067766817    2.2250738585072e-308    1.60416093688267e-302
ch01_87880392   GW_06g072920    0.0499413219745195  923.819795644165    2.2250738585072e-308    1.60416093688267e-302

我正在尝试计算每个基因的关联,以获得重要的基因进行总结。我将不胜感激任何建议。谢谢!

标签: r

解决方案


好吧,所以关联本质上是数据中特定基因存在的行数?然后很容易按基因分组并计算数字

library(magrittr)
eqtl %>% 
  dplyr::group_by(gene) %>%
  dplyr::summarise(Associations = dplyr::n())

# here is a small example with a toy df
tibble::tibble(SNPS = 1:4, Gene = "testgene") %>% 
  dplyr::group_by(Gene) %>% 
  dplyr:::summarise(Associations = dplyr::n())

这行得通吗,让我知道!

祝你好运 :)


推荐阅读