diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6524d9e Binary files /dev/null and b/.DS_Store differ diff --git a/DESCRIPTION b/DESCRIPTION index 6d12378..a55047f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: assigner Type: Package Title: Assignment Analysis with GBS/RADseq Data using R -Version: 0.3.2 -Date: 2016-07-20 +Version: 0.3.3 +Date: 2016-09-22 Encoding: UTF-8 Authors@R: c( person("Thierry", "Gosselin", email = "thierrygosselin@icloud.com", role = c("aut", "cre")), diff --git a/R/.DS_Store b/R/.DS_Store new file mode 100644 index 0000000..3f5aaa8 Binary files /dev/null and b/R/.DS_Store differ diff --git a/R/fst_WC84.R b/R/fst_WC84.R index 380e5a0..59e0179 100644 --- a/R/fst_WC84.R +++ b/R/fst_WC84.R @@ -374,7 +374,7 @@ fst_WC84 <- function(data, # fst function compute_fst <- function(x, ci = ci, iteration.ci = iteration.ci, quantiles.ci = quantiles.ci) { # x = data.genotyped # test - + # x = data.genotyped %>% filter(POP_ID %in% c("upj", "dsj")) # Markers in common between all populations ******************************** pop.number <- n_distinct(x$POP_ID) @@ -505,19 +505,31 @@ fst_WC84 <- function(data, ) data.genotyped.het <- x %>% - mutate(het = ifelse(stri_sub(GT, 1, 3) != stri_sub(GT, 4, 6), 1, 0)) - + mutate( + het = ifelse(stri_sub(GT, 1, 3) != stri_sub(GT, 4, 6), 1, 0), + AL1 = stri_sub(GT, 1, 3), + AL2 = stri_sub(GT, 4, 6) + ) %>% + select(-GT) %>% + tidyr::gather(data = ., key = ALLELES_GROUP, value = ALLELES, -c(INDIVIDUALS, MARKERS, POP_ID, het)) %>% + select(-ALLELES_GROUP) %>% + group_by(MARKERS, POP_ID, ALLELES) %>% + summarise(n = length(het[het == 1])) %>% + group_by(MARKERS, ALLELES) %>% + tidyr::spread(data = ., key = POP_ID, value = n, fill = 0) %>% + tidyr::gather(data = ., key = POP_ID, value = mho, -c(MARKERS, ALLELES)) fst.stats.prep <- suppressWarnings( data.genotyped.het %>% - group_by(MARKERS, POP_ID) %>% + # group_by(MARKERS, POP_ID) %>% # = the number of heterozygote individuals per pop and markers - summarise(mho = sum(het, na.rm = TRUE)) %>% - group_by(MARKERS) %>% - tidyr::spread(data = ., key = POP_ID, value = mho) %>% - tidyr::gather(key = POP_ID, value = mho, -MARKERS) %>% - mutate(mho = as.numeric(stri_replace_na(str = mho, replacement = 0))) %>% - full_join(freq.al.locus.pop, by = c("POP_ID", "MARKERS")) %>% + # summarise(mho = sum(het, na.rm = TRUE)) %>% + # group_by(MARKERS) %>% + # tidyr::spread(data = ., key = POP_ID, value = mho) %>% + # tidyr::gather(key = POP_ID, value = mho, -MARKERS) %>% + # mutate(mho = as.numeric(stri_replace_na(str = mho, replacement = 0))) %>% + # full_join(freq.al.locus.pop, by = c("POP_ID", "MARKERS")) %>% + full_join(freq.al.locus.pop, by = c("POP_ID", "MARKERS", "ALLELES")) %>% mutate( mhom = round(((2 * nal * P - mho)/2), 0), dum = nal * (P - 2 * P^2) + mhom diff --git a/README.md b/README.md index 4785cad..7392eb2 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,11 @@ The Amazon image can be imported into Google Cloud Compute Engine to start a new ## New features Change log, version, new features and bug history now lives in the [NEWS.md file] (https://github.com/thierrygosselin/assigner/blob/master/NEWS.md) + +**v.0.3.3** +* `fst_WC84`: bug fix, the function was not properly configured for multi-allelic markers (e.g. microsatellite, and haplotype format from STACKS). Thanks to Craig McDougall for catching this. + + **v.0.3.2** * `assignment_mixture`: added a check that throws an error when pop.levels != the pop.id in strata diff --git a/man/.DS_Store b/man/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/man/.DS_Store differ diff --git a/vignettes/.DS_Store b/vignettes/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/vignettes/.DS_Store differ