BioMart : Retrieve set_gene_id (ENSG) and set_transcript_id (ENST) from SNPs rsIDs
3
0
Entering edit mode
5.6 years ago

Hello, I want to retrieve set_gene_id (ENSG), set_transcript_id (ENST) from a file containing the rsIDs of many SNPs. After a lot of research, the BioMart package from R would allow me to do this. After some research, I saw that I had to use the argument refsnp_id to tell the program that I wanted to provide them with the rsIDs of my SNPs to perform the search and retrieve the gene and transcript ID.

Here is the code:

library(biomaRt)
Data <- readLines ("rsID.txt")
length(Data)

for (i in 1:length(Data)){
  mart <- useMart(biomart = "ensembl", dataset = "hsapiens_gene_ensembl")
  results <- getBM(attributes = c("refsnp_id", "ensembl_gene_id", "ensembl_transcript_id"),
                   filters = "refsnp_id", values = "i",
                   mart = mart)
}

However, it returns the following error :

Error in getBM(attributes = c("refsnp_id", "ensembl_gene_id", "ensembl_transcript_id"),  : 
  Invalid attribute(s): refsnp_id 
Please use the function 'listAttributes' to get valid attribute names

How to tell it that I want to give him rsIDs ?

Second, is this the right way to read a txt file line by line and thus search for gene and transcript names for each sNP?

Thank you in advance for your help.

snp BioMart rs ID • 2.7k views
ADD COMMENT
2
Entering edit mode
5.6 years ago

You need to use a different mart. Take a look at my answer, here: A: How to retrieve Gene name from SNP ID using biomaRt

To see all attributes that are available, type:

listAttributes(mart)

Kevin

ADD COMMENT
2
Entering edit mode
5.6 years ago
Mike Smith ★ 2.1k

As Kevin says, you need to use the SNPs mart rather than the Genes mart.

You also don't need to do this inside a loop. You can provide a vector of rsIDs to the values argument and the function will run the query for all of them. This will be much faster than doing them one at a time within the loop.

ADD COMMENT
0
Entering edit mode
5.6 years ago

Thank you for your answers, indeed, I should not use biomart correctly and especially not be in snp mode. But how do I transform my text file into a vector? I've tried different commands that always send me the same message. How to do this?

What has been tried:

Data_vec <- as.vector(Data) 
Data_vec<-c("Data")

library(biomaRt) Data <- readLines ("file.txt") length(Data)

#Data_vec <- as.vector(Data) 
#Data_vec<-c(Data)

 require(biomaRt) ensembl <- useMart("ENSEMBL_MART_SNP", dataset =
"hsapiens_snp") getBM(attributes=c(   "refsnp_id",
"ensembl_gene_stable_id", "ensembl_transcript_stable_id"),  
filters="snp_filter", values="Data_vec",   mart=ensembl, uniqueRows=TRUE)

Error :

[1] refsnp_id                    ensembl_gene_stable_id       ensembl_transcript_stable_id
<0 rows> (or 0-length row.names)
ADD COMMENT

Login before adding your answer.

Traffic: 2262 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6