[adegenet-forum] Any suggestions about conducting a 3-D sPCA?

Jombart, Thibaut t.jombart at imperial.ac.uk
Wed Jan 16 00:40:24 CET 2013


Hello, 

then, I would recommend starting by using depth only to define proximity as a base analysis. If there's no structure there, chances are correcting for 2D structures will not help much. 

As for controlling for 2D structures, this is an interesting question. One approach would be:
1) Generate a 2D connectivity matrix
2) derive Moran's eigenvectors from it (ME - see orthobasis in ade4)
3) regress the allele data onto relevant ME (variable selection will be needed)
4) perform a sPCA on the residuals of this regression, using depth to define connectivity

Quite a ride, but nothing impossible.

Otherwise, another option would be:
1) Regress 'depth distances' onto '2d distances'
2) Convert the residuals of this regression into a proximity measure (positive values)
3) Use this proximity as input of the sPCA, after row-standardization.

BTW, in my last email, I forgot that by convention, a location is never its own neighbours. The code should read:
####
dMax=quantile(D, .25) # 25% quantile is perfectly arbitrary
M <- 1* (as.matrix(D) < dMax) # non-standardized matrix of connectivity (1:neighbours; 0: otherwise)
diag(M) <- 0 # ! this is what was missing
W <- prop.table(M,1) # this is your spatial weighting matrix
####

Cheers
Thibaut
________________________________________
From: kdgorospe at gmail.com [kdgorospe at gmail.com] on behalf of Kelvin Gorospe [kgorospe at hawaii.edu]
Sent: 15 January 2013 21:21
To: Jombart, Thibaut
Cc: adegenet-forum at lists.r-forge.r-project.org
Subject: Re: [adegenet-forum] Any suggestions about conducting a 3-D sPCA?

Hi Thibaut,

Thanks for the insight and also for authoring adegenet! I'm wondering, however, if Euclidean distances between x,y,z coordinates will solve the problem of depth and space being confounded. I'm mainly interested to see whether or not there is a genetic cline with regards to depth after controlling for (or filtering out?) the autocorrelation due to spatial distances. Due to the geometry of my reef (i.e., a symmetrical, underwater mound), corals on opposite sides of the reef (diameter of 40m) have the same depth (depth only ranges between about 1 and 4m) but based on a Connectivity Network of Euclidean distances, would still be highly separated... I wonder if there is a way to give extra weight to depth distances without being too arbitrary about it... Or am I thinking about this the wrong way?

Nevertheless, I will certainly try your suggestion. And if there are any other suggestions out there, I'd be happy to hear about them...

Thanks again!
-Kelvin


On Tue, Jan 15, 2013 at 8:29 AM, Jombart, Thibaut <t.jombart at imperial.ac.uk<mailto:t.jombart at imperial.ac.uk>> wrote:

Hello,

theoretically yes, it is perfectly possible to perform a sPCA in 3D. In practice, the issue will be getting a matrix of connectivity between locations. The general approach is

1) compute Euclidean distances between locations in the 3D space
2) use these distances to define a graph of neighbouring sites (such as options 5 or 7 in chooseCN)
3) use this graph as input in the sPCA

Step 1 is easy. Just load a x,y,z matrix in R (with x,y,z in column), say in an object matXYZ, and then:
##
D <- dist(matXYZ)
##

Step 2 is not implemented in chooseCN, or the subroutines it calls from. One can do this manually. If you want to define neighbours based on distances in the 3d space (neighbours are distant by less than dMax):
##
dMax=quantile(D, .25) # 25% quantile is perfectly arbitrary
M <- 1* (as.matrix(D) < dMax) # non-standardized matrix of connectivity (1:neighbours; 0: otherwise)
W <- prop.table(M,1) # this is your spatial weighting matrix
##

Then you can use sPCA with the argument matWeight=W, and here you go.

Cheers

Thibaut

ps: if anyone has any knowledge of 3D-based connectivity graphs, that'd still be useful


________________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org<mailto:adegenet-forum-bounces at lists.r-forge.r-project.org> [adegenet-forum-bounces at lists.r-forge.r-project.org<mailto:adegenet-forum-bounces at lists.r-forge.r-project.org>] on behalf of Kelvin Gorospe [kgorospe at hawaii.edu<mailto:kgorospe at hawaii.edu>]
Sent: 15 January 2013 17:54
To: adegenet-forum at lists.r-forge.r-project.org<mailto:adegenet-forum at lists.r-forge.r-project.org>
Subject: [adegenet-forum] Any suggestions about conducting a 3-D sPCA?

Hi everyone,

For my PhD dissertation, I have sampled and mapped (x,y coordinate) every individual coral (n=2352) of one species within a single, circular coral reef. They are all genotyped at 6 micro satellite loci. I also have depth information for each individual coral.

I did some analyses previously and found spatial autocorrelation in the genetic data. Furthermore, I found that in addition to this x,y spatial autocorrelation, there is also spatial autocorrelation with regards to depth (using just a single z coordinate) in the genetic data.

Originally, I was conducting sPCA in R to do some exploratory analysis on the genetic data vs the x,y coordinates, in hopes of visualizing how genetic diversity was spatially structured and then comparing this to my maps of depth for the reef. However, I am wondering if I am approaching this the wrong way. Instead of treating depth as an environmental variable, is it better to conduct an sPCA using depth as a single spatial coordinate? And then look to see if there is a genetic cline along this single-coordinate system?

Or is it better (or even possible) to do a 3-dimensional sPCA using all three coordinates together (x,y, depth)? Has anyone ever attempted this? The reef is essentially shaped like an underwater hill or mound, such that the shallow sites are in the middle of the reef, and deeper sites are on the outer slopes or edges. Thus, some corals with similar depths are found on opposite sides of the reef, while others are found next to each other on the same side of the reef. If I am interested in exploring a genetic cline that is partitioned by both space (x,y) and depth (z), then corals on opposite sides of the reef are "connected" in terms of their depth, while those on the same side of the reef are "connected" by both space and depth. Given that, does anyone have any suggestions regarding what connection network would be best?

Any thoughts you might have would be greatly appreciated!

Thanks for your time and I look forward to hearing from you soon.

-Kelvin



More information about the adegenet-forum mailing list