Question: translate DNA sequence to Amino acid sequence in a dataframe
gravatar for XIA.PAN
5 months ago by
XIA.PAN10 wrote:

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))

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

Thank you very much!


ADD COMMENTlink modified 5 months ago by Martin Morgan ♦♦ 20k • written 5 months ago by XIA.PAN10
gravatar for Martin Morgan
5 months ago by
Martin Morgan ♦♦ 20k
United States
Martin Morgan ♦♦ 20k wrote:

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 COMMENTlink written 5 months ago by Martin Morgan ♦♦ 20k

it worked, thank you Martin.

ADD REPLYlink written 5 months ago by XIA.PAN10
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 149 users visited in the last hour