Entering edit mode
9.2 years ago
Gon
▴
10
Hi! I was wondering if anyone could help. I'm using the package ape in R and I want to trim an alignment of class DNAbin, this is, selecting portions of the alignment between two nucleotide positions. For example, I want all the sequences of my alignment but only between the nt positions 1503 and 3051.
Is it possible with ape or any other R package?
Thanks!
G.
Thanks Andrew! Eventually I managed to do it with ape, converting the object type DNAbin in a matrix, that way you can subset the usual way with square brackets. If you initially import the alignment from a fasta file using the argument
as.matrix=TRUE
you can skip the step of converting the DNAbin to a matrix. In my example:Hi Gon, how did you then write the subset to a new fasta file, without losing the fasta structure?
Hi jbt38! Following my example, I would export the sliced alignment into a new file like this:
Hope it's useful.
Legend, thanks for this - especially remembering what you did from so long ago!