Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zkamvar committed May 16, 2018
1 parent fb32018 commit 6aa71b2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 15 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", comment = c(ORCID = "0000-0003-1458-7108")),
person(c("Javier", "F."), "Tabima", role = "aut",
Expand Down Expand Up @@ -61,4 +61,4 @@ Suggests:
cowplot
License: GPL-2 | GPL-3
VignetteBuilder: knitr
RoxygenNote: 6.0.1
RoxygenNote: 6.0.1.9000
16 changes: 15 additions & 1 deletion R/filter_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion R/internal.r
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ mlg.matrix <- function(x){
#
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
#==============================================================================#

#' @noRd
.PA.Ia.Rd <- function(pop, missing=NULL){
vard.vector <- NULL
numLoci <- ncol(pop@tab)
Expand Down
16 changes: 15 additions & 1 deletion man/filter_stats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/mlg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions vignettes/mlg.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down

0 comments on commit 6aa71b2

Please sign in to comment.