seppop: Separate genotypes per population

Description Usage Arguments Value Author(s) See Also Examples

Description

The function seppop splits a genind or a genlight object by population, returning a list of objects whose components each correspond to a population.

For genind objects, the output can either be a list of genind (default), or a list of matrices corresponding to the @tab slot.

Usage

1
2
3
4
5
6
## S4 method for signature 'genind'
seppop(x,pop=NULL,truenames=TRUE,res.type=c("genind","matrix"),
  drop=FALSE, treatOther=TRUE, keepNA = FALSE, quiet=TRUE)

## S4 method for signature 'genlight'
seppop(x,pop=NULL, treatOther=TRUE, keepNA = FALSE, quiet=TRUE, ...)

Arguments

x

a genind object

pop

a factor giving the population of each genotype in 'x' OR a formula specifying which strata are to be used when converting to a genpop object. If none provided, population factors are sought in x@pop, but if given, the argument prevails on x@pop.

truenames

a logical indicating whether true names should be used (TRUE, default) instead of generic labels (FALSE); used if res.type is "matrix".

res.type

a character indicating the type of returned results, a list of genind object (default) or a matrix of data corresponding to the 'tab' slots.

drop

a logical stating whether alleles that are no longer present in a subset of data should be discarded (TRUE) or kept anyway (FALSE, default).

treatOther

a logical stating whether elements of the @other slot should be treated as well (TRUE), or not (FALSE). See details in accessor documentations (pop).

keepNA

If there are individuals with missing population information, should they be pooled into a separate population (TRUE), or excluded (FALSE, default).

quiet

a logical indicating whether warnings should be issued when trying to subset components of the @other slot (TRUE), or not (FALSE, default).

...

further arguments passed to the genlight constructor.

Value

According to 'res.type': a list of genind object (default) or a matrix of data corresponding to the 'tab' slots.

Author(s)

Thibaut Jombart t.jombart@imperial.ac.uk

See Also

seploc, repool

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
data(microbov)
strata(microbov) <- data.frame(other(microbov))

obj <- seppop(microbov)
names(obj)

obj$Salers

### example using strata
obj2 <- seppop(microbov, ~coun/spe)
names(obj2)

obj2$AF_BI

#### example for genlight objects ####
x <- new("genlight", list(a=rep(1,1e3),b=rep(0,1e3),c=rep(1, 1e3)))
x

pop(x) # no population info
pop(x) <- c("pop1","pop2", "pop1") # set population memberships
pop(x)
seppop(x)
as.matrix(seppop(x)$pop1)[,1:20]
as.matrix(seppop(x)$pop2)[,1:20,drop=FALSE]

## End(Not run)

Example output

Loading required package: ade4

   /// adegenet 2.1.1 is loaded ////////////

   > overview: '?adegenet'
   > tutorials/doc/questions: 'adegenetWeb()' 
   > bug reports/feature requests: adegenetIssues()


 [1] "Borgou"          "Zebu"            "Lagunaire"       "NDama"          
 [5] "Somba"           "Aubrac"          "Bazadais"        "BlondeAquitaine"
 [9] "BretPieNoire"    "Charolais"       "Gascon"          "Limousin"       
[13] "MaineAnjou"      "Montbeliard"     "Salers"         
/// GENIND OBJECT /////////

 // 50 individuals; 30 loci; 373 alleles; size: 139.2 Kb

 // Basic content
   @tab:  50 x 373 matrix of allele counts
   @loc.n.all: number of alleles per locus (range: 5-22)
   @loc.fac: locus factor for the 373 columns of @tab
   @all.names: list of allele names for each locus
   @ploidy: ploidy of each individual  (range: 2-2)
   @type:  codom
   @call: .local(x = x, i = i, j = j, treatOther = ..1, quiet = ..2, drop = drop)

 // Optional content
   @pop: population of each individual (group size range: 50-50)
   @strata: a data frame with 3 columns ( coun, breed, spe )
   @other: a list containing: coun  breed  spe 

[1] "AF_BI" "AF_BT" "FR_BT"
/// GENIND OBJECT /////////

 // 100 individuals; 30 loci; 373 alleles; size: 216.6 Kb

 // Basic content
   @tab:  100 x 373 matrix of allele counts
   @loc.n.all: number of alleles per locus (range: 5-22)
   @loc.fac: locus factor for the 373 columns of @tab
   @all.names: list of allele names for each locus
   @ploidy: ploidy of each individual  (range: 2-2)
   @type:  codom
   @call: .local(x = x, i = i, j = j, treatOther = ..1, quiet = ..2, drop = drop)

 // Optional content
   @pop: population of each individual (group size range: 100-100)
   @strata: a data frame with 3 columns ( coun, breed, spe )
   @other: a list containing: coun  breed  spe 

 /// GENLIGHT OBJECT /////////

 // 3 genotypes,  1,000 binary SNPs, size: 6.8 Kb
 0 (0 %) missing data

 // Basic content
   @gen: list of 3 SNPbin

 // Optional content
   @ind.names:  3 individual labels
   @other: a list containing: elements without names 

NULL
[1] pop1 pop2 pop1
Levels: pop1 pop2
$pop1
 /// GENLIGHT OBJECT /////////

 // 2 genotypes,  1,000 binary SNPs, size: 5.7 Kb
 0 (0 %) missing data

 // Basic content
   @gen: list of 2 SNPbin

 // Optional content
   @ind.names:  2 individual labels
   @pop: population of each individual (group size range: 2-2)
   @other: a list containing: elements without names 


$pop2
 /// GENLIGHT OBJECT /////////

 // 1 genotypes,  1,000 binary SNPs, size: 4.3 Kb
 0 (0 %) missing data

 // Basic content
   @gen: list of 1 SNPbin

 // Optional content
   @ind.names:  1 individual labels
   @pop: population of each individual (group size range: 1-1)
   @other: a list containing: elements without names 


  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
a    1    1    1    1    1    1    1    1    1     1     1     1     1     1
c    1    1    1    1    1    1    1    1    1     1     1     1     1     1
  [,15] [,16] [,17] [,18] [,19] [,20]
a     1     1     1     1     1     1
c     1     1     1     1     1     1
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
b    0    0    0    0    0    0    0    0    0     0     0     0     0     0
  [,15] [,16] [,17] [,18] [,19] [,20]
b     0     0     0     0     0     0

adegenet documentation built on July 18, 2021, 1:06 a.m.