diff --git a/DESCRIPTION b/DESCRIPTION index 4e038fea..617b7b22 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: poppr Type: Package Title: Genetic Analysis of Populations with Mixed Reproduction -Version: 2.7.1.99-79 -Date: 2018-05-12 +Version: 2.7.1.99-85 +Date: 2018-05-16 Authors@R: c(person(c("Zhian", "N."), "Kamvar", role = c("cre", "aut"), email = "zkamvar@gmail.com", comment = c(ORCID = "0000-0003-1458-7108")), person(c("Javier", "F."), "Tabima", role = "aut", @@ -61,4 +61,4 @@ Suggests: cowplot License: GPL-2 | GPL-3 VignetteBuilder: knitr -RoxygenNote: 6.0.1 +RoxygenNote: 6.0.1.9000 diff --git a/R/filter_stats.R b/R/filter_stats.R index 8c69da3b..8a0d4c40 100644 --- a/R/filter_stats.R +++ b/R/filter_stats.R @@ -89,9 +89,23 @@ #' #' @author Zhian N. Kamvar, Jonah C. Brooks #' @examples +#' +#' # Basic usage example: Bruvo's Distance -------------------------------- #' data(Pinf) #' pinfreps <- fix_replen(Pinf, c(2, 2, 6, 2, 2, 2, 2, 2, 3, 3, 2)) -#' filter_stats(Pinf, distance = bruvo.dist, replen = pinfreps, plot = TRUE, threads = 1L) +#' bres <- filter_stats(Pinf, distance = bruvo.dist, replen = pinfreps, plot = TRUE, threads = 1L) +#' print(bres) # shows all of the statistics +#' +#' # Use these results with cutoff_filter() +#' print(thresh <- cutoff_predictor(bres$farthest$THRESHOLDS)) +#' mlg.filter(Pinf, distance = bruvo.dist, replen = pinfreps) <- thresh +#' Pinf +#' +#' # Different distances will give different results ----------------------- +#' nres <- filter_stats(Pinf, distance = nei.dist, plot = TRUE, threads = 1L, missing = "mean") +#' print(thresh <- cutoff_predictor(nres$farthest$THRESHOLDS)) +#' mlg.filter(Pinf, distance = nei.dist, missing = "mean") <- thresh +#' Pinf #==============================================================================# filter_stats <- function(x, distance = bitwise.dist, threshold = 1e6 + .Machine$double.eps^0.5, diff --git a/R/internal.r b/R/internal.r index bb70affb..cb7d6a55 100644 --- a/R/internal.r +++ b/R/internal.r @@ -315,7 +315,7 @@ mlg.matrix <- function(x){ # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # #==============================================================================# - +#' @noRd .PA.Ia.Rd <- function(pop, missing=NULL){ vard.vector <- NULL numLoci <- ncol(pop@tab) diff --git a/man/filter_stats.Rd b/man/filter_stats.Rd index 4cc3e0db..ee8932de 100644 --- a/man/filter_stats.Rd +++ b/man/filter_stats.Rd @@ -55,9 +55,23 @@ This function originally appeared in \href{http://dx.doi.org/10.5281/zenodo.17424}{DOI: 10.5281/zenodo.17424} } \examples{ + +# Basic usage example: Bruvo's Distance -------------------------------- data(Pinf) pinfreps <- fix_replen(Pinf, c(2, 2, 6, 2, 2, 2, 2, 2, 3, 3, 2)) -filter_stats(Pinf, distance = bruvo.dist, replen = pinfreps, plot = TRUE, threads = 1L) +bres <- filter_stats(Pinf, distance = bruvo.dist, replen = pinfreps, plot = TRUE, threads = 1L) +print(bres) # shows all of the statistics + +# Use these results with cutoff_filter() +print(thresh <- cutoff_predictor(bres$farthest$THRESHOLDS)) +mlg.filter(Pinf, distance = bruvo.dist, replen = pinfreps) <- thresh +Pinf + +# Different distances will give different results ----------------------- +nres <- filter_stats(Pinf, distance = nei.dist, plot = TRUE, threads = 1L, missing = "mean") +print(thresh <- cutoff_predictor(nres$farthest$THRESHOLDS)) +mlg.filter(Pinf, distance = nei.dist, missing = "mean") <- thresh +Pinf } \references{ ZN Kamvar, JC Brooks, and NJ Grünwald. 2015. Supplementary diff --git a/man/mlg.Rd b/man/mlg.Rd index d1f1ed08..30a28ef9 100755 --- a/man/mlg.Rd +++ b/man/mlg.Rd @@ -2,7 +2,6 @@ % Please edit documentation in R/mlg.r \name{mlg} \alias{mlg} -\alias{mlg} \alias{mlg.table} \alias{mlg.vector} \alias{mlg.crosspop} diff --git a/vignettes/mlg.Rmd b/vignettes/mlg.Rmd index bd90bac7..f2a72098 100644 --- a/vignettes/mlg.Rmd +++ b/vignettes/mlg.Rmd @@ -301,11 +301,11 @@ Notice how the information you see has changed. You can see that it's printed out that you have 5 **contracted** multilocus genotypes, but you have some cryptic code underneath: -| symbol | meaning | -|:----:|:----| -| **[t]** | threshold | +| symbol | meaning | +|:-------:|:-------------------------------------| +| **[t]** | threshold | | **[d]** | distance (can be matrix or function) | -| **[a]** | algorithm (see the next section) | +| **[a]** | algorithm (see the next section) | Genclone and snpclone objects will always remember what parameters were used for filtering multilocus genotypes, but the only catch is that, if you use your own @@ -415,7 +415,7 @@ This initial peak likely represents clones differentiated by a small set of random mutations. You can see this in the figure above at a threshold of ~0.11 for the "farthest neighbor" algorithm. -However, if this peak is not obvious, then another method is to look for the largest gap between all putative thresholds. For this, you can use the `cutoff_predictor()` function with the output of `filter_stats()`. It should be noted, however, that this method is not a perfect solution. If we take the results from above, we can find the threshold for each algorithm: +However, if this peak is not obvious, then another method is to look for the largest gap between all putative thresholds. For this, you can use the `cutoff_predictor()` function with the output of `filter_stats()`. It should be noted that this method is not a perfect solution. If we take the results from above, we can find the threshold for each algorithm: ```{r cutof_predictor} print(farthest_thresh <- cutoff_predictor(pinf_filtered$farthest$THRESHOLDS)) @@ -425,9 +425,11 @@ print(nearest_thresh <- cutoff_predictor(pinf_filtered$nearest$THRESHOLDS)) Now we can define multilocus lineages for *P. infestans* with the following criteria: - - Genetic Distance: Bruvo's Distance - - Filtering Algorithm: Farthest neighbor - - Threshold: `r signif(farthest_thresh, 3)` +| | | | +|:-------:|:----------|:----------| +| **[t]** | threshold | `r signif(farthest_thresh, 3)` | +| **[d]** | distance | Bruvo's Distance | +| **[a]** | algorithm | Farthest neighbor | ```{r pinf_thresh} mlg.filter(Pinf, distance = bruvo.dist, replen = pinfreps, algorithm = "f") <- farthest_thresh