Read, concatenate and merge the multiple fasta sequence files in R
Hi everyone,
I am using Windows and R-Studio. I am looking for a particular R-package or commands to read, write, concatenate and relabel the sequences in a fasta formatted file. I know other GUI softwares but I need to perform this in R.
Please help me. Regards Awan
• 5,445 views
•
link
1 answer
For writing fasta to disk, you can use:
Write.Fasta <- function(Sequences, Names, FastaPath){
if (length(Sequences) != length(Names)) stop="Sequences and Names of unequal length!"
X <- data.frame(paste(">", Names, sep=""), Sequences)
D <- do.call(rbind, lapply(seq(nrow(X)), function(i) t(X[i, ])))
write.table(x = D, sep="\n", col.names = F, row.names = F, quote = F, file = FastaPath)
}
## Example:
Write.Fasta(Sequences = my.seqs, Names = my.names, FastaPath = "/Path/To/file.fa")
• 0 views
•
link
Log in to answer this question.
Did you take a look at
seqinrpackage ? read.fasta and write.fasta are include, maybe there are functions to relabel and concat ( https://cran.r-project.org/web/packages/seqinr/seqinr.pdf ).See also
seqRFLP