Search
Question: translate DNA sequence to Amino acid sequence in a dataframe
0
gravatar for XIA.PAN
9 months ago by
XIA.PAN10
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))
{
  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

ADD COMMENTlink modified 9 months ago by Martin Morgan ♦♦ 20k • written 9 months ago by XIA.PAN10
1
gravatar for Martin Morgan
9 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 9 months ago by Martin Morgan ♦♦ 20k

it worked, thank you Martin.

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

Help
Access

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