Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ALASCA
Title: Assorted, Linear ASCA Functions
Version: 1.0.17
Version: 1.0.19
Authors@R:
person(given = "Anders H.",
family = "Jarmund",
Expand All @@ -15,7 +15,7 @@ Encoding: UTF-8
LazyData: true
ByteCompile: true
Roxygen: list(markdown = TRUE, r6 = TRUE)
RoxygenNote: 7.1.2
RoxygenNote: 7.3.2
Depends:
data.table
Imports:
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export(plot_covariate)
export(plot_covariates)
export(plot_mm)
export(plot_val)
export(predict_scores)
export(save.AlascaModel)
export(screeplot)
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# ALASCA 1.0.19

* Bug fix: The prediction plots should now work for models with separated effects too

# ALASCA 1.0.18

* Replacing `aes_string()` due to changes in the `ggplot2` package
* Moved `finalize()` from public to private re changes in the `R6` package
* Bug fix: Plots all variables instead of subset

# ALASCA 1.0.17

* Minor bug fix related to 1.0.16
Expand Down
237 changes: 136 additions & 101 deletions R/ALASCA.R

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions R/AlascaModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ AlascaModel <- R6::R6Class("AlascaModel",
#' @field ignore_missing_covars If TRUE, ignore missing covariate values
ignore_missing_covars = FALSE,
#' @field version Version number
version = "1.0.17",
version = "1.0.19",
#' @field update_date Date of latest update
update_date = "2024-09-13",
update_date = "2026-01-16",

# Effect matrices
#' @field separate_effects If TRUE, try to separate the effects
Expand Down Expand Up @@ -256,15 +256,6 @@ AlascaModel <- R6::R6Class("AlascaModel",
# Build the ALASCA model ----
self$build_model()
},
finalize = function() {
if (self$save_to_disk && !self$minimize_object) {
if (self$db_method == "SQLite") {
DBI::dbDisconnect(self$db_con)
} else {
DBI::dbDisconnect(self$db_con, shutdown = TRUE)
}
}
},
#' @description
#' Update the current model (used for validation)
update = function() {
Expand Down Expand Up @@ -446,7 +437,7 @@ AlascaModel <- R6::R6Class("AlascaModel",

if (self$equal_baseline) {
# Must add baselines for missing interactions (baseline x group)
baseline_to_add <- self$model_prediction[get(self$effect_terms) %in% self$get_ref(self$effect_terms)]
baseline_to_add <- self$model_prediction[self$get_ref(self$effect_terms)]

if (length(self$effect_terms) == 2) {
# In this case, there are no main effects except time
Expand Down Expand Up @@ -844,5 +835,15 @@ AlascaModel <- R6::R6Class("AlascaModel",
unique(unlist(self$effect_list$terms))
}
),
private = list()
private = list(
finalize = function() {
if (self$save_to_disk && !self$minimize_object) {
if (self$db_method == "SQLite") {
DBI::dbDisconnect(self$db_con)
} else {
DBI::dbDisconnect(self$db_con, shutdown = TRUE)
}
}
}
)
)
15 changes: 7 additions & 8 deletions R/AlascaPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ AlascaPlot <- R6::R6Class("AlascaPlot",
#' @field type Plot type
type = "effect",
initialize = function(model) {
self$model <- model
self$n_limit <- min(self$n_limit / 2, floor(length(self$model$get_levels("variable")) / 2))
self$model <- model
},
call_plot = function(...) {
inputs <- list(...)
Expand Down Expand Up @@ -253,10 +252,10 @@ AlascaPlot <- R6::R6Class("AlascaPlot",

if (is.null(self$loading_group_column)) {
if (self$model$validate) {
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes_string(x = "covar", y = "estimate", ymin = "low", ymax = "high")) +
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes(x = .data[["covar"]], y = .data[["estimate"]], ymin = .data[["low"]], ymax = .data[["high"]])) +
ggplot2::geom_pointrange()
} else {
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes_string(x = "covar", y = "estimate")) +
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes(x = .data[["covar"]], y = .data[["estimate"]])) +
ggplot2::geom_point()
}
} else {
Expand All @@ -266,16 +265,16 @@ AlascaPlot <- R6::R6Class("AlascaPlot",
}
if (self$model$validate) {
if (self$black_and_white) {
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes_string(x = "covar", y = "estimate", ymin = "low", ymax = "high", shape = "covargroup"))
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes(x = .data[["covar"]], y = .data[["estimate"]], ymin = .data[["low"]], ymax = .data[["high"]], shape = .data[["covargroup"]]))
} else {
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes_string(x = "covar", y = "estimate", ymin = "low", ymax = "high", shape = "covargroup", color = "covargroup"))
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes(x = .data[["covar"]], y = .data[["estimate"]], ymin = .data[["low"]], ymax = .data[["high"]], shape = .data[["covargroup"]], color = .data[["covargroup"]]))
}
g <- g + ggplot2::geom_pointrange()
} else {
if (self$black_and_white) {
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes_string(x = "covar", y = "estimate", shape = "covargroup"))
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes(x = .data[["covar"]], y = .data[["estimate"]], shape = .data[["covargroup"]]))
} else {
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes_string(x = "covar", y = "estimate", shape = "covargroup", color = "covargroup"))
g <- ggplot2::ggplot(data_to_plot, ggplot2::aes(x = .data[["covar"]], y = .data[["estimate"]], shape = .data[["covargroup"]], color = .data[["covargroup"]]))
}

g <- g + ggplot2::geom_point()
Expand Down
Loading