sequence - R: How to use output of 'translate' function to write a table? -
i have file (data.txt) contains 2 dna sequences (orf):
data = readdnastringset(file="data.txt") data # dnastringset instance of length 2 # width seq names #[1] 57 atgacccccacctccatccccacacttctatcccgctgccccgcctctctcccctaa gpg #[2] 54 atgacccatgagcaccatgcagccaaaaccctgggaatcggcaaagccatctag pfk
i want convert them aminoacids:
t=vector(mode="list", length=length(data)) (i in seq_along(data)) { t[[i]]=translate(data[[i]]) } t #[[1]] #19-letter "aastring" instance #seq: mtptsiptllsrcpaslp* #[[2]] #18-letter "aastring" instance #seq: mthehhaaktlgigkai*
then write table , have output using:
tt=do.call(rbind,t) write.table(tt,"aa.txt",sep="\t\t")
but these commands don't work. couldn't find problem. how can write table?
note: translate
function [seqinr
] , readdnastringset
function [biostrings
].
i don't know why need seqinr. biostrings need.
library("biostrings") dna <- readdnastringset(file="data.txt") aa <- translate(dna) write.table(as.character(aa), file="aa.txt", sep="\t\t")
maybe want use writexstringset
instead of write.table
.
Comments
Post a Comment