Reduce saturation by deleting the 3rd position in each codon of DNA seqs. R ape package
1
0
Entering edit mode
10.0 years ago
dago ★ 2.8k

I am performing a phylogenentic analysis using specific marker genes.

I selected the aa sequences, aligned them, used as template for aligning the respective nucleotide sequences.

I created a saturation plot with the "ape" package in R, and I can see that same seq are saturated.

In order to have a more robust results I would like, now, to delete the third position in each codon.

Is there a way/program to do this?

I guess this could be done with

seq
test3[seq(1, length(test3), by = 3)] # take only the first nucleotide in the codon

but I cannot find a way of taking only the first one and the second one.

I am also open to any suggestion for different way of doing this task

alignment phylogeny DNA R • 3.9k views
ADD COMMENT
3
Entering edit mode
10.0 years ago
David W 4.9k

In R you can use negative indices to exclude elements.

Here's an example using one of ape's datasets (not this is an alignment (matrix), not a single sequence (vector) as in your example

 library(ape)
 data(woodmouse)
 #Just the third codon (assuming alignment is in-frame)
 woodmouse[, seq(1, ncol(woodmouse), by=3) ]
## 15 DNA sequences in binary format stored in a matrix.
## 
## All sequences of same length: 322 
## 
## Labels: No305 No304 No306 No0906S No0908S No0909S ...
## 
## Base composition:
##     a     c     g     t 
## 0.285 0.238 0.219 0.258
 #skipping the thrid codon
 woodmouse[, -seq(1, ncol(woodmouse), by=3) ]
## 15 DNA sequences in binary format stored in a matrix.
## 
## All sequences of same length: 643 
## 
## Labels: No305 No304 No306 No0906S No0908S No0909S ...
## 
## Base composition:
##     a     c     g     t 
## 0.318 0.273 0.079 0.330
view raw gist.md hosted with ❤ by GitHub

ADD COMMENT
0
Entering edit mode

Ok, really good thanks!

ADD REPLY
0
Entering edit mode

I might not understand the command AlignmentToFilter[, -seq(1, ncol(AlignmentToFilter), by=3) ] .. but it is apparently skipping the first codon position in my hand while command AlignmentToFilter[, -seq(3, ncol(AlignmentToFilter), by=3) ] worked for me and omitted the 3rd codon position.

ADD REPLY

Login before adding your answer.

Traffic: 2788 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6