Skip to content

Commit

Permalink
**v.0.3.**
Browse files Browse the repository at this point in the history
* `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.
  • Loading branch information
thierrygosselin committed Sep 22, 2016
1 parent a53b70b commit ee215b2
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 12 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre")),
Expand Down
Binary file added R/.DS_Store
Binary file not shown.
32 changes: 22 additions & 10 deletions R/fst_WC84.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added man/.DS_Store
Binary file not shown.
Binary file added vignettes/.DS_Store
Binary file not shown.

0 comments on commit ee215b2

Please sign in to comment.