欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

R语言拆分单元格,以GO为例

程序员文章站 2022-03-11 21:41:13
...

将GO
R语言拆分单元格,以GO为例
拆分成gene2go
R语言拆分单元格,以GO为例

library(stringr)
all_go_list=str_split(GO$GO_id,";")
all_ONTOLOGY_list=str_split(GO$Go_description,";")
gene2go <- data.frame(GID = rep(GO$GID,times = sapply(all_go_list, length)),
                      GO = unlist(all_go_list),ONTOLOGY=unlist(all_ONTOLOGY_list),
                      EVIDENCE = "IEA")

R语言拆分单元格,以GO为例

library(tidyr)
gene2go <- separate(data=gene2go, col="ONTOLOGY", into=c("ONTOLOGY","ONTOLOGY_descri"), sep = ":", remove = TRUE)
#data: 数据框格式,col: 要分解的列,可以是列名c(“col1”, “col2”),也可以是位置c(1,2),into: 分解后的列名,sep: 分隔符,remove: 去除被分解的列#

参考:https://blog.csdn.net/zdx1996/article/details/8920980
https://www.jieandze1314.com/post/cnposts/208/R语言拆分单元格,以GO为例

相关标签: 生物信息学