Entering edit mode
Tom Hait
▴
10
@tom-hait-5441
Last seen 10.2 years ago
Hello,
I'm a student in bioinformatics in Tel Aviv University.
I'm working with you biomaRt API in order to generate automatically
FASTA
sequences downloading.
I experienced some problem, here is my code:
#open biomart libaray
library(biomaRt)
#open data set of human
human = useDataset("hsapiens_gene_ensembl",mart=ensembl)
#select the attributes that we want from the data set
attr<-c('ensembl_gene_id','ensembl_transcript_id',
'external_gene_id','chromosome_name','strand','transcript_start')
#downloading the map between transcript id and transcript name
tmpgene<-getBM(attr, 'biotype', values = 'protein_coding', human)
#save in a TSV format (the file is saved in txt)
write.table(tmpgene,"Z:/tomhait/organisms/human/transcript_names.txt",
row.names=FALSE, quote=FALSE)
#collect all sequences with upstream flank 3000 bases based on the
first
column (ensembl_id) of tmpgene
i<-1
for(id1 in tmpgene[,2]){
#retrieve sequence
sequence<-getSequence(id=id1,
type='ensembl_transcript_id',seqType='transcript_flank',upstream =
3000,
mart = human)
#check if sequence was retrieved
sLengths <- with(sequence, nchar(as.character(transcript_flank)))
#writing to a new file in
"Z:/tomhait/organisms/human/mart_export_new.txt"
#you can change it to "mart_export_new.txt" and it will create a new
file
in R directory
if(length(sLengths) > 0){
x<-sequence[,1]
y<-y<-strsplit(gsub("([[:alnum:]]{60})", "\\1 ", x), " ")[[1]]
title<-paste(paste(">",tmpgene[i,1],sep=""),tmpgene[i,2],tmpgene[i,3
],tmpgene[i,4],tmpgene[i,5],tmpgene[i,6],
sep="|")
write(title,file="Z:/tomhait/organisms/human/mart_export_new.txt",nc
olumns
= 1, append=TRUE,sep="")
write(y,file="Z:/tomhait/organisms/human/mart_export_new.txt",ncolumns
=
1, append=TRUE,sep="\n")
write("\n",file="Z:/tomhait/organisms/human/mart_export_new.txt",nco
lumns
= 1, append=TRUE,sep="\n")
}
i<-i+1
}
I got the message:
Error in getBM(c(seqType, type), filters = c(type, "upstream_flank"),
:
Query ERROR: caught BioMart::Exception::Usage: Filter upstream_flank
NOT
FOUND
Could you please help me to solve this problem?
Best Regards,
Tom Hait.
[[alternative HTML version deleted]]