I am trying to perform Multiple Sequence Alignment using ClustalW. The code works, and I am able to see the alignments on my terminal in R. Below is the code that I wrote.
library(BiocManager)
library(msa)
library(Biostrings)
mySequences <- readRNAStringSet("C:/Users/School EC/Desktop/MSA
project/only_unaligned/no_recomb/1_unaligned.fasta")
mySequences
myClustalWAlignment <- msa(mySequences, "ClustalW")
myClustalWAlignment
library(seqinr)
write.fasta(sequences = myClustalWAlignment,names =
names(myClustalWAlignment), file.out = "aligned_1.fasta", open =
"w",nbchar = 60, as.string = FALSE)
However when I run the write.fasta function I get an error that states:
Error in sequence[(nbchar * q + 1):l] : object of type 'S4' is not subsettable
Could you please advise on how I can sort this out. When I check my file where everything is stored the output file "aligned_1" is there but it is empty.