diff --git a/DESCRIPTION b/DESCRIPTION
index 75b0d99..1d692b3 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,31 +2,30 @@ Package: PoolTestR
Title: Prevalence and Regression for Pool-Tested (Group-Tested) Data
Version: 0.2.0
Authors@R: c(
- person(given = "Angus", family = "McLure", role = c("aut", "cre"),
- email = "angus.mclure@anu.edu.au",comment = c(ORCID = "0000-0003-2551-3059") ),
- person(given = "Caitlin", family = "Cherryh", role = c("ctb"),
- comment = c(ORCID = "0000-0001-6146-4376") )
- )
+ person("Angus", "McLure", , "angus.mclure@anu.edu.au", role = c("aut", "cre"),
+ comment = c(ORCID = "0000-0003-2551-3059")),
+ person("Caitlin", "Cherryh", role = "ctb",
+ comment = c(ORCID = "0000-0001-6146-4376"))
+ )
+Description: An easy-to-use tool for working with presence/absence tests
+ on 'pooled' or 'grouped' samples. The primary application is for
+ estimating prevalence of a marker in a population based on the results
+ of tests on pooled specimens. This sampling method is often employed
+ in surveillance of rare conditions in humans or animals (e.g.
+ molecular xenomonitoring). The package was initially conceived as an
+ R-based alternative to the molecular xenomonitoring software,
+ 'PoolScreen' . However,
+ it goes further, allowing for estimates of prevalence to be adjusted
+ for hierarchical sampling frames, and perform flexible mixed-effect
+ regression analyses (McLure et al. Environmental Modelling and
+ Software. ). The package is
+ currently in early stages, however more features are planned or in the
+ works: e.g. adjustments for imperfect test specificity/sensitivity,
+ functions for helping with optimal experimental design, and functions
+ for spatial modelling.
+License: GPL (>= 3)
URL: https://github.com/AngusMcLure/PoolTestR
BugReports: https://github.com/AngusMcLure/PoolTestR
-Description: An easy-to-use tool for working with presence/absence tests on 'pooled'
- or 'grouped' samples. The primary application is for estimating prevalence of
- a marker in a population based on the results of tests on pooled specimens.
- This sampling method is often employed in surveillance of rare conditions in
- humans or animals (e.g. molecular xenomonitoring). The package was initially
- conceived as an R-based alternative to the molecular xenomonitoring software,
- 'PoolScreen' . However, it goes
- further, allowing for estimates of prevalence to be adjusted for hierarchical
- sampling frames, and perform flexible mixed-effect regression analyses
- (McLure et al. Environmental Modelling and Software.
- ). The package is currently in early stages,
- however more features are planned or in the works: e.g. adjustments for
- imperfect test specificity/sensitivity, functions for helping with optimal
- experimental design, and functions for spatial modelling.
-License: GPL (>= 3)
-Encoding: UTF-8
-LazyData: true
-Biarch: true
Depends:
R (>= 3.4.0)
Imports:
@@ -37,10 +36,14 @@ Imports:
progress,
Rcpp (>= 0.12.0),
RcppParallel (>= 5.0.1),
+ rlang,
rstan (>= 2.26.0),
rstantools (>= 2.3.1.1),
stats,
- stringr
+ stringr,
+ tibble
+Suggests:
+ covr
LinkingTo:
BH (>= 1.66.0),
Rcpp (>= 0.12.0),
@@ -48,8 +51,9 @@ LinkingTo:
RcppParallel (>= 5.0.1),
rstan (>= 2.26.0),
StanHeaders (>= 2.26.0)
-SystemRequirements: GNU make
-RoxygenNote: 7.3.2
+Biarch: true
+Encoding: UTF-8
Language: en-AU
-Suggests:
- covr
+LazyData: true
+RoxygenNote: 7.3.2
+SystemRequirements: GNU make
diff --git a/NAMESPACE b/NAMESPACE
index 6f51654..59bbf36 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -15,4 +15,5 @@ import(Rcpp)
import(dplyr)
import(methods)
import(rstan)
+importFrom(rlang,.data)
useDynLib(PoolTestR, .registration = TRUE)
diff --git a/R/HierPoolPrev.R b/R/HierPoolPrev.R
index ecd9054..dc003e1 100644
--- a/R/HierPoolPrev.R
+++ b/R/HierPoolPrev.R
@@ -184,14 +184,14 @@ HierPoolPrev <- function(data,result,poolSize,hierarchy,...,
cores = cores,
control = control)
#return(sfit)
- sfit <- extract(sfit) %>% dplyr::as_tibble() %>% rowwise()
+ sfit <- extract(sfit) %>% tibble::as_tibble() %>% rowwise()
prevICC <- sfit %>%
- transmute(prev = meanlinknormal(Intercept,
- total_group_sd,
+ transmute(prev = meanlinknormal(.data$Intercept,
+ .data$total_group_sd,
stats::plogis),
- ICC = t(ICC(Intercept[1],
- group_sd,
+ ICC = t(ICC(.data$Intercept[1],
+ .data$group_sd,
.mean = prev,
link = 'logit',
method = 'approx')))
@@ -207,7 +207,7 @@ HierPoolPrev <- function(data,result,poolSize,hierarchy,...,
estimate.type = 'consistent'
}
- out <- dplyr::tibble(PrevBayes =
+ out <- tibble::tibble(PrevBayes =
switch(estimate.type,
consistent = mean(prev),
zero = 0)
@@ -283,11 +283,11 @@ print.HierPoolPrevOutput <- function(x, ...) {
icc_names <- attr(x$ICC, "dimnames")[[2]]
trimmed_object <- x %>%
mutate(PrevBayes = paste0(" ",
- format((PrevBayes*100), digits = 2, nsmall = 2),
+ format((.data$PrevBayes*100), digits = 2, nsmall = 2),
" (",
- format((CrILow*100), digits = 2, nsmall = 2),
+ format((.data$CrILow*100), digits = 2, nsmall = 2),
" - ",
- format((CrIHigh*100), digits = 2, nsmall = 2),
+ format((.data$CrIHigh*100), digits = 2, nsmall = 2),
")"),
.keep = "unused") %>%
select(-contains("ICC", ignore.case = TRUE)) %>%
diff --git a/R/PoolPrev.R b/R/PoolPrev.R
index d271ee7..b5aed09 100644
--- a/R/PoolPrev.R
+++ b/R/PoolPrev.R
@@ -167,7 +167,7 @@ PoolPrev <- function(data,result,poolSize,...,
}
#initialise output object
- out <- dplyr::tibble(NumberOfPools = sdata$N,
+ out <- tibble::tibble(NumberOfPools = sdata$N,
NumberPositive = sum(sdata$Result))
#if there is at least one positive and one negative result
@@ -318,11 +318,11 @@ print.PoolPrevOutput <- function(x, ...) {
formatted_output <- as.data.frame(
ungroup(x) %>%
mutate(PrevMLE = paste0(" ",
- format((PrevMLE*100), digits = 2, nsmall = 2),
+ format((.data$PrevMLE*100), digits = 2, nsmall = 2),
" (",
- format((CILow*100), digits = 2, nsmall = 2),
+ format((.data$CILow*100), digits = 2, nsmall = 2),
" - ",
- format((CIHigh*100), digits = 2, nsmall = 2),
+ format((.data$CIHigh*100), digits = 2, nsmall = 2),
")"),
.keep = "unused") %>%
rename("PrevMLE % " = "PrevMLE")
@@ -332,11 +332,11 @@ print.PoolPrevOutput <- function(x, ...) {
formatted_output <- as.data.frame(
formatted_output %>%
mutate(PrevBayes = paste0(" ",
- format((PrevBayes*100), digits = 2, nsmall = 2),
+ format((.data$PrevBayes*100), digits = 2, nsmall = 2),
" (",
- format((CrILow*100), digits = 2, nsmall = 2),
+ format((.data$CrILow*100), digits = 2, nsmall = 2),
" - ",
- format((CrIHigh*100), digits = 2, nsmall = 2),
+ format((.data$CrIHigh*100), digits = 2, nsmall = 2),
")"),
.keep = "unused") %>%
rename("PrevBayes % " = "PrevBayes")
diff --git a/R/PoolTestR-package.R b/R/PoolTestR-package.R
index f1dc211..60c6fdf 100644
--- a/R/PoolTestR-package.R
+++ b/R/PoolTestR-package.R
@@ -22,6 +22,7 @@
#' @import methods
#' @import Rcpp
#' @import rstan
+#' @importFrom rlang .data
#'
#' @references
#'
diff --git a/R/utils.R b/R/utils.R
index dea3985..7f7515c 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -11,7 +11,7 @@ extract_matrix_column_ICC <- function(cluster_var, x){
if (cluster_var %in% all_cluster_vars){
# Extract only the columns for this clustering variable
matrix_cols <- x %>%
- select(grep("ICC", names(x), value = T))
+ select(grep("ICC", names(x), value = TRUE))
cluster_cols <- tibble::as_tibble(
lapply(
names(matrix_cols),
@@ -43,23 +43,23 @@ pretty_format_ICC_column <- function(var_df){
# Record original column names
col_names <- names(var_df)
# Set new column names
- names(var_df)[grep("low", names(var_df), ignore.case = T)] <- "low"
- names(var_df)[grep("high", names(var_df), ignore.case = T)] <- "high"
- names(var_df)[grep("low|high", names(var_df), ignore.case = T, invert = T)] <- "param"
+ names(var_df)[grep("low", names(var_df), ignore.case = TRUE)] <- "low"
+ names(var_df)[grep("high", names(var_df), ignore.case = TRUE)] <- "high"
+ names(var_df)[grep("low|high", names(var_df), ignore.case = TRUE, invert = TRUE)] <- "param"
# Create formatted output column
- formatted_df <- var_df %>% mutate(
- output = paste0(" ",
- custom_round(param),
- " (",
- custom_round(low),
- " - ",
- custom_round(high),
- ")"),
- .keep = "none"
- )
+ formatted_df <- var_df %>%
+ mutate(
+ output = paste0(" ",
+ custom_round(.data$param),
+ " (",
+ custom_round(.data$low),
+ " - ",
+ custom_round(.data$high),
+ ")"),
+ .keep = "none"
+ )
# Rename new column as "ICC."
- names(formatted_df) <-
- grep("low|high", col_names, ignore.case = T, invert = T, value = T)
+ names(formatted_df) <- grep("low|high", col_names, ignore.case = TRUE, invert = TRUE, value = TRUE)
return(formatted_df)
}