This site is a beta test.
Question: Iteration of the Biomart search command on the entire list of rsIDs in a file
0
Entering edit mode
5 months ago
amandinelecerfdefer • 0

Hello,

I have a text file containing a list of rsIDs for many snp. I want to make the same request to search for gene names and transcripts on each line of this file. So, I would like to read my file line by line and indicate the current line (loop?) in my request. How to read my file line by line and put in "value" (of the getBM function) each line of my file (here instead of Data_with it is to have each line of the file).

Here is the code I tried:

Data <- readLines ("/Users/amandinelecerfdefer/Desktop/rsID.txt")
require(biomaRt)
sink("sortie_rsID.txt")
retrieve<-list()
for (i in 1:nrow(Data)){
  values <- Data_vec[[i]]
  ensembl <- useMart("ENSEMBL_MART_SNP", dataset = "hsapiens_snp")
  retrieve[[i]] <-getBM(attributes=c(
  "refsnp_id", "ensembl_gene_stable_id", "ensembl_transcript_stable_id"),
  filters="snp_filter", values=values,
  mart=ensembl, uniqueRows=TRUE)
}

but I still have this message:

Error in 1:nrow(Data) : argument of length 0

How can I link the file line by line and indicate to value each line line after line? and so how can I iterate this search command on all my snps in my file?

Entering edit mode
0

I guess your Data is in character class. If whatever you want to stick to your codes, you can try:

for (i in 1:length(Data)) {
  values <- Data[i]
  ......
}
ADD REPLYlink 5 months ago
SMK
♦ 1.3k
Entering edit mode
0

Thank you for your answer but the search command via mart does not start. How to solve this problem?

ADD REPLYlink 5 months ago
amandinelecerfdefer
• 0
Entering edit mode
0

Thank you for your answer but the search command via mart does not start. How to solve this problem?

ADD REPLYlink 5 months ago
amandinelecerfdefer
• 0
Entering edit mode
0

Did you have a look at the final dataframe: result if using the codes from fracarb8?

ADD REPLYlink 5 months ago
SMK
♦ 1.3k
Entering edit mode
0

Thank you for your help SMK , your solution works perfectly! Thank you! Thank you!

ADD REPLYlink 5 months ago
amandinelecerfdefer
• 0
Entering edit mode
0

Hello, I turn to you because since Friday, I can no longer retrieve my various information because I find myself with a recurrent error:

> res <- getBM(
+   attributes = c(
+     "refsnp_id",
+     "ensembl_gene_stable_id",
+     "ensembl_transcript_stable_id"
+   ),
+   filters = "snp_filter",
+   values = Data$rsID,
+   mart = snpmart,
+   uniqueRows = TRUE
+ )
Batch submitting query [=======>-----------------------------------------------------]  13% eta:  2hError in getBM(attributes = c("refsnp_id", "ensembl_gene_stable_id", "ensembl_transcript_stable_id"),  : 
  The query to the BioMart webservice returned an invalid result: biomaRt expected a character string of length 1. 
Please report this on the support site at http://support.bioconductor.org

Despite my internet research, I can't fix this mistake. How can I get this tool to work again?

Thank you in advance

ADD REPLYlink 5 months ago
amandinelecerfdefer
• 0
Entering edit mode
0

Did you find answers in BioMart : the BioMart webservice returned an invalid result?

ADD REPLYlink 5 months ago
SMK
♦ 1.3k
Entering edit mode
0

Yes, it's also my post ^^. The problem is the length of the list to send to the server. A maximum of 500 queries can be sent. What seems strange to me is that last week I managed to send 100,000 rsIDs.

ADD REPLYlink 5 months ago
amandinelecerfdefer
• 0
Entering edit mode
0

I added a comment there, regarding the batch issue.

ADD REPLYlink 5 months ago
SMK
♦ 1.3k
3
Entering edit mode
5 months ago
SMK ♦ 1.3k
Ghent, Belgium

Hi amandinelecerfdefer,

Try the following codes (assuming your file rsID.txt is with rsID as the header):

rsID
rs1450830176
rs868546642
rs1207902742
rs1431088173
rs1266518345
rs1387005982
library(biomaRt)
Data <- read.delim("rsID.txt")

snpmart <-
  useMart(biomart = "ENSEMBL_MART_SNP", dataset = "hsapiens_snp")
res <- getBM(
  attributes = c(
    "refsnp_id",
    "ensembl_gene_stable_id",
    "ensembl_transcript_stable_id"
  ),
  filters = "snp_filter",
  values = Data$rsID,
  mart = snpmart,
  uniqueRows = TRUE
)

Your results will be saved in a data.frame named res, you can save that out using write.csv(res, file = "rsID_out.txt").

ADD COMMENTlink 5 months ago SMK ♦ 1.3k
0
Entering edit mode
5 months ago
fracarb8 • 10

Why don't you simply read.delim() your file, save the column containing your IDs into values and pass it to useMart?

data <- read.delim("/Users/amandinelecerfdefer/Desktop/rsID.txt") values <- data[,1] # or use $ if the column is not the first ensembl <- useMart("ENSEMBL_MART_SNP", dataset = "hsapiens_snp") result <- getBM(attributes=c("refsnp_id", "ensembl_gene_stable_id", "ensembl_transcript_stable_id"), filters="snp_filter", values=values, mart=ensembl, uniqueRows=TRUE)

ADD COMMENTlink 5 months ago fracarb8 • 10

Login before adding your answer.

Powered by the version 1.5.2