[adegenet-forum] error on find.clusters

Jombart, Thibaut t.jombart at imperial.ac.uk
Mon Dec 16 04:21:12 CET 2013


Hello, 

thanks for sending the data off-list. As it turns out, there is an issue in your script. Your data are all "1" once recoded into a genind:
> table(truenames(a)$tab)

   1 
6132 

> alleles(a)
$L1
 1 
"" 

$L2
 1 
"" 

$L3
 1 
"" 

$L4
 1 
"" 

$L5
 1 
"" 

$L6
 1 
"" 

Which comes from the conversion from pegas, but then I am not sure if it is a problem in pegas's function or in the way you used them. 
In any case, the classical conversion from a table using df2genind works:

> dat <- read.csv("cpSSR_BigPuzzle.csv")

> head(dat)
     X X.1 pt100783 PcG2R1 PcI1A2 PcI2T1 Pt71936 Pc10
1 A101  A1      125    106    206    277     163  208
2 A102  A1      125    106    205    278     163  207
3 A103  A1      126    105    205    278     163  207
4 A104  A1      126    105    205    278     163  207
5 A105  A1      125    106    205    278     164  207
6 A106  A1      126    106    205    278     164  207

> x <- df2genind(dat[,-c(1,2)], ind.names=dat[,1], pop=dat[,2], ploidy=1)


> alleles(x)
$L1
    1     2     3     4     5 
"124" "125" "126" "127" "128" 

$L2
    1     2     3     4     5 
"104" "105" "106" "107" "108" 

$L3
   01    02    03    04    05    06    07    08    09    10    11 
"200" "201" "202" "203" "204" "205" "206" "207" "208" "209" "210" 

$L4
    1     2     3     4     5     6     7     8 
"267" "276" "277" "278" "279" "280" "281" "288" 

$L5
    1     2     3     4     5     6     7     8     9 
"158" "159" "160" "161" "162" "163" "164" "165" "166" 

$L6
    1     2     3     4     5     6     7     8 
"205" "206" "207" "208" "209" "210" "211" "212" 

> clust <- find.clusters(x) # THIS WORKS

In this case, the BIC profile suggests that there is no clear-cut number of clusters, but classifying individuals into around 10 groups would probably be a useful simplification.

Cheers

Thibaut


--
######################################
Dr Thibaut JOMBART
MRC Centre for Outbreak Analysis and Modelling
Department of Infectious Disease Epidemiology
Imperial College - School of Public Health
St Mary’s Campus
Norfolk Place
London W2 1PG
United Kingdom
Tel. : 0044 (0)20 7594 3658
t.jombart at imperial.ac.uk
http://sites.google.com/site/thibautjombart/
http://adegenet.r-forge.r-project.org/
________________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Willyard, Ann [Willyard at hendrix.edu]
Sent: 14 December 2013 20:40
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] error on find.clusters

On my way to DAPC, I am stuck on an error finding clusters:
> grp <- find.clusters(a, max.n.clust=40)
Error in if (nf > rank) nf <- rank :   missing value where TRUE/FALSE needed

I imported an SSR matrix that has 1022 individuals, 6 loci, and 47 populations:
>df <- read.loci(file.choose(), loci.sep=",", col.pop=2, col.loci=3:8)
And created a Genuind object using
>loci<-df[,3:8]
>pop<-df[,2]
>sample<-df[,1]
>a <- df2genind (loci, ncode=3, sep = ",", missing = NA, ploidy = 1, >pop=pop, ind.names=sample)
And confirmed that it is in the correct format using:
print(a, details = TRUE)

   #####################
   ### Genind object ###
   #####################
- genotypes of individuals -

S4 class:  genind
@call: df2genind(X = loci, sep = ",", ncode = 3, ind.names = sample,
    pop = pop, missing = NA, ploidy = 1)

@tab:  1022 x 6 matrix of genotypes

@ind.names: vector of  1022 individual names
@loc.names: vector of  6 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the  6 columns of @tab
@all.names: list of  6 components yielding allele names for each locus
@ploidy:  1
@type:  codom

Optionnal contents:
@pop:  factor giving the population of each individual
@pop.names:  factor giving the population of each individual

@other: - empty -

I am running 32 bit R version on a Windows 7 PC. I unintalled my R vers. 2.15.3 and installed R. vers. 3.0.2.
I have adegenet vers. 1.3-9.2. According to your web page, this is the most recent stable version, although adegenet-basics.pdf indicates that the adegenet version should be 1.4.
I have loaded the adegenet, pegas, MASS, and ade4 libraries.
I have searched the FAQ and every other source I can think of.

Help for an adegenet newbie will be most appreciated. NSF proposal deadline is looming ……

Ann Willyard
Assistant Professor
Hendrix College
1600 Washington Ave
Conway AR 72032
501-450-1376
Willyard at hendrix.edu


More information about the adegenet-forum mailing list