I've been using the getBM-function to retrieve genes given a SNP (rs-id). However, if I try searching from a certain base pair distance, I do not get the same results as with the more simple query. E.g., in:
library(biomaRt)
mart.hs <- useMart("ensembl", "hsapiens_gene_ensembl")
mart.snp <- useMart("ENSEMBL_MART_SNP", "hsapiens_snp")
snip <- "rs6440082"
snipInfo <- getBM(attributes = c("refsnp_id","ensembl_gene_stable_id","chr_name","chrom_start","chrom_end","chrom_strand"),
filters="snp_filter", values=snip, mart=mart.snp)
bp <- as.numeric(snipInfo$chrom_start)
region <- paste(snipInfo$chr_name, bp-5e5, bp+5e5, snipInfo$chrom_strand, sep = ":")
genes <- unlist(getBM(attributes = "ensembl_gene_id", filters = "chromosomal_region", values = region, mart = mart.hs))
the latter getBM-query retrieves 8 genes, none of which contain the one retrieved by the former query. What is it that I am doing wrong here?
I should also note that you are assuming that a SNP is actually strand based. It's not. The reference and alternate alleles are different, depending on whichever strand you are talking about, but both strands have either the reference or alternate allele. Genes, on the other hand, are strand based.
And further to that point: