diff --git a/.Rbuildignore b/.Rbuildignore index 0a62820b..6f8b414c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -24,3 +24,4 @@ vignettes/poppr_manual.Rmd ^pkgdown$ ^\.github$ ^docs$ +^CRAN-SUBMISSION$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 5e1a1de1..d2987eac 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,14 +1,14 @@ -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] + release: + types: [published] + schedule: + - cron: '0 4 * * 2' name: R-CMD-check @@ -22,70 +22,42 @@ jobs: fail-fast: false matrix: config: + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + TINYTEX_INSTALLER: TinyTex steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} - - - uses: r-lib/actions/setup-pandoc@v1 - - uses: r-lib/actions/setup-tinytex@v1 - - name: Install LaTeX packages - run: | - tlmgr install colortbl - tlmgr install mathtools - tlmgr install preprint - tlmgr install natbib - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-pandoc@v2 + - uses: r-lib/actions/setup-tinytex@v2 + # - name: Install LaTeX packages + # run: | + # tlmgr install colortbl + # tlmgr install mathtools + # tlmgr install preprint + # tlmgr install natbib + + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} + extra-packages: any::rcmdcheck, local::. + needs: check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 00000000..20269f91 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,50 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: test-coverage + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, local::. + needs: check + + - name: Test coverage + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 00000000..f8b77e15 --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 2.9.4 +Date: 2023-03-23 00:53:20 UTC +SHA: b43ac8e7096d534fab19e3a7834a42215b6e9081 diff --git a/DESCRIPTION b/DESCRIPTION index f11b3b47..9c721078 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: poppr Type: Package Title: Genetic Analysis of Populations with Mixed Reproduction -Version: 2.9.3 +Version: 2.9.4 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", @@ -33,7 +33,7 @@ Description: Population genetic analyses for hierarchical analysis of partially clonal populations built upon the architecture of the 'adegenet' package. Originally described in Kamvar, Tabima, and Grünwald (2014) with version 2.0 described in Kamvar, Brooks, and - Grünwald (2015) . + Grünwald (2015) . MailingList: https://groups.google.com/d/forum/poppr BugReports: https://github.com/grunwaldlab/poppr/issues/ Depends: @@ -63,8 +63,8 @@ Suggests: knitr, rmarkdown, poweRlaw, - cowplot, - RClone + cowplot +Config/Needs/check: dbailleul/RClone License: GPL-2 | GPL-3 VignetteBuilder: knitr -RoxygenNote: 7.1.1 +RoxygenNote: 7.2.3 diff --git a/NEWS.md b/NEWS.md index 0245bb98..5eefee6c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,19 @@ +poppr 2.9.4 +=========== + +CRAN MAINTENANCE +---------------- + +* a function declaration was added for `SEXP omp_test()` +* failing tests were fixed. +* code where object classes were compared with `==` was fixed to use `inherits()` + +DEPENDENCIES +------------ + +* {RClone} has been removed as a suggested package as it was archived on CRAN + some time ago. + poppr 2.9.3 =========== diff --git a/R/bootstraping.R b/R/bootstraping.R index 9882a1a7..061e1c52 100644 --- a/R/bootstraping.R +++ b/R/bootstraping.R @@ -588,7 +588,7 @@ diversity_boot <- function(tab, n, n.boot = 1L, n.rare = NULL, H = TRUE, #' one clear method for calculating confidence intervals. A suggestion for #' correction in Shannon's index is to center the CI around the observed #' statistic (Marcon, 2012), but there are theoretical limitations to this. -#' For details, see . +#' For details, see . #' } #' #' \subsection{User-defined functions}{ @@ -604,6 +604,7 @@ diversity_boot <- function(tab, n, n.boot = 1L, n.rare = NULL, H = TRUE, #' vegan::rarefy(t(as.matrix(x)), 10)`). #' } #' @export +#' @md #' @seealso [diversity_boot()] [diversity_stats()] #' [poppr()] [boot::boot()] [boot::norm.ci()] #' [boot::boot.ci()] diff --git a/R/data_subset.r b/R/data_subset.r index 296429d8..5bb1444b 100644 --- a/R/data_subset.r +++ b/R/data_subset.r @@ -296,9 +296,9 @@ popsub <- function(gid, sublist="ALL", exclude=NULL, blacklist=NULL, mat=NULL, d if (!is.null(exclude)){ # If both the sublist and exclude are numeric or character. - if (is.numeric(sublist) & is.numeric(exclude) | class(sublist) == class(exclude)){ + if (is.numeric(sublist) && is.numeric(exclude) || identical(class(sublist), class(exclude))){ sublist <- sublist[!sublist %in% exclude] - } else if (is.numeric(sublist) & class(exclude) == "character"){ + } else if (is.numeric(sublist) && inherits(exclude, "character")){ # if the sublist is numeric and exclude is a character. eg s=1:10, b="USA" sublist <- sublist[sublist %in% which(!popnames %in% exclude)] } else { diff --git a/R/distances.r b/R/distances.r index 895d0ba5..9f19722e 100644 --- a/R/distances.r +++ b/R/distances.r @@ -205,7 +205,7 @@ diss.dist <- function(x, percent=FALSE, mat=FALSE){ #' Prevosti A. (1974) La distancia genetica entre poblaciones. Miscellanea #' Alcobe, 68, 109-118. #' -#' Prevosti A., Oca\~na J. and Alonso G. (1975) Distances +#' Prevosti A., Ocana J. and Alonso G. (1975) Distances #' between populations of Drosophila subobscura, based on chromosome #' arrangements frequencies. Theoretical and Applied Genetics, 45, 231-241. #' diff --git a/R/internal.r b/R/internal.r index e52ef7fe..56d3499c 100644 --- a/R/internal.r +++ b/R/internal.r @@ -197,9 +197,9 @@ sub_index <- function(pop, sublist="ALL", exclude=NULL){ # Treating anything present in exclude. if (!is.null(exclude)){ # If both the sublist and exclude are numeric or character. - if (is.numeric(sublist) & is.numeric(exclude) | class(sublist) == class(exclude)){ + if (is.numeric(sublist) && is.numeric(exclude) || identical(class(sublist), class(exclude))) { sublist <- sublist[!sublist %in% exclude] - } else if (is.numeric(sublist) & class(exclude) == "character"){ + } else if (is.numeric(sublist) && inherits(exclude, "character")){ # if the sublist is numeric and exclude is a character. eg s=1:10, b="USA" sublist <- sublist[sublist %in% which(!popNames(pop) %in% exclude)] } else { diff --git a/R/poppr.R b/R/poppr.R index fb363601..e057702b 100644 --- a/R/poppr.R +++ b/R/poppr.R @@ -84,7 +84,7 @@ #' #' Examples of analyses are available in a primer written by Niklaus J. #' Grünwald, Zhian N. Kamvar, and Sydney E. Everhart at -#' .} +#' .} #' #' \subsection{Getting help}{ If you have a specific question or issue with #' \pkg{poppr}, feel free to contribute to the google group at diff --git a/README.md b/README.md index 51455bbf..83a96a96 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Poppr version 2 -[![R-CMD-check](https://github.com/grunwaldlab/poppr/workflows/R-CMD-check/badge.svg)](https://github.com/grunwaldlab/poppr/actions) +[![R-CMD-check](https://github.com/grunwaldlab/poppr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/grunwaldlab/poppr/actions/workflows/R-CMD-check.yaml) ## What is *poppr*? @@ -98,7 +98,7 @@ New features are occasionally added to {poppr}, but it can take time for it to get to CRAN. If you know that you want the latest version of {poppr}, (which will contain bug fixes and new features to be included in future releases), then you can use the custom R-Universe repository, which is updated hourly: - + To install poppr from the R-Universe, you can use the following code: diff --git a/cran-comments.md b/cran-comments.md index 3dc773c8..f5293cba 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,23 +1,5 @@ -# Poppr version 2.9.3 +# Poppr version 2.9.4 -This update rearranges the C files to declare all non-R headers before R headers to address the openmp failures in clang13 as pointed out by Prof. Ripley. - -## Test environments - -* local macOS install, R 4.1.1 -* local ubuntu 20.04 install, R 4.1.1, R devel -* windows R Under development (unstable) - -## R CMD check results - -Ubuntu Linux: OK -macOS: OK -Windows: OK - - -## Downstream dependencies - -- popprxl: OK -- vcfR: OK -- adegenet: OK +This fixes broken tests, provides a declaration for an exported C function, and fixes object class comparison to use identical() +This also removes RClone from Suggests. There is no user-facing code that contains RClone and it is an archived package on CRAN. diff --git a/inst/CITATION b/inst/CITATION index b8a728d6..c1fc8cb8 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -3,9 +3,9 @@ umlaut <- iconv("\x9f", from = "MAC", to = "UTF-8") # paste0("u", "\u0308") header <- paste("To cite poppr in publications or presentations, please specify poppr version", meta$Version, "and with the following citation:") citHeader(header) -citEntry(entry = 'article', +bibentry(bibtype = 'article', title = "\\textit{Poppr}: an {R} package for genetic analysis of populations with clonal, partially clonal, and/or sexual reproduction.", - author = personList(as.person("Zhian N. Kamvar"), + author = c(as.person("Zhian N. Kamvar"), as.person("Javier F. Tabima"), as.person(paste0("Niklaus J. Gr", umlaut, "nwald")) ), @@ -22,9 +22,9 @@ citEntry(entry = 'article', textVersion = paste0("Kamvar ZN, Tabima JF, Grünwald NJ. (2014) Poppr: an R package for genetic analysis of populations with clonal, partially clonal, and/or sexual reproduction. PeerJ 2:e281. doi: 10.7717/peerj.281") ) -citEntry(entry = 'article', +bibentry(bibtype = 'article', title = "{Novel R tools for analysis of genome-wide population genetic data with emphasis on clonality}", - author = personList(as.person("Zhian N. Kamvar"), + author = c(as.person("Zhian N. Kamvar"), as.person("Jonah C. Brooks"), as.person(paste0("Niklaus J. Gr", umlaut, "nwald")) ), diff --git a/man/bruvo.dist.Rd b/man/bruvo.dist.Rd index 73257c75..e3adc89d 100755 --- a/man/bruvo.dist.Rd +++ b/man/bruvo.dist.Rd @@ -102,11 +102,11 @@ Bruvo's distance between two alleles is calculated as } \section{Functions}{ \itemize{ -\item \code{bruvo.between}: Bruvo's distance between a query and a reference +\item \code{bruvo.between()}: Bruvo's distance between a query and a reference Only diferences between query individuals and reference individuals will be reported All other values are NaN -}} +}} \note{ Do not use missingno with this function. \subsection{Missing alleles and Bruvo's distance in \pkg{poppr} versions < 2.5}{ diff --git a/man/diversity_boot.Rd b/man/diversity_boot.Rd index 5c1da7f7..7a476d3a 100644 --- a/man/diversity_boot.Rd +++ b/man/diversity_boot.Rd @@ -59,14 +59,16 @@ Bootstrapping is performed in three ways: \itemize{ \item if \code{n.rare} is a number greater than zero, then bootstrapping is performed by randomly sampling without replacement \emph{n.rare} -samples from the data.\preformatted{\\item if `n.boot` is greater than 1, bootstrapping is performed by +samples from the data. + +\if{html}{\out{
}}\preformatted{\\item if `n.boot` is greater than 1, bootstrapping is performed by sampling n.boot samples from a multinomial distribution weighted by the proportion of each MLG in the data. \\item if `n.boot` is less than 2, bootstrapping is performed by sampling N samples from a multinomial distribution weighted by the proportion of each MLG in the data. -} +}\if{html}{\out{
}} } diff --git a/man/diversity_ci.Rd b/man/diversity_ci.Rd index ad2df630..bc4c8576 100644 --- a/man/diversity_ci.Rd +++ b/man/diversity_ci.Rd @@ -19,59 +19,60 @@ diversity_ci( ) } \arguments{ -\item{tab}{a [genind()], [genclone()], -[snpclone()], OR a matrix produced from -[poppr::mlg.table()].} +\item{tab}{a \code{\link[=genind]{genind()}}, \code{\link[=genclone]{genclone()}}, +\code{\link[=snpclone]{snpclone()}}, OR a matrix produced from +\code{\link[=mlg.table]{mlg.table()}}.} -\item{n}{an integer defining the number of bootstrap replicates (defaults to +\item{n}{an integer defining the number of bootstrap replicates (defaults to 1000).} \item{n.boot}{an integer specifying the number of samples to be drawn in each -bootstrap replicate. If `n.boot` < 2 (default), the number of samples +bootstrap replicate. If \code{n.boot} < 2 (default), the number of samples drawn for each bootstrap replicate will be equal to the number of samples in the data set. See Details.} \item{ci}{the percent for confidence interval.} -\item{total}{argument to be passed on to [poppr::mlg.table()] if -`tab` is a genind object.} +\item{total}{argument to be passed on to \code{\link[=mlg.table]{mlg.table()}} if +\code{tab} is a genind object.} -\item{rarefy}{if `TRUE`, bootstrapping will be performed on the smallest -population size or the value of `n.rare`, whichever is larger. -Defaults to `FALSE`, indicating that bootstrapping will be performed +\item{rarefy}{if \code{TRUE}, bootstrapping will be performed on the smallest +population size or the value of \code{n.rare}, whichever is larger. +Defaults to \code{FALSE}, indicating that bootstrapping will be performed respective to each population size.} -\item{n.rare}{an integer specifying the smallest size at which to resample -data. This is only used if `rarefy = TRUE`.} +\item{n.rare}{an integer specifying the smallest size at which to resample +data. This is only used if \code{rarefy = TRUE}.} -\item{plot}{If `TRUE` (default), boxplots will be produced for each -population, grouped by statistic. Colored dots will indicate the observed -value.This plot can be retrieved by using `p <- last_plot()` from the +\item{plot}{If \code{TRUE} (default), boxplots will be produced for each +population, grouped by statistic. Colored dots will indicate the observed +value.This plot can be retrieved by using \code{p <- last_plot()} from the \pkg{ggplot2} package.} -\item{raw}{if `TRUE` (default) a list containing three elements will be +\item{raw}{if \code{TRUE} (default) a list containing three elements will be returned} -\item{center}{if `TRUE` (default), the confidence interval will be -centered around the observed statistic. Otherwise, if `FALSE`, the -confidence interval will be bias-corrected normal CI as reported from -[boot::boot.ci()]} +\item{center}{if \code{TRUE} (default), the confidence interval will be +centered around the observed statistic. Otherwise, if \code{FALSE}, the +confidence interval will be bias-corrected normal CI as reported from +\code{\link[boot:boot.ci]{boot::boot.ci()}}} -\item{...}{parameters to be passed on to [boot::boot()] and -[diversity_stats()]} +\item{...}{parameters to be passed on to \code{\link[boot:boot]{boot::boot()}} and +\code{\link[=diversity_stats]{diversity_stats()}}} } \value{ \subsection{raw = TRUE}{ - - - **obs** a matrix with observed statistics in columns, - populations in rows - - **est** a matrix with estimated statistics in columns, - populations in rows - - **CI** an array of 3 dimensions giving the lower and upper - bound, the index measured, and the population. - - **boot** a list containing the output of - [boot::boot()] for each population. - } +\itemize{ +\item \strong{obs} a matrix with observed statistics in columns, +populations in rows +\item \strong{est} a matrix with estimated statistics in columns, +populations in rows +\item \strong{CI} an array of 3 dimensions giving the lower and upper +bound, the index measured, and the population. +\item \strong{boot} a list containing the output of +\code{\link[boot:boot]{boot::boot()}} for each population. +} +} \subsection{raw = FALSE}{ a data frame with the statistic observations, estimates, and confidence intervals in columns, and populations in rows. Note @@ -79,77 +80,76 @@ that the confidence intervals are converted to characters and rounded to three decimal places. } } \description{ -This function is for calculating bootstrap statistics and their confidence -intervals. It is important to note that the calculation of confidence -intervals is not perfect (See Details). Please be cautious when interpreting +This function is for calculating bootstrap statistics and their confidence +intervals. It is important to note that the calculation of confidence +intervals is not perfect (See Details). Please be cautious when interpreting the results. } \details{ \subsection{Bootstrapping}{ - For details on the bootstrapping procedures, see - [diversity_boot()]. Default bootstrapping is performed by - sampling \strong{N} samples from a multinomial distribution weighted by the - relative multilocus genotype abundance per population where \strong{N} is - equal to the number of samples in the data set. If \strong{n.boot} > 2, - then \strong{n.boot} samples are taken at each bootstrap replicate. When - `rarefy = TRUE`, then samples are taken at the smallest population - size without replacement. This will provide confidence intervals for all - but the smallest population. - } - \subsection{Confidence intervals}{ - Confidence intervals are derived from the function - [boot::norm.ci()]. This function will attempt to correct for bias - between the observed value and the bootstrapped estimate. When `center - = TRUE` (default), the confidence interval is calculated from the - bootstrapped distribution and centered around the bias-corrected estimate - as prescribed in Marcon (2012). This method can lead to undesirable - properties, such as the confidence interval lying outside of the maximum - possible value. For rarefaction, the confidence interval is simply - determined by calculating the percentiles from the bootstrapped - distribution. If you want to calculate your own confidence intervals, you - can use the results of the permutations stored in the `$boot` element - of the output. - } - \subsection{Rarefaction}{ - Rarefaction in the sense of this function is simply sampling a subset of - the data at size **n.rare**. The estimates derived from this method - have straightforward interpretations and allow you to compare diversity - across populations since you are controlling for sample size. - } - \subsection{Plotting}{ Results are plotted as boxplots with point - estimates. If there is no rarefaction applied, confidence intervals are - displayed around the point estimates. The boxplots represent the actual - values from the bootstrapping and will often appear below the estimates and - confidence intervals. - } +For details on the bootstrapping procedures, see +\code{\link[=diversity_boot]{diversity_boot()}}. Default bootstrapping is performed by +sampling \strong{N} samples from a multinomial distribution weighted by the +relative multilocus genotype abundance per population where \strong{N} is +equal to the number of samples in the data set. If \strong{n.boot} > 2, +then \strong{n.boot} samples are taken at each bootstrap replicate. When +\code{rarefy = TRUE}, then samples are taken at the smallest population +size without replacement. This will provide confidence intervals for all +but the smallest population. +} +\subsection{Confidence intervals}{ +Confidence intervals are derived from the function +\code{\link[boot:norm.ci]{boot::norm.ci()}}. This function will attempt to correct for bias +between the observed value and the bootstrapped estimate. When \code{center = TRUE} (default), the confidence interval is calculated from the +bootstrapped distribution and centered around the bias-corrected estimate +as prescribed in Marcon (2012). This method can lead to undesirable +properties, such as the confidence interval lying outside of the maximum +possible value. For rarefaction, the confidence interval is simply +determined by calculating the percentiles from the bootstrapped +distribution. If you want to calculate your own confidence intervals, you +can use the results of the permutations stored in the \verb{$boot} element +of the output. +} +\subsection{Rarefaction}{ +Rarefaction in the sense of this function is simply sampling a subset of +the data at size \strong{n.rare}. The estimates derived from this method +have straightforward interpretations and allow you to compare diversity +across populations since you are controlling for sample size. +} +\subsection{Plotting}{ Results are plotted as boxplots with point +estimates. If there is no rarefaction applied, confidence intervals are +displayed around the point estimates. The boxplots represent the actual +values from the bootstrapping and will often appear below the estimates and +confidence intervals. +} } \note{ -\subsection{Confidence interval calculation}{ Almost all of the statistics - supplied here have a maximum when all genotypes are equally represented. - This means that bootstrapping the samples will always be downwardly biased. - In many cases, the confidence intervals from the bootstrapped distribution - will fall outside of the observed statistic. The reported confidence - intervals here are reported by assuming the variance of the bootstrapped - distribution is the same as the variance around the observed statistic. As - different statistics have different properties, there will not always be - one clear method for calculating confidence intervals. A suggestion for - correction in Shannon's index is to center the CI around the observed - statistic (Marcon, 2012), but there are theoretical limitations to this. - For details, see . - } - - \subsection{User-defined functions}{ - While it is possible to use custom functions with this, there are three - important things to remember when using these functions: - - 1. The function must return a single value. - 2. The function must allow for both matrix and vector inputs - 3. The function name cannot match or partially match any arguments - from [boot::boot()] - - Anonymous functions are okay \cr(e.g. `function(x) - vegan::rarefy(t(as.matrix(x)), 10)`). - } +\subsection{Confidence interval calculation}{ Almost all of the statistics +supplied here have a maximum when all genotypes are equally represented. +This means that bootstrapping the samples will always be downwardly biased. +In many cases, the confidence intervals from the bootstrapped distribution +will fall outside of the observed statistic. The reported confidence +intervals here are reported by assuming the variance of the bootstrapped +distribution is the same as the variance around the observed statistic. As +different statistics have different properties, there will not always be +one clear method for calculating confidence intervals. A suggestion for +correction in Shannon's index is to center the CI around the observed +statistic (Marcon, 2012), but there are theoretical limitations to this. +For details, see \url{https://stats.stackexchange.com/q/156235/49413}. +} + +\subsection{User-defined functions}{ +While it is possible to use custom functions with this, there are three +important things to remember when using these functions: + +\if{html}{\out{
}}\preformatted{1. The function must return a single value. +2. The function must allow for both matrix and vector inputs +3. The function name cannot match or partially match any arguments +from [boot::boot()] +}\if{html}{\out{
}} + +Anonymous functions are okay \cr(e.g. \code{function(x) vegan::rarefy(t(as.matrix(x)), 10)}). +} } \examples{ library(poppr) @@ -185,14 +185,14 @@ diversity_ci(Pinf, 1000L, CF = CF, rarefy = TRUE, raw = FALSE) } \references{ -Marcon, E., Herault, B., Baraloto, C. and Lang, G. (2012). The Decomposition +Marcon, E., Herault, B., Baraloto, C. and Lang, G. (2012). The Decomposition of Shannon’s Entropy and a Confidence Interval for Beta Diversity. -*Oikos* 121(4): 516-522. +\emph{Oikos} 121(4): 516-522. } \seealso{ -[diversity_boot()] [diversity_stats()] - [poppr()] [boot::boot()] [boot::norm.ci()] - [boot::boot.ci()] +\code{\link[=diversity_boot]{diversity_boot()}} \code{\link[=diversity_stats]{diversity_stats()}} +\code{\link[=poppr]{poppr()}} \code{\link[boot:boot]{boot::boot()}} \code{\link[boot:norm.ci]{boot::norm.ci()}} +\code{\link[boot:boot.ci]{boot::boot.ci()}} } \author{ Zhian N. Kamvar diff --git a/man/genetic_distance.Rd b/man/genetic_distance.Rd index e565334a..4fcb892f 100644 --- a/man/genetic_distance.Rd +++ b/man/genetic_distance.Rd @@ -103,7 +103,7 @@ Molecular markers, natural history and evolution. Chapman & Hall, London. Prevosti A. (1974) La distancia genetica entre poblaciones. Miscellanea Alcobe, 68, 109-118. -Prevosti A., Oca\~na J. and Alonso G. (1975) Distances +Prevosti A., Ocana J. and Alonso G. (1975) Distances between populations of Drosophila subobscura, based on chromosome arrangements frequencies. Theoretical and Applied Genetics, 45, 231-241. diff --git a/man/poppr-package.Rd b/man/poppr-package.Rd index 752b2f52..7b9172ba 100644 --- a/man/poppr-package.Rd +++ b/man/poppr-package.Rd @@ -45,7 +45,7 @@ vignette, and details for working with multilocus genotypes are in Examples of analyses are available in a primer written by Niklaus J. Grünwald, Zhian N. Kamvar, and Sydney E. Everhart at -\url{http://grunwaldlab.github.io/Population_Genetics_in_R/}.} +\url{https://grunwaldlab.github.io/Population_Genetics_in_R/}.} \subsection{Getting help}{ If you have a specific question or issue with \pkg{poppr}, feel free to contribute to the google group at diff --git a/man/snpclone-method.Rd b/man/snpclone-method.Rd index 8a2fb85f..cec9130f 100644 --- a/man/snpclone-method.Rd +++ b/man/snpclone-method.Rd @@ -40,8 +40,6 @@ mlg object into an MLG class object.} Default methods for subsetting snpclone objects. } \author{ -Zhian N. Kamvar - Zhian N. Kamvar } \keyword{internal} diff --git a/man/unique-methods.Rd b/man/unique-methods.Rd index 1c6cf834..0e40346a 100644 --- a/man/unique-methods.Rd +++ b/man/unique-methods.Rd @@ -1,13 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/aaaMLGmethods.R \docType{methods} -\name{unique,MLG,ANY-method} -\alias{unique,MLG,ANY-method} +\name{unique,MLG-method} \alias{unique,MLG-method} +\alias{unique,MLG,ANY-method} \alias{duplicated,MLG-method} \title{Unique and Duplicated implementations for MLG objects} \usage{ -\S4method{unique}{MLG,ANY}(x, incomparables = FALSE, ...) +\S4method{unique}{MLG}(x, incomparables = FALSE, ...) \S4method{duplicated}{MLG}(x, incomparables = FALSE, ...) } diff --git a/src/init.c b/src/init.c index 46ec08a5..1c3de7b1 100644 --- a/src/init.c +++ b/src/init.c @@ -21,7 +21,7 @@ extern SEXP get_pgen_matrix_genind(SEXP, SEXP, SEXP, SEXP); extern SEXP mlg_round_robin(SEXP); extern SEXP msn_tied_edges(SEXP, SEXP, SEXP); extern SEXP neighbor_clustering(SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP omp_test(); +extern SEXP omp_test(void); extern SEXP pairdiffs(SEXP); extern SEXP pairwise_covar(SEXP); extern SEXP permute_shuff(SEXP, SEXP, SEXP); diff --git a/src/omp_test.c b/src/omp_test.c index 9f0c0b99..1b4a9953 100644 --- a/src/omp_test.c +++ b/src/omp_test.c @@ -2,9 +2,11 @@ #include #include +SEXP omp_test(void); + // Simple function to check for openMP support // Returns 1 if openMP is supported, 0 if it is not. -SEXP omp_test() +SEXP omp_test(void) { SEXP Rout; PROTECT(Rout = allocVector(INTSXP,1)); diff --git a/tests/testthat/test-msn.R b/tests/testthat/test-msn.R index 99636aca..c7e34af5 100644 --- a/tests/testthat/test-msn.R +++ b/tests/testthat/test-msn.R @@ -101,10 +101,6 @@ expect_vertex_attr <- function(g, a){ eval(bquote(expect_equal(igraph::vertex_attr_names(.(g$graph)), .(a)))) } -expect_vertex_size_scale <- function(g, s){ - eval(bquote(expect_equal(sort(igraph::vertex_attr(.(g$graph), "size")^2), - sort(.(s))))) -} #' Testing distance tables #' @@ -434,11 +430,6 @@ bpc <- bruvo.dist(pc, replen = rep(1, 10)) bmsn <- bruvo.msn(pc, replen = rep(1, 10), showplot = FALSE) pmsn <- poppr.msn(pc, bpc, showplot = FALSE) -test_that("nodes are properly scaled", { - expect_vertex_size_scale(bmsn, as.integer(table(mll(pc)))) - expect_vertex_size_scale(pmsn, as.integer(table(mll(pc)))) -}) - test_that("a warning is thrown if there are no populations to subset", { skip_on_cran() pc2 <- pc