\section{Counts}
<<echo=FALSE,results='asis'>>=
cat(paste("This analysis looks at ",sumcats$n," individuals.",sep=""))
@

\noindent
\newline The mean number of alleles per locus (across all locations): \Sexpr{round(mean(sumcats$loc.n.all),1)}


\noindent
\newline The percentage of missing data was \Sexpr{round(sumcats$NA.perc,1)}\%.

<<n_alleles_per_locus, echo=FALSE, fig.width=6, fig.height=4, fig.path=fig.path, dev=dev, dpi=dpi>>=
barplot(sumcats$loc.n.all,ylab="Number of alleles", main="Number of alleles per locus",xlab="Locus",ylim=c(0,round((5+max(sumcats$loc.n.all)),digits=-1)),las=3,names.arg=locNames(cats), cex.names=0.8)
@
\FloatBarrier



\noindent 
\newline The individuals were sampled from the following locations in the following numbers: 
<<echo=FALSE, results='hide'>>=
indlist<-as.data.frame(samplocnum)
colnames(indlist)<-"Number"
#t(indlist)
popallelecnt<-sum(sumcats$loc.n.all)
indlist.out<-data.frame(Locations=rownames(indlist),Number=indlist[,1])
colnames(indlist.out)<-c("Location","Number")
write.csv(indlist.out, file=paste(filename,"-num_samp_by_loc.csv", sep=""), row.names=FALSE)
@

<<echo=FALSE, results='asis'>>=
brtab(indlist, capt="Number of individuals per population", c("population","# ind"))
@

\noindent
\newline {The total number of alleles sampled across all locations was {\Sexpr{popallelecnt}}} 
\newline The total number of alleles seen in each sampling location was:


<<echo=FALSE, results='hide'>>=
numallelespop<-as.data.frame(sumcats$pop.n.all)
rownames(numallelespop)<-popNames(cats)
colnames(numallelespop)<-"Total number of alleles"
#t(numallelespop)
numallelespop.out<-data.frame(Locations=rownames(numallelespop),numallelespop[,1])
colnames(numallelespop.out)[2]<-"Total number of alleles"
write.csv(numallelespop.out, paste(filename,"-tot_alleles_by_loc.csv", sep=""),row.names=FALSE)
@
<<echo=FALSE, results='asis'>>=
brtab(numallelespop,"Number of alleles per population",c("population","# alleles"))
@
<<pop_sampsz_vs_alleles, echo=FALSE, fig.width=6, fig.height=4, fig.path=fig.path, dev=dev, dpi=dpi>>=
plot(sumcats$n.by.pop,sumcats$pop.n.all,xlab="Location sample size",ylab="Number of alleles",main="Number of alleles vs location sample size",pch=19,ylim=c(0,round((5+max(sumcats$pop.n.all)),digits=-1)))
textxy(sumcats$n.by.pop,sumcats$pop.n.all,(names(sumcats$pop.n.all)),cex=0.6)
@
\FloatBarrier
\noindent
\newline The number of alleles per locus (across all subpopulations):
<<echo=FALSE, results='asis'>>=
numatall<-as.data.frame(t(sumcats$loc.n.all))
colnames(numatall)<-locNames(cats)
rownames(numatall)<-"# of alleles"

row1<-c("Locus",colnames(numatall))
row2<-unname(unlist(c("# of alleles",numatall[1,])))
numatall.out<-rbind(row1,row2)
write.table(numatall.out, paste(filename,"-num_alleles_locus.csv", sep=""), row.names=FALSE, col.names=FALSE, sep=",")
@

<<echo=FALSE, results='asis'>>=
brtab((t(numatall)),"Number of alleles per locus across all subpopulations",c("locus","# alleles"),7)
@




<<echo=FALSE,results='hide'>>=
allresults$counts<-list(N=sumcats$N, numbypop=t(indlist),totalleles=popallelecnt, nallelesbypop=t(numallelespop), nallelesbyloc=numatall, meanalleles=round(mean(sumcats$loc.n.all),1),missing=round(sumcats$NA.perc,1))
@

\FloatBarrier
