Skip to content

Commit

Permalink
Merge pull request #24 from tece-lab/upbound
Browse files Browse the repository at this point in the history
Added upper bound parameter integration to DAISIE scripts
  • Loading branch information
Neves-P authored Feb 28, 2023
2 parents 0e5c1cb + 6bef253 commit bc6a8fe
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 17 deletions.
2 changes: 0 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,3 @@ Imports:
DAISIE (>= 4.2.1),
ggplot2,
cowplot
Remotes:
rsetienne/DAISIE@relaxed
7 changes: 6 additions & 1 deletion R/default_params_doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@
#' of the largest clade.
#' @param prop_type2_pool A numeric determining the proportion of the mainland
#' species pool that is composed on type 2 species.
#' @param par_upper_bound A numeric defining the upper limit of the integration
#' of a parameter when fitting the relaxed-rate DAISIE model. If the DAISIE
#' model being applied is not the relaxed-rate model, this parameter can be
#' ignored and left as its default as it does not influence the model.
#'
#' @return Nothing
#' @keywords internal
Expand Down Expand Up @@ -244,6 +248,7 @@ default_params_doc <- function(model,
low_rates,
rep_index,
res,
prop_type2_pool) {
prop_type2_pool,
par_upper_bound) {
# Nothing
}
4 changes: 3 additions & 1 deletion R/run_daisie_ml.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ run_daisie_ml <- function(daisie_data,
low_rates = FALSE,
rep_index = "NULL",
res = 100,
par_upper_bound = Inf,
test = FALSE) {
if (test) {
seed <- array_index
Expand Down Expand Up @@ -63,7 +64,8 @@ run_daisie_ml <- function(daisie_data,

model_arguments <- setup_model(
model = model,
low_rates = low_rates
low_rates = low_rates,
par_upper_bound = par_upper_bound
)

initparsopt <- model_arguments$initparsopt
Expand Down
18 changes: 12 additions & 6 deletions R/setup_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#' model = model
#' )
setup_model <- function(model,
low_rates = FALSE) {
low_rates = FALSE,
par_upper_bound = Inf) {
expected_models <- get_available_models()
testit::assert(model %in% expected_models)

Expand Down Expand Up @@ -75,31 +76,36 @@ setup_model <- function(model,
if (grepl("rr_lac", model)) {
cs_version <- DAISIE::create_CS_version(
model = 2,
relaxed_par = "cladogenesis"
relaxed_par = "cladogenesis",
par_upper_bound = par_upper_bound
)
}
if (grepl("rr_mu", model)) {
cs_version <- DAISIE::create_CS_version(
model = 2,
relaxed_par = "extinction"
relaxed_par = "extinction",
par_upper_bound = par_upper_bound
)
}
if (grepl("rr_k", model)) {
cs_version <- DAISIE::create_CS_version(
model = 2,
relaxed_par = "carrying_capacity"
relaxed_par = "carrying_capacity",
par_upper_bound = par_upper_bound
)
}
if (grepl("rr_gam", model)) {
cs_version <- DAISIE::create_CS_version(
model = 2,
relaxed_par = "immigration"
relaxed_par = "immigration",
par_upper_bound = par_upper_bound
)
}
if (grepl("rr_laa", model)) {
cs_version <- DAISIE::create_CS_version(
model = 2,
relaxed_par = "anagenesis"
relaxed_par = "anagenesis",
par_upper_bound = par_upper_bound
)
}
}
Expand Down
8 changes: 7 additions & 1 deletion bash/submit_run_daisie_ml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
# res - A numeric determining the resolution of the likelihood calculations, it
# sets the limit for the maximum number of species for which a probability
# must be computed, which must be larger than the size of the largest clade
# par_upper_bound - A numeric defining the upper limit of the integration
# of a parameter when fitting the relaxed-rate DAISIE model. If the DAISIE
# model being applied is not the relaxed-rate model, this parameter can be
# ignored and left as its default as it does not influence the model

################################################################################
##### Before running make sure install_DAISIEutils.sh has been run ####
Expand All @@ -74,6 +78,7 @@ optimmethod=${7-subplex}
low_rates=${8-FALSE}
rep_index=${9-NULL}
res=${10-100}
par_upper_bound=${11-Inf}
seed=${SLURM_ARRAY_TASK_ID}

ml R
Expand All @@ -87,4 +92,5 @@ Rscript DAISIEutils/scripts/run_daisie_ml.R ${data} \
${optimmethod} \
${low_rates} \
${rep_index} \
${res}
${res} \
${par_upper_bound}
8 changes: 7 additions & 1 deletion bash/submit_run_daisie_ml_long.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
# res - A numeric determining the resolution of the likelihood calculations, it
# sets the limit for the maximum number of species for which a probability
# must be computed, which must be larger than the size of the largest clade
# par_upper_bound - A numeric defining the upper limit of the integration
# of a parameter when fitting the relaxed-rate DAISIE model. If the DAISIE
# model being applied is not the relaxed-rate model, this parameter can be
# ignored and left as its default as it does not influence the model

################################################################################
##### Before running make sure install_DAISIEutils.sh has been run ####
Expand All @@ -73,6 +77,7 @@ optimmethod=${7-subplex}
low_rates=${8-FALSE}
rep_index=${9-NULL}
res=${10-100}
par_upper_bound=${11-Inf}
seed=${SLURM_ARRAY_TASK_ID}

ml R
Expand All @@ -86,4 +91,5 @@ Rscript DAISIEutils/scripts/run_daisie_ml.R ${data} \
${optimmethod} \
${low_rates} \
${rep_index} \
${res}
${res} \
${par_upper_bound}
8 changes: 7 additions & 1 deletion man/default_params_doc.Rd

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

6 changes: 6 additions & 0 deletions man/run_daisie_ml.Rd

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

7 changes: 6 additions & 1 deletion man/setup_model.Rd

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

9 changes: 6 additions & 3 deletions scripts/run_daisie_ml.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ if (identical(args[6], "NULL")) {
optimmethod = args[8],
low_rates = as.logical(args[9]),
rep_index = args[10],
res = as.numeric(args[11])
res = as.numeric(args[11]),
par_upper_bound = as.numeric(args[12])
)
} else if (identical(args[6], "NA")){
DAISIEutils::run_daisie_ml(
Expand All @@ -35,7 +36,8 @@ if (identical(args[6], "NULL")) {
optimmethod = args[8],
low_rates = as.logical(args[9]),
rep_index = args[10],
res = as.numeric(args[11])
res = as.numeric(args[11]),
par_upper_bound = as.numeric(args[12])
)
} else {
DAISIEutils::run_daisie_ml(
Expand All @@ -49,6 +51,7 @@ if (identical(args[6], "NULL")) {
optimmethod = args[8],
low_rates = as.logical(args[9]),
rep_index = args[10],
res = as.numeric(args[11])
res = as.numeric(args[11]),
par_upper_bound = as.numeric(args[12])
)
}

0 comments on commit bc6a8fe

Please sign in to comment.