Hi there,
I'm trying to map SNPs to a list of genes (~300) using the biomaRt package. My goal is to retrieve SNPs associated with each gene. Below are the steps I have followed:
STEP 1: Install necessary packages and load the file
library(biomaRt)
# Load gene list file
gene_list <- read.table(................................)
STEP 2: Map gene symbols to Ensembl gene IDs
ensembl_gene <- useEnsembl(biomart = "ensembl", dataset = "hsapiens_gene_ensembl")
gene_id_map <- getBM(
attributes = c("hgnc_symbol", "ensembl_gene_id"),
filters = "hgnc_symbol",
values = gene_list,
mart = ensembl_gene
)
STEP 3: Connect to SNP BioMart
ensembl_snp <- useEnsembl(biomart = "ENSEMBL_MART_SNP", dataset = "hsapiens_snp")
STEP 4: Retrieve SNPs
snp_results <- getBM(
attributes = c("refsnp_id", "chr_name", "chrom_start", "consequence_allele_string",
"ensembl_gene_stable_id", "associated_gene"),
filters = "ensembl_gene",
values = gene_id_map,
mart = ensembl_snp
)
print(snp_results)
I'm encountering the following error despite using a small subset of genes:
Error in `httr2::req_perform()`:
! Failed to perform HTTP request.
Caused by error in `curl::curl_fetch_memory()`:
! transfer closed with outstanding read data remaining
I have set a longer R timeout in case of network slowness but not resolved.
Note: I previously used MAGMA and it worked, though some genes were dropped during the process. I'm trying to retrieve more complete SNPs.
Any idea how to resolve this error or improve the stability of the query? Or any other options? Thanks in advance for your help!
Best regards, Nigussie
It is possible that at the time you were trying this BioMart was not working (Ensembl services are less reliable than they used to). Have you tried to do this again?
Just tried the example code provided by @Kevin here How to retrieve Gene name from SNP ID using biomaRt and was able to get prompt responses from BioMart.