R语言拆分单元格,以GO为例
程序员文章站
2022-03-11 21:41:13
...
将GO
拆分成gene2go
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")
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/
下一篇: 我太太太蠢了
推荐阅读