<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi there,
<br>
<br>
pop() is an accessor defined for genind objects, and does not work with matrices, which is your problem here: data_full is not a genind, but a matrix.
<br>
<br>
Please check the basics tutorial for more on data handling in adegenet.<br>
<br>
Also, scaleGen is now deprecated, better to use 'tab' instead.<br>
<br>
Cheers<br>
Thibaut<br>
<div><br>
<div style="font-family:Tahoma; font-size:13px">
<div class="BodyFragment"><font size="2"><span style="font-size:10pt">
<div class="PlainText"><br>
<br>
</div>
</span></font></div>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF294661"><font color="#000000" face="Tahoma" size="2"><b>From:</b> adegenet-forum-bounces@lists.r-forge.r-project.org [adegenet-forum-bounces@lists.r-forge.r-project.org] on behalf of Ella Bowles [ebowles@ucalgary.ca]<br>
<b>Sent:</b> 19 October 2015 20:44<br>
<b>To:</b> adegenet-forum@lists.r-forge.r-project.org<br>
<b>Subject:</b> [adegenet-forum] unable to find an inherited method for function ‘pop’ for signature ‘"matrix"’<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1">Hello,</font></div>
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1">I'm working my way through the DAPC manual for genind objects, and after trying to run </font></div>
<div class="gmail_default" style="">
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1">> table(pop(data_full), NumClust$grp)</font></div>
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1">#got the error</font></div>
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1">Error in (function (classes, fdef, mtable) : </font></div>
<div class="gmail_default" style="color:rgb(0,0,255)"><font size="1"> unable to find an inherited method for function ‘pop’ for signature ‘"matrix"’</font></div>
<div style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
<div style="color:rgb(0,0,255)"><font size="1">My full dataset has the name data_full (equivalent to the "x" dataset name in the manual), and the NumClust variable contains the information from the find.cluster section (equivalent to the "grp" variable used
in the manual).</font></div>
<div style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
<div style="color:rgb(0,0,255)"><font size="1">I'm wondering if you know what could cause this.</font></div>
<div style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
<div style="color:rgb(0,0,255)"><font size="1">Commands that I have executed thus are are:</font></div>
<div style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
<div style="">
<div style=""><font color="#0000ff" size="1">data <- read.structure("C:/Users/Ella Bowles/Documents/PhD Ecology Evolution/Data/GBS_2013_run/stacks_run_08/populations_08c9 results_this is the data used for pop gen and genet architec chaps/batch_1_8c9_modified.stru",
n.ind = 186, n.loc = 4099, onerowperind = FALSE, col.lab = 1, col.pop = 2, col.others = NULL, row.marknames = 2, NA.char = "0", ask = TRUE)</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">data</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">#slots are accessed using both @ and $ (data are S4 object)</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">popNames(data)</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">sum(<a href="http://is.na" target="_blank">is.na</a>(data$tab))</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">#there are [1] 76822 missing data</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">#replace them with scaleGen</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">#calling new dataset "data_full)</font></div>
<div style=""><font color="#0000ff" size="1">data_full <- scaleGen(data, NA.method="mean")</font></div>
<div style=""><font color="#0000ff" size="1">class(data_full)</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">dim(data_full)</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">#note disable scaling in dudi.pca, which would erase scaling choice made earlier in scaleGen</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">NumClust <- find.clusters(data_full, max.n.clust=150)</font></div>
<div style=""><font color="#0000ff" size="1">150 #number of PCs to retain</font></div>
<div style=""><font color="#0000ff" size="1">20 #choosing number of clusters</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">names(NumClust)</font></div>
<div style=""><font color="#0000ff" size="1"> #names(NumClust)</font></div>
<div style=""><font color="#0000ff" size="1">#[1] "Kstat" "stat" "grp" "size" </font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">head(NumClust$Kstat, 20) #BIC for different values of k</font></div>
<div style=""><font color="#0000ff" size="1"># K=1 K=2 K=3 K=4 K=5 K=6 K=7 K=8 K=9 K=10 K=11 K=12 K=13 </font></div>
<div style=""><font color="#0000ff" size="1">1660.250 1652.460 1646.640 1645.846 1647.815 1648.798 1650.835 1654.304 1657.618 1661.039 1664.529 1668.123 1671.439 </font></div>
<div style=""><font color="#0000ff" size="1"> K=14 K=15 K=16 K=17 K=18 K=19 K=20 </font></div>
<div style=""><font color="#0000ff" size="1">1675.647 1678.779 1682.386 1685.970 1689.871 1693.475 1697.183 </font></div>
<div style=""><font color="#0000ff" size="1">#looks like k=4 is best</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">#some other stats that I didn't find useful, see p 6 of dapc manual</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">head(NumClust$grp, 20)</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">NumClust$size #group sizes</font></div>
<div style=""><font color="#0000ff" size="1"># [1] 5 6 4 1 19 2 16 3 1 12 7 15 11 2 1 14 7 14 45 1</font></div>
<div style=""><font color="#0000ff" size="1"><br>
</font></div>
<div style=""><font color="#0000ff" size="1">table(pop(data_full), NumClust$grp)</font></div>
</div>
<div style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
<div style="color:rgb(0,0,255)"><font size="1">Many thanks,</font></div>
<div style="color:rgb(0,0,255)"><font size="1">Ella</font></div>
<div style="color:rgb(0,0,255)"><font size="1"><br>
</font></div>
</div>
<font size="1">-- <br>
</font>
<div class="gmail_signature">
<div dir="ltr">
<div><font size="1">Ella Bowles<br>
PhD Candidate </font></div>
<div><font size="1">Biological Sciences</font></div>
<div><font size="1">University of Calgary<br>
<br>
e-mail: <a href="mailto:ebowles@ucalgary.ca" target="_blank">ebowles@ucalgary.ca</a>,
<a href="mailto:bowlese@gmail.com" target="_blank">bowlese@gmail.com</a></font></div>
<div><font size="1">website: <a href="http://ellabowlesphd.wordpress.com/" rel="nofollow me" style="color:rgb(59,89,152); font-family:'lucida grande',tahoma,verdana,arial,sans-serif; line-height:17px" target="_blank">http://<span style="display:inline-block"></span>ellabowlesphd.wordpre<span style="display:inline-block"></span>ss.com/</a></font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>