Question: Binary SNP matrix into APE (R)
0
gravatar for biogirl
4.9 years ago by
biogirl160
European Union
biogirl160 wrote:

Hi there,

I have a binary matrix in a tab-delimited file of aligned SNPs, where 1=SNP and 0=non-SNP.  The rows are the loci and the column are different individuals.  For example

 

Position   Isolate 1   Isolate 2   Isolate 3 ... Isolate n

4              1               0              0            ... 0

5              0               0              1           ... 1

10            1               1              0           ...0

etc.

I've seen a couple of posts mentioning that the R package 'APE' is good for generating trees from this type of data.  However, after reading the documentation, it is not clear to me how this is done.  Has anyone used this package for this type of data, and if so, can you please point me in the right direction?

 

Many thanks

trees alignment snp phylogenetics R • 3.9k views
ADD COMMENTlink modified 4.9 years ago by beroe140 • written 4.9 years ago by biogirl160
2
gravatar for beroe1
4.9 years ago by
beroe140
United States
beroe140 wrote:

One way is through calculating the distance and then making a neighbor-joining tree. You will probably have to transpose your existing matrix so that taxa are in rows, but I am entering them directly in that orientation using rbind.

library(ape)
snp = rbind(A=c(1,1,1,0,1),B=c(1,1,0,1,1),D=c(1,1,1,1,1),E=c(0,1,0,1,0))
stree = nj(dist.gene(snp))
plot(stree)

 

 

ADD COMMENTlink written 4.9 years ago by beroe140

This worked a treat, thanks!

ADD REPLYlink written 4.9 years ago by biogirl160
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: 1096 users visited in the last hour