Jombart, Thibaut t.jombart at imperial.ac.uk
Wed Feb 23 12:40:55 CET 2011

```Dear Sofie,

In the figure you mention, the map does not directly represent groups by colors, but principal components of DAPC. To do this with your data, you can use the same technique by representing the average scores of individuals at a given location. So the trick will consist in 1) identifying unique locations for individuals 2) averaging DAPC scores for each location 3) plotting the result

Here is a simple example using the dataset sim2pop. Some commands may require the devel version of adegenet to work.

####
data(sim2pop)

## define 10 locations to which indiv are assigned randomly
loc <- matrix(runif(20), ncol=2)
xy <- loc[sample(1:10, nInd(sim2pop),replace=TRUE), ]
sunflowerplot(xy, main="Spatial distribution of the individuals", xlab="x", ylab="y") # visualize the obtained spatial distribution

## perform DAPC
dapc1 <- dapc(sim2pop, n.pca=20, n.da=2) # there are two clusters, see "pop(sim2pop)"

## identify unique locations and make it a factor
xy <- round(xy, 10)
facloc <- factor(paste(xy[,1], xy[,2], sep="-")) # this tells to which location each indiv belongs
uniqLocXY <- Reduce(rbind, lapply(strsplit(levels(facloc), "-"), as.numeric)) # this contains the xy coords of each unique location

## compute average score for each loc
locScores <- tapply(dapc1\$ind.coord[,1], facloc,mean)

## plot results
colorplot(uniqLocXY, as.data.frame(locScores), xlab="x",ylab="y", cex=4)

####
On the obtained plot, the color of each location is defined by its composition in terms of genotypes.

2) I don't know. Package 'maps' has pretty much all countries... back in 1991 (!). I think this kind of data is usually difficult to get for free.

3) In such a case, it is dubious that there is a single 'good' answer. What the analysis tells is that there are two equally satisfying (from the point of view of the BIC) solutions. However, you may look at both and see how they differed. I have already seen this situation, but the extra increase of K actually led to one cluster with a single individual - an outlier.

Best regards

Thibaut.

________________________________________
From: adegenet-forum-bounces at r-forge.wu-wien.ac.at [adegenet-forum-bounces at r-forge.wu-wien.ac.at] On Behalf Of Sofie Vandewoestijne [sofie.vandewoestijne at uclouvain.be]
Sent: 23 February 2011 09:45

Dear Thibaut Jombart and List members,

I have three questions concerning the mapping of DAPC results:

1) after find.clusters, it appear that individuals from the 5 samples sites are genetically grouped into 3 clusters. I would like to map this (as in Fig 7, Jombart et al BMC Genetics), but given that I have 5 localities (xy) and only 3 clusters, isn't it normal that I do not have the same number of row numbers in xy and X? (?? dem to post from Bernhard Stoeckle??). How do I resolve this error (Erreur dans colorplot.default(xy, -dapc.a\$grp.coord, cex = 3, add = TRUE,  :
xy and X have different row numbers) ?

> dim(xy)
 5 2
> dim(dapc.a\$grp.coord)
 3 2

> if(require(maps)){
+
+ xy <- cbind(data\$other\$popInfo\$Longitude, data\$other\$popInfo\$Latitude)
+
+ par(mar=rep(.1,4))
+ map(fill=TRUE, col="lightgrey")
+ colorplot(xy, -dapc.a\$grp.coord, cex=3, add=TRUE, trans=FALSE)
+ }
Erreur dans colorplot.default(xy, -dapc.a\$grp.coord, cex = 3, add = TRUE,  :
xy and X have different row numbers

2) where can one download maps from countries other than those provided in the map package?

3) finally, when there are 2 BIC values that are very similar, should one choose for the smaller number of clusters even if it has a higher BIC value?

Sincerely yours,

Sofie

Sofie Vandewoestijne
Postdoctoral fellow
Biodiversity Research Centre
Catholic University Louvain
Place Croix du Sud 5
B-1348 Louvain-la-Neuve
Belgium

Tel: 32 (0)10 473454
Fax: 32 (0)10 473490