Last active
December 14, 2015 14:21
-
-
Save fstrozzi/fda9ffea251947879ab1 to your computer and use it in GitHub Desktop.
Example BiomaRt with R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(biomaRt) | |
## ensembl=useMart("ensembl") | |
## listDatasets(ensembl) # show all the possible databases on Ensembl | |
ensembl = useEnsembl(biomart="ensembl",dataset="btaurus_gene_ensembl") | |
## listAttributes(ensembl) # show the attributes of the database | |
window = 500000 # number of bases to search upstream and downstream the SNP position | |
ch4 = read.table("Significant_snp_CH4.txt",sep="\t",header=T,row.names=1,colClasses = c("character","character","integer","character","character","integer","numeric")) | |
genes_ch4 = list() | |
for (snp_name in rownames(ch4)) { | |
snp = ch4[snp_name,] | |
genes_ch4[[snp_name]] = getBM(c('ensembl_gene_id','uniprot_sptrembl','uniprot_swissprot'), | |
filters = c("chromosome_name","start","end"), | |
values=list(snp$Chromosome,snp$Position-window,snp$Position+window), | |
mart=ensembl) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment