[adegenet-forum] Distance patches in data

Jombart, Thibaut t.jombart at imperial.ac.uk
Wed Feb 5 13:27:53 CET 2014


Hello, 

again, sorry about the late reply. 
What you describe makes sense - it is a Mantel test using an unorthodox measure of geographic distance. Because this distance is binary (neighbour/not neighbour), it is also the AMOVA of your distance matrix using neighbourhood definition as a grouping factor for each pairwise distance comparison. 

The only trick is that you want to convert your standardized list of spatial weights (decimal numbers between 0 and 1 reflecting geographic proximities)  into a binary matrix of distances.
Here's an example of how to do it:
### 

## get the spatial distance
data(sim2pop)
cn <- chooseCN(sim2pop$other$xy, type=2)
matgeo <- as.dist(1*(!nb2mat(cn)>1e-14))

## compare these distances with genetic distances
library(ggplot2)
x <- data.frame(geo=as.vector(matgeo), genet=as.vector(dist(sim2pop$tab))) # 
head(x) # both distance measures
boxplot(x$genet~x$geo) # distances are marginally greater in non-neighbours


## using ggplot2 for fancier plots
p <- ggplot(x, aes(x=factor(geo),y=genet)) 
p + geom_boxplot() # boxplot
p + geom_violin(alpha=.4) # better: violinplot

###

However, the weakness of the result here with sim2pop shows that this approach is not the best for testing structures.
Cheers
Thibaut

--
######################################
Dr Thibaut JOMBART
MRC Centre for Outbreak Analysis and Modelling
Department of Infectious Disease Epidemiology
Imperial College - School of Public Health
St Mary’s Campus
Norfolk Place
London W2 1PG
United Kingdom
Tel. : 0044 (0)20 7594 3658
t.jombart at imperial.ac.uk
http://sites.google.com/site/thibautjombart/
http://adegenet.r-forge.r-project.org/
________________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Peter [peter.rooney at blueyonder.co.uk]
Sent: 03 February 2014 01:50
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] Distance patches in data

Hi,

I’m very new to adegenet, and trying to determine if it is sensible to create a distance matrix from a neighbour joining tree (njt) for correspondence analysis with a genetic matrix.  I couldn’t find any information on this from a search of the archives.

I have created a neighbour joining tree and then used it in an sPCA as follows:

njt <- chooseCN(myind at other$xy,ask=FALSE,type=4) #create njt from xy
njt_ed<-edit.nb(njt,myind at other$xy,polys=rb_polys) #edit njt to insert “barriers”, creates a “forest”
myspca<-spca(myind, cn=njt_ed, scale=TRUE, type=1, plot.nb=TRUE, nfposi=40, nfnega=40, ask=FALSE, scannf=FALSE)

I can now create a genetic distance matrix from the microsatellite data:
dg<-dist(myind$tab)

However, I don’t know how to create a distance matrix for the individuals based on the edited neighbour joining tree, rather than the xy coordinates (as in the tutorial) or the results of the sPCA which also represent genetic variation.  I want to compare distances for individuals based on the njt “forest”, so that I can compare them, e.g.:

plot(dg,?? geographic distance matrix using njt ??)

Perhaps it would be more sensible to use a different type of connection network?

If anyone can help I’d be very grateful, thanks.

Peter


More information about the adegenet-forum mailing list