Hi Thibaut,<div><br></div><div>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?</div>

<div><br></div><div>Nevertheless, I will certainly try your suggestion. And if there are any other suggestions out there, I'd be happy to hear about them...</div><div><br></div><div>Thanks again!</div><div>-Kelvin<br>


<br><br><div class="gmail_quote">On Tue, Jan 15, 2013 at 8:29 AM, Jombart, Thibaut <span dir="ltr"><<a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Hello,<br>
<br>
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<br>
<br>
1) compute Euclidean distances between locations in the 3D space<br>
2) use these distances to define a graph of neighbouring sites (such as options 5 or 7 in chooseCN)<br>
3) use this graph as input in the sPCA<br>
<br>
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:<br>
##<br>
D <- dist(matXYZ)<br>
##<br>
<br>
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):<br>
##<br>
dMax=quantile(D, .25) # 25% quantile is perfectly arbitrary<br>
M <- 1* (as.matrix(D) < dMax) # non-standardized matrix of connectivity (1:neighbours; 0: otherwise)<br>
W <- prop.table(M,1) # this is your spatial weighting matrix<br>
##<br>
<br>
Then you can use sPCA with the argument matWeight=W, and here you go.<br>
<br>
Cheers<br>
<br>
Thibaut<br>
<br>
ps: if anyone has any knowledge of 3D-based connectivity graphs, that'd still be useful<br>
<br>
<br>
________________________________________<br>
From: <a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a> [<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>] on behalf of Kelvin Gorospe [<a href="mailto:kgorospe@hawaii.edu">kgorospe@hawaii.edu</a>]<br>


Sent: 15 January 2013 17:54<br>
To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
Subject: [adegenet-forum] Any suggestions about conducting a 3-D sPCA?<br>
<div class="HOEnZb"><div class="h5"><br>
Hi everyone,<br>
<br>
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.<br>


<br>
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.<br>


<br>
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?<br>


<br>
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?<br>


<br>
Any thoughts you might have would be greatly appreciated!<br>
<br>
Thanks for your time and I look forward to hearing from you soon.<br>
<br>
-Kelvin</div></div></blockquote></div><br></div>