Skip to content

Commit

Permalink
pass threshold into workflow PecanProject#18
Browse files Browse the repository at this point in the history
  • Loading branch information
robkooper committed Jan 14, 2015
1 parent 855cfe7 commit 062c4b5
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion all/tests/testthat/test.workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#settings <- read.settings(settings.file)

# settings$pfts <- get.trait.data(settings$pfts, settings$model$type, settings$run$dbfiles, settings$database$bety, settings$meta.analysis$update)
# run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$run$dbfiles, settings$database$bety)
# run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety)
# run.write.configs("ED2")
# clear.scratch(settings)
# start.model.runs("ED2")
Expand Down
2 changes: 1 addition & 1 deletion models/biocro/BioCro_demo.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ model <- settings$model$type
settings$pfts <- get.trait.data(settings$pfts, settings$model$type, settings$run$dbfiles, settings$database$bety, settings$meta.analysis$update)

# Run the PEcAn meta.analysis
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$run$dbfiles, settings$database$bety)
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety)

run.write.configs(model) # Calls model specific write.configs e.g. write.config.ed.R
## load met data
Expand Down
2 changes: 1 addition & 1 deletion models/biocro/inst/workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ settings$meta.analysis$update <- TRUE
settings$pfts <- get.trait.data(settings$pfts, settings$model$type, settings$run$dbfiles, settings$database$bety, settings$meta.analysis$update)

# Run the PEcAn meta.analysis
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$run$dbfiles, settings$database$bety)
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety)

run.write.configs(model) # Calls model specific write.configs e.g. write.config.ed.R
## load met data
Expand Down
2 changes: 1 addition & 1 deletion models/biocro/vignettes/workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ model <- settings$model$type
settings$pfts <- get.trait.data(settings$pfts, settings$model$type, settings$run$dbfiles, settings$database$bety, settings$meta.analysis$update)

# Run the PEcAn meta.analysis
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$run$dbfiles, settings$database$bety)
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety)

## @knitr , echo=FALSE,warning=FALSE,cache=TRUE
run.write.configs(model) # Calls model specific write.configs e.g. write.config.ed.R
Expand Down
2 changes: 1 addition & 1 deletion models/biocro/vignettes/workflow.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ settings$pfts <- get.trait.data(settings$pfts, settings$model$type, settings$run

### Run Meta-analysis
```{r, echo=FALSE,warning=FALSE,cache=TRUE}
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$run$dbfiles, settings$database$bety)
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety)
```


Expand Down
8 changes: 4 additions & 4 deletions modules/meta.analysis/R/run.meta.analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://opensource.ncsa.illinois.edu/license.html
#-------------------------------------------------------------------------------
run.meta.analysis.pft <- function(pft, iterations, random, dbfiles, dbcon) {
run.meta.analysis.pft <- function(pft, iterations, random, threshold, dbfiles, dbcon) {
# check to see if get.trait was executed
if (!file.exists(file.path(pft$outdir, 'trait.data.Rdata')) || !file.exists(file.path(pft$outdir, 'prior.distns.Rdata'))) {
logger.severe("Could not find output from get.trait for", pft$name)
Expand Down Expand Up @@ -101,7 +101,7 @@ run.meta.analysis.pft <- function(pft, iterations, random, dbfiles, dbcon) {
}

### Generate summaries and diagnostics
pecan.ma.summary(trait.mcmc, pft$name, pft$outdir)
pecan.ma.summary(trait.mcmc, pft$name, pft$outdir, threshold)

### Save the meta.analysis output
save(trait.mcmc, file = file.path(pft$outdir, 'trait.mcmc.Rdata'))
Expand Down Expand Up @@ -142,10 +142,10 @@ run.meta.analysis.pft <- function(pft, iterations, random, dbfiles, dbcon) {
##' and post.distns.Rdata, respectively
##' @export
##' @author Shawn Serbin, David LeBauer
run.meta.analysis <- function(pfts, iterations, random, dbfiles, database) {
run.meta.analysis <- function(pfts, iterations, random, threshold, dbfiles, database) {
# process all pfts
dbcon <- db.open(database)
result <- lapply(pfts, run.meta.analysis.pft, iterations, random, dbfiles, dbcon)
result <- lapply(pfts, run.meta.analysis.pft, iterations, random, threshold, dbfiles, dbcon)
db.close(dbcon)
} ### End of function: run.meta.analysis.R
##==================================================================================================#
Expand Down
2 changes: 1 addition & 1 deletion scripts/workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ status.end()
# Run the PEcAn meta.analysis
status.start("META")
if('meta.analysis' %in% names(settings)) {
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$run$dbfiles, settings$database$bety)
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety)
}
status.end()

Expand Down
4 changes: 4 additions & 0 deletions settings/R/read.settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ check.settings <- function(settings) {
settings$meta.analysis$random.effects <- FALSE
logger.info("Setting meta.analysis random effects to ", settings$meta.analysis$random.effects)
}
if (is.null(settings$meta.analysis$threshold)) {
settings$meta.analysis$threshold <- 1.2
logger.info("Setting meta.analysis threshold to ", settings$meta.analysis$threshold)
}
if (is.null(settings$meta.analysis$update)) {
settings$meta.analysis$update <- 'AUTO'
logger.info("Setting meta.analysis update to only update if no previous meta analysis was found")
Expand Down
2 changes: 1 addition & 1 deletion tests/testpfts.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runmeta <- function(pftid, pftname, model, dbparam) {
cat(paste0("TESTING [id=", pftid, " pft='", pftname, "' model='", model, "'] : get.traits\n"), file=stderr())
pfts <- get.trait.data(list(pft), model, dbparam$dbfiles, dbparam, TRUE)
cat(paste0("TESTING [id=", pftid, " pft='", pftname, "' model='", model, "'] : meta.analysis\n"), file=stderr())
run.meta.analysis(pfts, 3000, FALSE, dbparam$dbfiles, dbparam)
run.meta.analysis(pfts, 3000, FALSE, 1.2, dbparam$dbfiles, dbparam)
cat(paste0("TESTING [id=", pftid, " pft='", pftname, "' model='", model, "'] : OK\n"), file=stderr())
}

Expand Down
2 changes: 1 addition & 1 deletion tests/workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ status.end()
# run meta-analysis
status.start("META")
if('meta.analysis' %in% names(settings)) {
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$run$dbfiles, settings$database$bety)
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety)
}
status.end()

Expand Down
2 changes: 1 addition & 1 deletion web/workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (length(which(commandArgs() == "--continue")) == 0) {

# run meta-analysis
status.start("META")
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$run$dbfiles, settings$database$bety)
run.meta.analysis(settings$pfts, settings$meta.analysis$iter, settings$meta.analysis$random.effects, settings$meta.analysis$threshold, settings$run$dbfiles, settings$database$bety)
status.end()

# do conversions
Expand Down

0 comments on commit 062c4b5

Please sign in to comment.