Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Testing functions in meta-analysis sub-workflow #3298

Merged
merged 16 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions modules/meta.analysis/tests/testthat/test.jagify.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2012 University of Illinois, NCSA.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the
# University of Illinois/NCSA Open Source License
# which accompanies this distribution, and is available at
# http://opensource.ncsa.illinois.edu/license.html
#-------------------------------------------------------------------------------
infotroph marked this conversation as resolved.
Show resolved Hide resolved

test_that("jagify correctly assigns treatment index of 1 to all control treatments, regardless of alphabetical order", {
## generate test data; controls assigned to early alphabet and late alphabet trt names
testresult <- data.frame(citation_id = 1,
site_id = rep(1:2, each = 5),
name = rep(letters[1:5],2),
trt_id = as.character(rep(letters[1:5],2)),
control = c(1, rep(0,8), 1),
greenhouse = c(rep(0,5), rep(1,5)),
date = 1,
time = NA,
cultivar_id = 1,
specie_id = 1,
n = 2,
mean = sqrt(1:10),
stat = 1,
statname = "SE",
treatment_id = 1:10
)
i <- sapply(testresult, is.factor)
testresult[i] <- lapply(testresult[i], as.character)
meetagrawal09 marked this conversation as resolved.
Show resolved Hide resolved

jagged.data <- jagify(testresult)
expect_equal(jagged.data$trt_num[jagged.data$trt == "control"], c(1, 1))
})
3 changes: 3 additions & 0 deletions modules/meta.analysis/tests/testthat/test.meta.analysis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_that("`pecan.ma`", {

})
41 changes: 5 additions & 36 deletions modules/meta.analysis/tests/testthat/test.run.meta.analysis.R
Original file line number Diff line number Diff line change
@@ -1,42 +1,11 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2012 University of Illinois, NCSA.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the
# University of Illinois/NCSA Open Source License
# which accompanies this distribution, and is available at
# http://opensource.ncsa.illinois.edu/license.html
#-------------------------------------------------------------------------------
test_that("`runModule.run.meta.analysis`", {

meetagrawal09 marked this conversation as resolved.
Show resolved Hide resolved
context("run.meta.analysis")
})

test_that("`run.meta.analysis`", {

test_that("singleMA gives expected result for example inputs",{
## need to calculate x
## x <- singleMA(....)
#expect_equal(round(summary(x)$statistics["beta.o", "Mean"]), 5)
})

test_that("jagify correctly assigns treatment index of 1 to all control treatments, regardless of alphabetical order", {
## generate test data; controls assigned to early alphabet and late alphabet trt names
testresult <- data.frame(citation_id = 1,
site_id = rep(1:2, each = 5),
name = rep(letters[1:5],2),
trt_id = as.character(rep(letters[1:5],2)),
control = c(1, rep(0,8), 1),
greenhouse = c(rep(0,5), rep(1,5)),
date = 1,
time = NA,
cultivar_id = 1,
specie_id = 1,
n = 2,
mean = sqrt(1:10),
stat = 1,
statname = "SE",
treatment_id = 1:10
)
i <- sapply(testresult, is.factor)
testresult[i] <- lapply(testresult[i], as.character)
test_that("`run.meta.analysis.pft`", {

jagged.data <- jagify(testresult)
expect_equal(jagged.data$trt_num[jagged.data$trt == "control"], c(1, 1))
})
})
5 changes: 5 additions & 0 deletions modules/meta.analysis/tests/testthat/test.single.MA.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test_that("`single.MA` gives expected result for example inputs", {
## need to calculate x
## x <- singleMA(....)
#expect_equal(round(summary(x)$statistics["beta.o", "Mean"]), 5)
})
Loading