Skip to content

Commit

Permalink
Fix importFrom calls and use agglomerate in mediate.R
Browse files Browse the repository at this point in the history
  • Loading branch information
RiboRings committed Apr 16, 2024
1 parent bf91d31 commit 63ffa3c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ importFrom(SingleCellExperiment,SingleCellExperiment)
importFrom(SingleCellExperiment,altExp)
importFrom(SingleCellExperiment,altExpNames)
importFrom(SingleCellExperiment,altExps)
importFrom(SingleCellExperiment,reducedDim)
importFrom(SingleCellExperiment,reducedDimNames)
importFrom(SingleCellExperiment,reducedDims)
importFrom(SummarizedExperiment,"assay<-")
importFrom(SummarizedExperiment,"assays<-")
Expand Down Expand Up @@ -312,8 +314,13 @@ importFrom(stats,chisq.test)
importFrom(stats,cmdscale)
importFrom(stats,cor)
importFrom(stats,cor.test)
importFrom(stats,formula)
importFrom(stats,gaussian)
importFrom(stats,glm)
importFrom(stats,hclust)
importFrom(stats,lm)
importFrom(stats,median)
importFrom(stats,na.omit)
importFrom(stats,p.adjust)
importFrom(stats,runif)
importFrom(stats,sd)
Expand Down
7 changes: 6 additions & 1 deletion R/mediate.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
#' tse <- hitchip1006
#'
#' # Agglomerate features by family (merely to speed up execution)
#' tse <- mergeFeaturesByRank(tse, rank = "Family")
#' tse <- agglomerateByRank(tse, rank = "Family")
#' # Convert BMI variable to numeric
#' tse$bmi_group <- as.numeric(tse$bmi_group)
#'
Expand Down Expand Up @@ -142,6 +142,7 @@ setGeneric("addMediation", signature = c("x"),

#' @rdname getMediation
#' @export
#' @importFrom stats gaussian
setMethod("addMediation", signature = c(x = "SummarizedExperiment"),
function(x, outcome, treatment, name = "mediation",
mediator = NULL, assay.type = NULL, dimred = NULL,
Expand All @@ -167,6 +168,8 @@ setGeneric("getMediation", signature = c("x"),

#' @rdname getMediation
#' @export
#' @importFrom stats gaussian
#' @importFrom SingleCellExperiment reducedDim reducedDimNames
setMethod("getMediation", signature = c(x = "SummarizedExperiment"),
function(x, outcome, treatment,
mediator = NULL, assay.type = NULL, dimred = NULL,
Expand Down Expand Up @@ -276,6 +279,7 @@ setMethod("getMediation", signature = c(x = "SummarizedExperiment"),


# Check that arguments can be passed to mediate and remove unused samples
#' @importFrom stats na.omit
.check.mediate.args <- function(x, outcome, treatment, mediator, covariates, verbose = TRUE, ...) {

# Create dataframe from selected columns of colData
Expand Down Expand Up @@ -328,6 +332,7 @@ setMethod("getMediation", signature = c(x = "SummarizedExperiment"),

# Run mediation analysis
#' @importFrom mediation mediate
#' @importFrom stats lm formula glm
.run.mediate <- function(x, outcome, treatment, mediator = NULL, mat = NULL,
family = gaussian(), covariates = NULL, ...) {

Expand Down
2 changes: 1 addition & 1 deletion man/getMediation.Rd

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

9 changes: 0 additions & 9 deletions man/hierarchy-tree.Rd

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

1 change: 1 addition & 0 deletions man/mia-package.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/taxonomy-methods.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-mediate.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_that("getMediation", {
data("hitchip1006", package = "miaTime")
tse <- hitchip1006

expect_warning(tse <- mergeFeaturesByRank(tse, rank = "Family"))
tse <- agglomerateByRank(tse, rank = "Family")
tse$bmi_group <- as.numeric(tse$bmi_group)

### Batch 1: check errors when missing or wrong arguments ###
Expand Down

0 comments on commit 63ffa3c

Please sign in to comment.