Closed jgx65 closed 8 years ago
Ok that's good timing because I need to run some test with Laura Benestan data! Will give you an update on functions tested tomorrow Cheers Thierry
On Nov 25, 2015, at 09:29, Jerome Goudet notifications@github.com wrote:
hierfstat should not be able to read genindobjects, and several functions in hierfstat can take as argument a genindobject (basic.stats, wc, genet.dist, ...). In addition, genind2hierfstatdoes the conversion, and can take haploid or diploid data, as well as alleles encoded with letters (e.g. adegenet::H3N2. Would love to have feedbacks to make sure that it works. @thibautjombart @thierrygosselin @smanel @zkamvar
— Reply to this email directly or view it on GitHub.
We're on holiday stateside, but I will take a look at it within a few days. :thumbsup:
It looks good! I found a bug in genind2hierfstat, but I think I fixed that in #10. I tried the functions on the microbov data set, which has three levels of hierarchy.
library(hierfstat)
library(adegenet)
# Data setup phase
data(microbov)
strata(microbov) <- data.frame(other(microbov))
nameStrata(microbov) <- ~Country/Breed/Species
# Pre-define the hierarchy
hier(microbov) <- ~Country/Species/Breed
microbov
## /// GENIND OBJECT /////////
##
## // 704 individuals; 30 loci; 373 alleles; size: 1.1 Mb
##
## // Basic content
## @tab: 704 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: genind(tab = truenames(microbov)$tab, pop = truenames(microbov)$pop)
##
## // Optional content
## @pop: population of each individual (group size range: 30-61)
## @strata: a data frame with 3 columns ( Country, Breed, Species )
## @hierarchy: ~Country/Species/Breed
## @other: a list containing: coun breed spe
varcomp.glob(hier(microbov), genind2hierfstat(microbov)[-1])
## $loc
## [,1] [,2] [,3] [,4] [,5]
## INRA63 0.1173000960 0.0647794947 0.06361455 0.011578832 0.5530086
## INRA5 0.0121845683 0.0129382874 0.01430052 0.035836874 0.5399129
## ETH225 -0.0124319038 0.0487034259 0.04915075 0.026408664 0.6905444
## ILSTS5 0.0135110583 0.0517138841 0.04905979 0.010274610 0.4508076
## HEL5 0.0483275536 0.0303297523 0.06652854 0.050456662 0.6415094
## HEL1 0.1078680667 0.1253425099 0.03559172 0.021497255 0.5974212
## INRA35 -0.0107774636 0.0084973992 0.03558309 0.171926340 0.2904624
## ETH152 -0.0605934179 0.1338601503 0.03685872 0.025607431 0.5860534
## INRA23 0.0868319088 0.0371286049 0.04130543 0.053629048 0.6848306
## ETH10 0.0811586568 0.0799362964 0.09105508 0.030915671 0.5771429
## HEL9 0.0516898466 0.0761886429 0.03582657 0.020243629 0.6603221
## CSSM66 -0.0043924213 0.0152441827 0.07744402 0.039109865 0.7054598
## INRA32 0.0186643213 0.1600901977 0.04441658 0.022135523 0.5953079
## ETH3 0.0549178630 -0.0013820157 0.04428838 -0.009695299 0.7052023
## BM2113 0.0278982606 0.0521433738 0.06104839 -0.000034360 0.7979943
## BM1824 0.0438056290 0.0754409120 0.05561409 0.007952213 0.6384505
## HEL13 0.1090026640 0.1559971309 0.04365766 0.013740498 0.4534884
## INRA37 0.0992965084 0.0450839942 0.05822925 0.014709458 0.6396527
## BM1818 0.0720595020 0.0306564336 0.03409718 0.022358255 0.6474074
## ILSTS6 0.1201655247 0.0003883814 0.05854446 0.043729015 0.6285714
## MM12 -0.0585414257 0.1401026439 0.03442348 0.032276208 0.6603499
## CSRM60 -0.0134639321 0.1179904177 0.05900233 0.007710427 0.6569343
## ETH185 0.1083381232 0.0034178206 0.06052818 0.068641233 0.5941807
## HAUT24 0.0495419679 0.0245594116 0.04369654 0.024183879 0.7381295
## HAUT27 0.0228908786 0.0083714775 0.03555060 0.018656962 0.6762178
## TGLA227 -0.0025323999 0.1066869908 0.04828694 0.023681402 0.7722063
## TGLA126 0.0072856375 0.0330671939 0.03467997 0.018801416 0.6174785
## TGLA122 -0.0002594815 0.0507386030 0.05187441 0.009971784 0.6891117
## TGLA53 0.0167521176 0.0257066907 0.05028980 0.140398489 0.6810730
## SPS115 0.0494256183 -0.0146722427 0.04373537 0.070696634 0.4392387
##
## $overall
## Country Species Breed Ind Error
## 1.155924 1.699050 1.458282 1.027399 18.608471
##
## $F
## Country Species Breed Ind
## Total 0.04826581 0.11920995 0.18010079 0.22300000
## Country 0.00000000 0.07454197 0.13852080 0.18359558
## Species 0.00000000 0.00000000 0.06913207 0.11783745
## Breed 0.00000000 0.00000000 0.00000000 0.05232254
Great! Many thanks @zkamvar, looks cool!
hierfstat
should now be able to readgenind
objects, and several functions inhierfstat
can take as argument agenind
object (basic.stats
,wc
,genet.dist
, ...). In addition,genind2hierfstat
does the conversion, and can take haploid or diploid data, as well as alleles encoded with letters (e.g.adegenet::H3N2
). Would love to have feedbacks to make sure that it works. @thibautjombart @thierrygosselin @smanel @zkamvar