[adegenet-forum] Visualizing DAPC with scatter() - help

Kathryn Davis daviskec at gmail.com
Sun Mar 22 18:38:22 CET 2020


Hello all,

I am trying to visualize a DAPC based upon the four clusters identified by
find.clusters() in a previous step. However, I want the color of points to
correspond to the origin of the individual (be it sampling site, presumed
subspecies, or another data point). A collaborator told me to use setPop()
and the scatter() code listed below. While this produced a DAPC plot with
each subspecies represented as a cluster, each with their own color, the
clusters do not line up to those in the DAPC plot with find.clusters input.

I've included my code below. Any suggestions on how to plot what I would
like will be greatly appreciated (I would also, once I have things working
the way I want, like to be able to manipulate the colors of the subspecies
to match other figures).

# START HERE create genlight object, name samples
n_gl <-vcfR2genlight(vcfile)
indNames(n_gl)<-plot_info$Sample

#replace NAs
mydf<-lapply(n_gl, as.integer)
n_gl_2<-do.call(rbind, lapply(mydf, function(e) replace(e, is.na(e), 0)))
n_gl_2<-as.genlight(n_gl_2)

#define strata/populations
strata.df <- read.table("pop-info.csv", header = TRUE, sep = ",")
strata(n_gl_2) <- strata.df
setPop(n_gl_2) <- ~Coast/Subspecies
popNames(n_gl_2)

#run find.clusters how many PCs/DAs to include
find.clusters(n_gl_2) #tutorial recommends keeping all PCs (300)unless it
is too computationally expensive. Identify the number of clusters as the
lowest BIC value (4)
grp<- find.clusters(n_gl_2, n.pca=300, n.clust=4)

#run DAPC directly:
dapc1 <- dapc(n_gl_2, n.pca=150, n.da=6) #without prior clusters

dapc2 <- dapc(n_gl_2, grp$grp, n.pca=150, n.da = 3) #with prior clusters,
number of PCs=150, DAs=3

##plot
scatter(dapc1, scree.da=FALSE, bg="white", pch=20, cell=1, cstar=1,
solid=.6, cex=2, clab=0, legend=TRUE, posi.leg="topleft")
scatter(dapc2, scree.da=FALSE, bg="white", pch=20, cell=1, cstar=1,
solid=.6, cex=2, clab=0, legend=TRUE)

Thank you,

-- 
Katie Davis
Louisiana State University '20
Natural Resource Ecology & Management/Spanish Major
daviskec at gmail.com | 407-927-6696
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20200322/3c8676e7/attachment.html>


More information about the adegenet-forum mailing list