BioMart: Is there a way to easily change the species for all of my code?

落爺英雄遲暮 提交于 2019-11-29 16:56:56

Easy way is to just wrap it all in a for loop:

library(biomaRt)

species <- c("hsapiens_gene_ensembl", "mmusculus_gene_ensembl", "ggallus_gene_ensembl")

for (s in species) {
tmp <- useMart("ensembl", dataset = paste0(s))
hsapien_PC_genes <- getBM(attributes = c("ensembl_gene_id", "external_gene_name"), 
                          filters = "biotype", 
                          values = "protein_coding", 
                          mart = tmp)
paralogues[[s]] <- getBM(attributes = c("external_gene_name",
                                                 "hsapiens_paralog_associated_gene_name"), 
                                  filters = "ensembl_gene_id", 
                                  values = c(ensembl_gene_ID) , mart = tmp)
}

This should work, I haven't tested it because I don't have those packages installed. I've changed the names of some vars to make more sense (eg tmp)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!