Question: Read, concatenate and merge the multiple fasta sequence files in R
0
gravatar for 3335098459
8 days ago by
33350984590
33350984590 wrote:

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

sequence R genome • 118 views
ADD COMMENTlink modified 8 days ago by ATpoint3.5k • written 8 days ago by 33350984590
2

Did you take a look at seqinr package ? 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

ADD REPLYlink modified 8 days ago • written 8 days ago by Bastien HervĂ©590
2
gravatar for ATpoint
8 days ago by
ATpoint3.5k
Germany
ATpoint3.5k wrote:

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")
ADD COMMENTlink modified 6 days ago • written 8 days ago by ATpoint3.5k
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.3.0
Traffic: 1758 users visited in the last hour