diff --git a/DESCRIPTION b/DESCRIPTION index 0513d84..240fca9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: enviromtx Title: Predicting Species-Species Interactions from Environmental Metatranscriptomics Data -Version: 1.1.0 +Version: 1.1.1 Authors@R: c(person("Amy D", "Willis", email = "adwillis@uw.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-2802-4317")), person("Sarah", "Teichman", role = "aut"), @@ -15,9 +15,9 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 Imports: dplyr, - geepack, - geeasy, lazyeval, raoBust (>= 1.1.1), - tibble + tibble, + geeasy, + geepack Remotes: statdivlab/raoBust diff --git a/NAMESPACE b/NAMESPACE index 5e2e33a..2fbb118 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,9 +3,5 @@ export(fit_mgx_model) import(geeasy) import(geepack) -import(stats) -importFrom(dplyr,bind_cols) -importFrom(lazyeval,as_call) -importFrom(lazyeval,f_new) +importFrom(raoBust,gee_test) importFrom(raoBust,glm_test) -importFrom(tibble,tibble) diff --git a/R/fit_mgx_model.R b/R/fit_mgx_model.R index 1c95e44..b534ece 100644 --- a/R/fit_mgx_model.R +++ b/R/fit_mgx_model.R @@ -26,13 +26,9 @@ #' Users can override some or all of these. #' If \code{center = TRUE}, then covariates will be centered before being included in the model. #' -#' @importFrom tibble tibble -#' @importFrom dplyr bind_cols -#' @importFrom lazyeval f_new as_call -#' @importFrom raoBust glm_test -#' @import stats -#' @import geepack +#' @importFrom raoBust glm_test gee_test #' @import geeasy +#' @import geepack #' #' @examples #' my_df <- data.frame(xx = rpois(20, lambda = 400), @@ -163,7 +159,7 @@ fit_mgx_model <- function( stop("At least one replicate provided is infinite. Please fix this and then rerun.") } } - covs <- all.vars(update(formula, . ~ .))[-1] + covs <- all.vars(stats::update(formula, . ~ .))[-1] for (i in 1:length(covs)) { if (any(is.infinite(my_df[[covs[i]]]))) { stop(paste0("At least one value of covariate ", covs[i], " is infinite. Please fix this and rerun.")) @@ -178,7 +174,7 @@ fit_mgx_model <- function( # center covariates if desired if (control$center) { # get variable names from the formula - vars <- setdiff(all.vars(update(formula, . ~ .))[-1], "predictor") + vars <- setdiff(all.vars(stats::update(formula, . ~ .))[-1], "predictor") # copy data so we don't overwrite data_centered <- my_df @@ -222,11 +218,11 @@ fit_mgx_model <- function( ## E[Y]/X = gamma0 * (X^*/X)^beta1 * e^(beta2*salinity + beta3*iron) if (is.null(replicates)) { - raoBust_out <- raoBust::glm_test(formula = formula, - offset = offset, - family = stats::poisson(link = "log"), - data = my_df, - weights = wts)$coef_tab + raoBust_out <- glm_test(formula = formula, + offset = offset, + family = stats::poisson(link = "log"), + data = my_df, + weights = wts)$coef_tab } else { if (!all(my_df[[wts]] == 1L)) { warning("Run this by Amy; not sure what this is doing off-the-cuff") @@ -239,13 +235,13 @@ fit_mgx_model <- function( id <- "id" } - raoBust_out <- raoBust::gee_test(formula = formula, - offset = offset, - family = stats::poisson(link="log"), - id = id, - data = my_df, - use_jack_se = use_jack_se, - cluster_corr_coef = cluster_corr_coef)$coef_tab + raoBust_out <- gee_test(formula = formula, + offset = offset, + family = stats::poisson(link="log"), + id = id, + data = my_df, + use_jack_se = use_jack_se, + cluster_corr_coef = cluster_corr_coef)$coef_tab } diff --git a/man/fit_mgx_model.Rd b/man/fit_mgx_model.Rd index f67e735..2e1e896 100644 --- a/man/fit_mgx_model.Rd +++ b/man/fit_mgx_model.Rd @@ -19,7 +19,7 @@ fit_mgx_model( ) } \arguments{ -\item{enviro_df}{A data frame or tibble with columns containing the relevant variables, and rows denoting the observations. Columns must contain the following data: observed gene expression data, taxon abundance data, environmental covariates, and (optionally) technical replicate information.} +\item{enviro_df}{A data frame or tibble with columns containing the relevant variables, and rows denoting the observations. Columns must contain the following data: observed gene expression data, taxon abundance data, environmental covariates, and (optionally) technical replicate information. If any of these values are missing, the entire row containing the missing value will be removed from the data.} \item{yy}{The name of the column in \code{enviro_df} containing the expression data for a gene expressed by the responder taxon. Default is "yy". Expression data could be in the form of coverage, counts, etc. See vignettes for details on acceptable and suggested datatypes and preprocessing ("normalizations"). In the above notation, this corresponds to the expression of gene \eqn{k} expressed by taxon \eqn{j}.} diff --git a/tests/testthat/test-accuracy-correlated.R b/tests/testthat/test-accuracy-correlated.R index b99a5d7..bdb8bf4 100644 --- a/tests/testthat/test-accuracy-correlated.R +++ b/tests/testthat/test-accuracy-correlated.R @@ -20,7 +20,7 @@ test_that("reasonably accurate estimates with covariates and correlation", { # yy1 <- rpois(n, lambda=eta) yy1 <- rnbinom(n, mu=eta, size=eta^2) - my_df <- tibble(yy1, xx1, xstar1, xx_covariates1, xx_covariates2, id) + my_df <- tibble::tibble(yy1, xx1, xstar1, xx_covariates1, xx_covariates2, id) output10 <- fit_mgx_model(enviro_df = my_df, yy = "yy1", diff --git a/tests/testthat/test-accuracy-uncorrelated.R b/tests/testthat/test-accuracy-uncorrelated.R index ad5bb5a..17b6963 100644 --- a/tests/testthat/test-accuracy-uncorrelated.R +++ b/tests/testthat/test-accuracy-uncorrelated.R @@ -87,7 +87,7 @@ test_that("reasonably accurate estimates with covariates and correlation", { # yy1 <- rpois(n, lambda=eta) yy1 <- rnbinom(n, mu=eta, size=eta^2) - my_df <- tibble(yy1, xx1, predictor = log((xstar1 + 1)/(xx1 + 1)), xx_covariates1, xx_covariates2, id) + my_df <- tibble::tibble(yy1, xx1, predictor = log((xstar1 + 1)/(xx1 + 1)), xx_covariates1, xx_covariates2, id) output9 <- fit_mgx_model(data.frame(yy = yy1, xstar = xstar1, diff --git a/tests/testthat/test-fit_mgx_model_centering.R b/tests/testthat/test-fit_mgx_model_centering.R index 4453ae4..cc738a9 100644 --- a/tests/testthat/test-fit_mgx_model_centering.R +++ b/tests/testthat/test-fit_mgx_model_centering.R @@ -52,7 +52,7 @@ test_that("with small parameter values, centering does not affect results", { eta <- xx1 * beta0 * (xstar1/xx1)^beta1 * exp(beta2 * xx_covariates1 + beta3 * xx_covariates2 + b[id]) yy1 <- rnbinom(n, mu=eta, size=eta^2) - my_df <- tibble(yy1, xx1, predictor = log((xstar1 + 1)/(xx1 + 1)), xx_covariates1, xx_covariates2, id) + my_df <- tibble::tibble(yy1, xx1, predictor = log((xstar1 + 1)/(xx1 + 1)), xx_covariates1, xx_covariates2, id) output3 <- fit_mgx_model(data.frame(yy = yy1, xstar = xstar1, @@ -245,7 +245,7 @@ test_that("reasonably accurate estimates with covariates and correlation", { # yy1 <- rpois(n, lambda=eta) yy1 <- rnbinom(n, mu=eta, size=eta^2) - my_df <- tibble(yy1, xx1, xstar1, xx_covariates1, xx_covariates2, id) + my_df <- tibble::tibble(yy1, xx1, xstar1, xx_covariates1, xx_covariates2, id) output9 <- fit_mgx_model(yy = "yy1", xstar = "xstar1",