jgx65 / hierfstat

the hierfstat package
24 stars 14 forks source link

Make a better use of genind object #1

Closed jgx65 closed 8 years ago

thibautjombart commented 9 years ago

A note on this, to get relevant data from a genind or a genpop object, you mostly need only to use tab(...). Examples using nancycats:

## load toy data
data(nancycats)
x <- nancycats

## get individual allele counts:
ind.counts <- tab(x)

## get individual allele frequencies
ind.freq <- tab(x, freq=TRUE)

## get allele counts per groups, with a group factor 'grp'
pop(x) <- grp
grp.counts <- tab(genind2genpop(x))

## get allele frequencies per groups, with a group factor 'grp'
pop(x) <- grp
grp.freq <- tab(genind2genpop(x), freq=TRUE)

So basically using natively genind objects should be relatively straightforward?

thibautjombart commented 9 years ago

Cool! =D

jgx65 commented 8 years ago

Function genind2hierfstat in hierfstat should do most of the trick