<div dir="ltr"><div style="font-size:12.8px"><span style="font-size:12.8px">Dear all, </span></div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px"><span style="font-size:12.8px">I am trying to constuct a DAPC scatterplot with adegenet and have three questions that after consulting online resources, tutorials, etc. still haven't been answered definitively. </span><br></div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">My data set consists of (diploid) microsatellite data (8 markers) for 20 ant colonies of 9-28 workers each (mean=15), 301 workers total. I have missing data in 7 spots (i.e. individuals with missing data at one or more loci). My first question is about reading in the genepop file:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b>1) What is the proper command for reading in my file in regards to missing data? </b></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I had replaced all missing data ("0000") with "NA" in the genepop file and used the below code assuming that it would recognize my missing data as NA (first line of code) and replace missing values with means (second line):</div><br style="font-size:12.8px"><i style="font-size:12.8px">msts_m2<-read.genepop("BOR-Od_m2_301w.gen",missing="NA")<br>na.replace(msts_m2,"mean", quiet=FALSE)</i><div style=""><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">However, when I run this code, it informs me that it replaced 119 missing values. This obviously seems too much as it should have only replaced 7. I'm not sure why this isn't working, see output below</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b>OUTPUT:</b></div><div style=""><div style=""><span style="font-size:12.8px"><i>> na.replace(msts_m2,"mean", quiet=FALSE) </i></span></div><div style=""><span style="font-size:12.8px"><br></span></div><div style=""><span style="font-size:12.8px"><i> Replaced 119 missing values </i></span></div><div style=""><span style="font-size:12.8px"><i><br></i></span></div><div style=""><span style="font-size:12.8px"><i> #####################</i></span></div><div style=""><span style="font-size:12.8px"><i> ### Genind object ### </i></span></div><div style=""><span style="font-size:12.8px"><i> #####################</i></span></div><div style=""><span style="font-size:12.8px"><i>- genotypes of individuals - </i></span></div><div style=""><span style="font-size:12.8px"><i><br></i></span></div><div style=""><span style="font-size:12.8px"><i>S4 class: genind</i></span></div><div style=""><span style="font-size:12.8px"><i>@call: read.genepop(file = "BOR-Od_m2_301w.gen", missing = "NA")</i></span></div><div style=""><span style="font-size:12.8px"><i><br></i></span></div><div style=""><span style="font-size:12.8px"><i>@tab: 301 x 93 matrix of genotypes</i></span></div><div style=""><span style="font-size:12.8px"><i><br></i></span></div><div style=""><span style="font-size:12.8px"><i>@ind.names: vector of 301 individual names</i></span></div><div style=""><span style="font-size:12.8px"><i>@loc.names: vector of 8 locus names</i></span></div><div style=""><span style="font-size:12.8px"><i>@loc.nall: number of alleles per locus</i></span></div><div style=""><span style="font-size:12.8px"><i>@loc.fac: locus factor for the 93 columns of @tab</i></span></div><div style=""><span style="font-size:12.8px"><i>@all.names: list of 8 components yielding allele names for each locus</i></span></div><div style=""><span style="font-size:12.8px"><i>@ploidy: 2</i></span></div><div style=""><span style="font-size:12.8px"><i>@type: codom</i></span></div><div style=""><span style="font-size:12.8px"><i><br></i></span></div><div style=""><span style="font-size:12.8px"><i>Optionnal contents: </i></span></div><div style=""><span style="font-size:12.8px"><i>@pop: factor giving the population of each individual</i></span></div><div style=""><span style="font-size:12.8px"><i>@pop.names: factor giving the population of each individual</i></span></div><div style=""><span style="font-size:12.8px"><i><br></i></span></div><div style=""><span style="font-size:12.8px"><i>@other: - empty -</i></span></div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">My second and third questions relate to the selection of the # of PCs and the # of discriminant functions to retain. It seems that each time I make slight changes to these numbers, the output changes vastly and so I want to make sure I input the proper numbers. </div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">First I use the find.clusters function, I designate 20 for n.pca here since I have 20 colonies:</div><div style="font-size:12.8px"><div><br></div><div><i>clusters<-find.clusters(msts_m2,max.n.pca=20)</i></div><div><br></div><div>When asked for the number of PCs to retain I select 30 which is the level at which the points seem to level off. The BIC graph looks nothing like the graph in the vignette (it does not level off but below a certain level shows a downward zigzag pattern) so I choose 20 given that I have 20 colonies. </div><div><i><br></i></div><div><i>dapc_m2<-dapc(msts_m2,clusters$grp)</i><i><br></i></div><div><img src="cid:ii_1504daedf8025696" alt="Inline image 1" width="223" height="214" style="margin-right: 0px;"><img src="cid:ii_1504daf4b898e88b" alt="Inline image 2" width="211" height="205" style="font-size: 12.8px; margin-right: 0px;"><i><br></i></div><div>Next, when asked for PCs to retain I again choose the level at which the points start to level off (30) but when asked for discriminant functions to retain, I'm at a loss. I have about 18 relatively constantly decreasing bars. I usually choose the point between the first few ones and the rest where there is some kind of bigger (sometimes arbitrary) break and use that number (in this case: 4):</div><div><br></div><div><b>2) How to choose the appropriate number for PCs to retain and discr. functions to retain?</b></div><div><b><br></b></div><div><b><img src="cid:ii_1504db017166e9eb" alt="Inline image 3" width="197" height="193" style="margin-right: 0px;"><img src="cid:ii_1504db084b5f29b4" alt="Inline image 4" width="229" height="222" style="margin-right: 0px;"><br></b></div><div><b><br></b></div><div><br></div><div><br></div><div><i>best.n.pca<-a.score(dapc_m2)</i></div><div><i>temp<-optim.a.score(dapc_m2)</i></div><div><i><br></i></div><div>After running the optim.a.score function I receive a graph that tells me at the top "optimal number of PCs". This is the number I put into my last line of code (below) for n.pca, and for n.da I choose the number I used when prompted earlier: </div><div><br></div><div><b>3) Are these the correct numbers to use for this last line of code? </b></div><div><br></div><div><i>dapc_m2<-dapc(msts_m2,n.pca=7,n.da=4)</i></div></div><div><br></div><div><br></div><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr">Magdalena Sorger<br>____________<br>Department of Applied Ecology<br>North Carolina State University<br>127 David Clark Labs, Box 7617<br>100 Eugene Brooks Ave.<br>Raleigh, NC 27695, USA<br># <a href="tel:919-513-7464" value="+19195137464" target="_blank">919-513-7464</a><br>
<a href="mailto:dmsorger@ncsu.edu" target="_blank">dmsorger@ncsu.edu</a><div><a href="http://www.theantlife.com" target="_blank"><b>www.theantlife.com</b></a></div></div></div></div></div>
</div>