我正在使用RStudio并拥有此代码:
My_Iterator<-mget(x=c('X','Y','Z','X_Y','X_Z','Y_Z','X_Y_Z'))
for (i in My_Iterator) {
EzID<- unique(i[['Entrez.ID']])
geneList <-factor(as.integer(AllHumanGenes %in% EzID))
names(geneList)<-AllHumanGenes
My_Names<-c('A_GO','B_GO','C_GO','A_B_GO','A_C_GO','B_C_GO','A_B_C_GO')
for (i in 1:length(My_Names)){
My_Iterator[My_Names[i]] <-new(Class ='topGOdata',
ontology='BP',
allGenes=geneList,
annot =annFUN.org,
mapping ='org.Hs.eg.db')
}
break;
}
我在休息时加入; b / c否则它不会停止循环。我现在遇到的问题是,在经过适当的7次循环之后,它仍然只吐出一个对象,我需要它来吐出7个不同的对象(A_GO,B_GO等)。如果只是说:
My_Iterator<-mget(x=c('X','Y','Z','X_Y','X_Z','Y_Z','X_Y_Z'))
for (i in My_Iterator) {
EzID<- unique(i[['Entrez.ID']])
geneList <-factor(as.integer(AllHumanGenes %in% EzID))
names(geneList)<-AllHumanGenes
My_Iterator[i] <-new(Class ='topGOdata',
ontology='BP',
allGenes=geneList,
annot =annFUN.org,
mapping ='org.Hs.eg.db')
}
我收到此错误:
Error in My_Iterator[i] <- new(Class = "topGOdata", :
incompatible types (from S4 to character) in subassignment type fix
我也试过这个:
My_Names[i] <- My_Iterator[My_Names[i]] <-new(Class ='topGOdata',
ontology='BP',
allGenes=geneList,
annot =annFUN.org,
mapping ='org.Hs.eg.db')
}
break;
}
并得到同样的错误:
Error in My_Names[i] <- My_Iterator[My_Names[i]] <- new(Class = "topGOdata", :
incompatible types (from S4 to character) in subassignment type fix
我确信这只是一个简单的解决方法,但我没想出来。请帮助!
P.S。对不起,如果我没有使用正确的术语。希望你能理解我的要求!