我有一个包含n行和26个克隆的表,其中行名作为基因名,列作为每个基因的相关功能。如果该基因在特定列上带有“ +”,则表示该基因与此功能相关。如何计算特定途径中所有带有“ +”的基因?我试图将图表变成一个数据框,例如df1,然后使用summary函数,但是它没有给我想要的输出。我看到一些帖子说str_detect()有效,但这似乎适用于一个变量/列。我期望从Rstudio获得的一个例子是:适应性免疫反应4血管生成2凋亡4....等等等等。这是我提到的图表的片段(单击链接,级别不足以直接上传图像):Gene List
欢迎您提出任何建议的功能或软件包,对于使用R进行数据分析来说还是很新的。谢谢
回答关于上传可复制数据的评论:
structure(list(Gene = c("Cyp27a1", "Tnfrsf13c", "Igf1r", "S100a10",
"Kit", "Hcar2", "Itgax", "Mbd2", "Asph", "Ccl7", "Dlg1", "Tgm1",
"Gstm1", "Casp1", "Tbc1d4", "Olfml3", "Ppp3ca", "Igsf10", "Rpl28",
"Rad1", "F3", "Gpr34", "Lrrc3", "Col6a3", "Cdc7", "Stx18", "Ccl2",
"Ptx3", "Nfkb1", "Bola2", "Npl", "Itga6", "Slc17a7", "Prkar2a",
"Serping1"), Cell.Type = c(NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, "Dendritic cells", NA, NA, NA, NA, NA, NA, NA, NA), Adaptive_Immune_Response = c("-",
"-", "-", "-", "+", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "+", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "+", "-", "-", "-", "-", "-", "-"), Angiogenesis = c("-",
"-", "-", "-", "+", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-"), Apoptosis = c("-", "-",
"+", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "+", "-",
"-", "+", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"+", "-", "-", "-", "-", "+", "-"), Astrocyte_Function = c("-",
"-", "-", "+", "-", "-", "-", "-", "-", "-", "-", "+", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "+",
"+", "-", "-", "-", "-", "-", "-", "+"), Autophagy = c("-", "-",
"+", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "+", "-", "-",
"-", "-", "-", "-", "-", "-", "-"), Carbohydrate_Metabolism = c("-",
"-", "+", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-"), Cell_Cycle = c("-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "+", "-", "-", "-", "-", "+", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-"), Cellular_Stress = c("-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "+", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "+", "-", "-", "-", "-", "-", "-"), Cytokine_Signaling = c("-",
"+", "-", "-", "+", "-", "-", "-", "-", "+", "-", "-", "-", "+",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "+",
"-", "+", "-", "-", "-", "-", "-", "-"), DNA_Damage = c("-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "+", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-"), Epigenetic_Regulation = c("-",
"-", "-", "-", "-", "-", "-", "+", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-"), Growth_Factor_Signaling = c("-",
"-", "+", "-", "+", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "+", "-", "-", "-", "-", "-", "-", "+", "-", "-", "-",
"-", "+", "-", "-", "+", "-", "+", "-"), Inflammatory_Signaling = c("+",
"+", "-", "-", "-", "-", "-", "-", "-", "+", "-", "-", "+", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "+",
"-", "+", "-", "-", "-", "-", "-", "-"), Innate_Immune_Response = c("-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "+",
"-", "-", "+", "-", "-", "-", "-", "-", "-", "-", "-", "-", "+",
"-", "+", "-", "-", "-", "-", "-", "-"), Insulin_Signaling = c("-",
"-", "+", "-", "+", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-"), Lipid_Metabolism = c("-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-"), Matrix_Remodeling = c("-",
"-", "-", "-", "-", "-", "+", "-", "-", "-", "-", "-", "-", "-",
"-", "+", "-", "-", "-", "-", "-", "-", "-", "+", "-", "-", "-",
"-", "-", "-", "-", "+", "-", "-", "-"), Microglia_Function = c("-",
"-", "-", "-", "-", "+", "+", "-", "+", "-", "-", "-", "-", "-",
"+", "-", "-", "+", "+", "-", "+", "+", "+", "+", "-", "-", "-",
"-", "-", "+", "+", "+", "-", "-", "-"), NF.kB = c("-", "+",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"+", "-", "-", "-", "-", "-", "-"), Neurons_and_Neurotransmission = c("-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "+", "-", "-", "-",
"+", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "+", "-", "-"), Notch = c("-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-"), Oligodendrocyte_Function = c("-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-"), Wnt = c("-", "-", "-",
"-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"+", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
"-", "-", "-", "-", "-", "-"), Human_Gene = c("CYP27A1", "TNFRSF13C",
"IGF1R", "S100A10", "KIT", "HCAR2", "ITGAX", "MBD2", "ASPH",
"CCL7", "DLG1", "TGM1", "GSTM1", "CASP1", "TBC1D4", "OLFML3",
"PPP3CA", "IGSF10", "RPL28", "RAD1", "F3", "GPR34", "LRRC3",
"COL6A3", "CDC7", "STX18", "CCL2", "PTX3", "NFKB1", "BOLA2",
"NPL", "ITGA6", "SLC17A7", "PRKAR2A", "SERPING1")), row.names = c(181L,
705L, 314L, 602L, 382L, 285L, 353L, 433L, 24L, 98L, 189L, 680L,
279L, 85L, 670L, 495L, 537L, 316L, 590L, 568L, 226L, 266L, 405L,
156L, 131L, 661L, 94L, 562L, 471L, 66L, 484L, 349L, 631L, 546L,
612L), class = "data.frame")
尝试这样的事情:
counts = cbind(colSums(df[,-c(1,2,26)]=="+"),colSums(df[,-c(1,2,26)]=="-"))
colnames(counts) = c("plus","minus")
plus minus
Adaptive_Immune_Response 3 32
Angiogenesis 1 34
Apoptosis 5 30
Astrocyte_Function 5 30
Autophagy 2 33
Carbohydrate_Metabolism 1 34
Cell_Cycle 2 33
Cellular_Stress 2 33
Cytokine_Signaling 6 29
DNA_Damage 1 34
Epigenetic_Regulation 1 34
Growth_Factor_Signaling 7 28
Inflammatory_Signaling 6 29
Innate_Immune_Response 4 31
Insulin_Signaling 2 33
Lipid_Metabolism 0 35
Matrix_Remodeling 4 31
Microglia_Function 13 22
NF.kB 2 33
Neurons_and_Neurotransmission 3 32
Notch 0 35
Oligodendrocyte_Function 0 35
Wnt 1 34