translate DNA sequence to Amino acid sequence in a dataframe
1
0
Entering edit mode
XIA.PAN ▴ 20
@xiapan-12407
Last seen 5.1 years ago

Dear all,

I have a set of short DNA sequences extracted from a Fastq into a data.frame that need to be translated to amino acids.

After the extraction, they are string characters, need to transfer to DNA string, then translate. So I wrote sth like 

for (n in 1:length(seqs.frame$DNA_seqs))
{
  translate(DNAString(seqs.frame$DNA_seqs[n]))
}

The translation seems to be working, but how do I put the tranlated amino acids back to the data.frame.

Thank you very much!

XIA

translation • 6.4k views
ADD COMMENT
1
Entering edit mode
@martin-morgan-1513
Last seen 4 months ago
United States

No need to iterate, just translate(DNAStringSet(seq.frame$DNA_seqs)). If you first df=DataFrame(seq.frame) then the result of translate() can be placed in the data frame

df$aa = translate(DNAStringSet(df$DNA_seqs))

otherwise use as.character() (again, no iteration) to coerce back to a plain-old-character vector.

ADD COMMENT
0
Entering edit mode

it worked, thank you Martin.

ADD REPLY

Login before adding your answer.

Traffic: 681 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