Question: Read, concatenate and merge the multiple fasta sequence files in R
0
gravatar for 3335098459
7 months ago by
333509845910
333509845910 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 • 814 views
ADD COMMENTlink modified 7 months ago by ATpoint10k • written 7 months ago by 333509845910
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 7 months ago • written 7 months ago by Bastien HervĂ©2.7k
2
gravatar for ATpoint
7 months ago by
ATpoint10k
Germany
ATpoint10k 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 7 months ago • written 7 months ago by ATpoint10k
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: 1229 users visited in the last hour