I want to associate a column of IDs with their name. That is, in each IDS line I have a list of genes. and to this list of genes I want to associate the name of the genes. Here is my code:
geneIDS<- Cas1_go_BP2[, 6] #vector with the IDS
allgencNames<- vector(length = length(geneIDS))
for (i in 1:length(geneIDS)) {
geneIDS_split<- unlist(strsplit(as.character(geneIDS[i]), ","))
geneIDs_split2<-as.character(gsub(" ", "", as.character(geneIDS_split)))
geneNames_split2<-DEG_ID[match(geneIDs_split2, DEG_ID[,2]), 1]
geneNames<- paste(geneNames_split2, collapse = ",")
allgencNames[i]<- geneNames
}
all_go_BP<- cbind(Cas1_go_BP, geneNames)