<div dir="ltr">Hello all,<div><br></div><div>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. </div><div><br></div><div>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). </div><div><br></div><div># START HERE create genlight object, name samples<br>n_gl <-vcfR2genlight(vcfile)<br>indNames(n_gl)<-plot_info$Sample<br><br>#replace NAs<br>mydf<-lapply(n_gl, as.integer)<br>n_gl_2<-do.call(rbind, lapply(mydf, function(e) replace(e, <a href="http://is.na">is.na</a>(e), 0)))<br>n_gl_2<-as.genlight(n_gl_2)<br><br>#define strata/populations<br>strata.df <- read.table("pop-info.csv", header = TRUE, sep = ",")<br>strata(n_gl_2) <- strata.df<br>setPop(n_gl_2) <- ~Coast/Subspecies<br>popNames(n_gl_2)<br><br>#run find.clusters how many PCs/DAs to include<br>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)<br>grp<- find.clusters(n_gl_2, n.pca=300, n.clust=4)</div><div><br></div><div>#run DAPC directly:<br>dapc1 <- dapc(n_gl_2, n.pca=150, n.da=6) #without prior clusters<br><br>dapc2 <- dapc(n_gl_2, grp$grp, n.pca=150, n.da = 3) #with prior clusters, number of PCs=150, DAs=3<br><br>##plot<br>scatter(dapc1, scree.da=FALSE, bg="white", pch=20, cell=1, cstar=1, solid=.6, cex=2, clab=0, legend=TRUE, posi.leg="topleft")<br>scatter(dapc2, scree.da=FALSE, bg="white", pch=20, cell=1, cstar=1, solid=.6, cex=2, clab=0, legend=TRUE)<br><br></div><div>Thank you,</div><div><br></div><div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><font face="georgia, serif" size="4">Katie Davis</font><div><font face="georgia, serif">Louisiana State University '20</font></div><div><font face="georgia, serif">Natural Resource Ecology & Management/Spanish Major</font></div><div><font face="georgia, serif"><a href="mailto:daviskec@gmail.com" target="_blank">daviskec@gmail.com</a> | 407-927-6696</font></div></div></div></div></div>