This is a test version of Biostars. For the public version, visit https://www.biostars.org.
exportFASTA not working

I am trying to use the biomart to extract genomic sequence based on the coordinate information and saving output in fasta format file. Here are few lines of code :

mart <- useMart("ensembl", dataset="hsapiens_gene_ensembl")

seq1 <- getSeq(x = hg38, names = chromosome, start =start, end =  end)
head(seq)
exportFASTA(seq1, file="test.fa")

With output:

**DNAStringSet object of length 6:
    width seq                                               names               
[1]  1043 GGGGCCGTAGACAAGCAATTAAA...TTAGGGGAGGGATCGGGGGAGGG chr12
[2]   450 CCCCCTTCCCTTCCCTCCCCACC...GGCTGGGCTCGGGCTGGTCGCCG chr2
[3]   665 AGCGGCGGGGGAGGGGAGGAGAC...CGCTGAGGAGACCAAGGACAAAG chr7
[4]   580 TAACCGGCCGCGGCCCGATGGCG...GGGATGTCCGCGAGGTCGGCCTA chr2
[5]   124 AAATCCGAGTTTCGCGGGAGGAC...ACCCGGGCTGCCGCCGCCGCCTC chr6
[6]   608 CAGCCCCACGTTACTTTGATTGA...TCACACACTTGTATATTATTTTG chr9**

Error :

  1. exportFASTA(seq1, file)
  2. stop("No data.frame given to write FASTA. The data.frame should be the output of the getSequence function.")

I would appreciate all the suggestion.

Thanks

exportfasta biomart getseq

1 answer

As the error tells you the function expects a data.frame. However, you can use Biostrings::writeXStringSet() to write a DNAStringset as fasta.

With dataframe input, still gave error. But successfully saved fasta format sequence with writeXStringSet() options.

Log in to answer this question.