r - 如何计算每个基因的关联数
问题描述
我有一个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
我正在尝试计算每个基因的关联,以获得重要的基因进行总结。我将不胜感激任何建议。谢谢!
解决方案
好吧,所以关联本质上是数据中特定基因存在的行数?然后很容易按基因分组并计算数字
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())
这行得通吗,让我知道!
祝你好运 :)
推荐阅读
- random - 如何通过从字母数字字符中采样来创建随机字符串?
- google-apps-script - onFormsSubmit(e)'se 为空
- php - 如何形成一个数组以从具有多个参数的 URL 进行查询
- c# - 将前一行值减去当前行并按日期排序
- python-3.x - 在尝试使用 sort_values() 方法对 pandas 数据帧进行排序时,我得到了意外的 KeyError
- azure - 现在叫什么“Azure 网站”?
- ios - 如何从委托方法启动 UIAlertController?
- python - 用不同的子字符串替换字符串的相同子字符串出现在python中循环
- python - 为什么熊猫会提出“KeyError:True”,而“df.Apples==30 & True”也不是关键?
- c - printf 出了什么问题