jgx65 / hierfstat

the hierfstat package
24 stars 14 forks source link

NeiFST_calcuation_error #63

Closed laxmangene7 closed 1 year ago

laxmangene7 commented 1 year ago

Hi,

I got persistence error while computing Neis fst, however, I could compute WCfst and betas. Please check this error below.

pairwise.neifst(dat[,-2],diploid=TRUE) Error in pairwise.neifst(dat[, -2], diploid = TRUE) : unused argument (diploid = TRUE) pairwise.neifst(dat[,-2]) df function (dat, diploid = TRUE) { if (is.genind(dat)) dat <- genind2hierfstat(dat) dat <- dat[order(dat[, 1]), ] pops <- unique(dat[, 1]) npop <- length(pops) fstmat <- matrix(nrow = npop, ncol = npop, dimnames = list(pops, pops)) if (is.factor(dat[, 1])) { dat[, 1] <- as.numeric(dat[, 1]) pops <- as.numeric(pops) } for (a in 2:npop) { for (b in 1:(a - 1)) { subdat <- dat[dat[, 1] == pops[a] | dat[, 1] == pops[b], ] fstmat[a, b] <- fstmat[b, a] <- wc(subdat, diploid = diploid)$FST } } fstmat } <bytecode: 0x7fcb06710c50>

When I tired it differently

hap.converted <- hap.read(hap.obj = hap2, data.col = 12) gbs object created successfully with 17246 markers and 215 individuals. diversity.stats <- gbs.diversity(hap = hap.converted, popGroups = lininfo) Computing Nei's diversity index... Done Numericalizing genotypes... Done Computing overall population Fst...Error: 'fstat' is not an exported object from 'namespace:hierfstat'

jgx65 commented 1 year ago

Hi, could you post a reproducible example? I cannot reproduce the error you are getting. Using the gtrunchier dataset of hierfstat for instance:

data(gtrunchier)

pairwise.neifst(gtrunchier[,-2],diploid=TRUE)
       1      2      3      4      5      6
1     NA 0.4746 0.4274 0.4459 0.3349 0.4129
2 0.4746     NA 0.7577 0.7725 0.6095 0.7159
3 0.4274 0.7577     NA 0.6236 0.5717 0.5317
4 0.4459 0.7725 0.6236     NA 0.5202 0.4670
5 0.3349 0.6095 0.5717 0.5202     NA 0.5130
6 0.4129 0.7159 0.5317 0.4670 0.5130     NA
laxmangene7 commented 1 year ago

Hi Jgx65,

Did you make any changes now? It worked now. Thanks!