Skip to content
Merged
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cqtkit
Title: Comprehensive C-QT Analysis From Data to Deliverables
Version: 1.0.0
Version: 1.0.1
Authors@R: c(
person("Matt", "Smith", , "matthews@a2-ai.com", role = c("aut", "cre")),
person("Devin", "Pastoor", , "devin@a2-ai.com", role = c("aut")),
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# cqtkit 1.0.1

### Fixed
* Exposed the intended optional `legend_location` argument in `gof_residuals_trt_boxplots()`.
* Updated `predict_with_observations_plot` to use `trt_col` to group data allowing for styling.
* Updated `predict_with_observations_plot` and `predict_with_quantiles_plot` to keep default black color
for prediction line when other colors supplied.
* Updated `eda_quantiles_plot` with `plot_observations` to add individual data points to plot.

# cqtkit 1.0.0

* Initial public release.
26 changes: 18 additions & 8 deletions R/compute.R
Original file line number Diff line number Diff line change
Expand Up @@ -1512,11 +1512,21 @@ compute_contrast_observations <- function(

if (is.null(control_predictors)) {
# Simple case: no control group subtraction
observed_df <- tibble::tibble(
group = "Observations",
conc = data %>% dplyr::pull(!!conc),
dv = data %>% dplyr::pull(!!dv)
)
if (rlang::quo_is_null(trt)) {
# No treatment column provided, use default grouping
observed_df <- tibble::tibble(
group = "Observations",
conc = data %>% dplyr::pull(!!conc),
dv = data %>% dplyr::pull(!!dv)
)
} else {
# Use treatment column for grouping
observed_df <- tibble::tibble(
group = data %>% dplyr::pull(!!trt),
conc = data %>% dplyr::pull(!!conc),
dv = data %>% dplyr::pull(!!dv)
)
}
} else {
# Control group subtraction case
trt_str <- rlang::as_name(trt)
Expand All @@ -1527,7 +1537,7 @@ compute_contrast_observations <- function(
# Individual ID+time matching (crossover studies)
treatment_df <- data %>%
dplyr::filter(!!rlang::sym(trt_str) == !!treatment_value) %>%
dplyr::select(!!id, !!ntime, !!conc, treatment_dv = !!dv)
dplyr::select(!!id, !!ntime, !!conc, !!trt, treatment_dv = !!dv)

control_df <- data %>%
dplyr::filter(!!rlang::sym(trt_str) == !!control_value) %>%
Expand All @@ -1540,7 +1550,7 @@ compute_contrast_observations <- function(
) %>%
dplyr::mutate(dv = .data$treatment_dv - .data$control_dv) %>%
dplyr::transmute(
group = "Observations",
group = !!trt,
conc = !!conc,
dv
)
Expand All @@ -1564,7 +1574,7 @@ compute_contrast_observations <- function(
dplyr::left_join(control_means, by = rlang::as_name(ntime)) %>%
dplyr::mutate(dv = !!dv - .data$control_mean_dv) %>%
dplyr::transmute(
group = "Observations",
group = !!trt,
conc = !!conc,
dv
)
Expand Down
23 changes: 21 additions & 2 deletions R/eda.R
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ eda_qtc_comparison_plot <- function(
#' @param xdata_col An unquoted column name for x data
#' @param ydata_col An unquoted column name for y data
#' @param trt_col An unquoted column name for treatment column to stratify the data by
#' @param plot_observations A boolean to include the raw individual data points as background points, default FALSE
#' @param conf_int Numeric confidence interval level (default: 0.9)
#' @param error_bars A string for setting which errorbars are shown, CI, SE, SD
#' @param style A named list of arguments passed to style_plot()
Expand Down Expand Up @@ -312,6 +313,7 @@ eda_quantiles_plot <- function(
xdata_col,
ydata_col,
trt_col = NULL,
plot_observations = FALSE,
conf_int = 0.90,
error_bars = "CI",
style = list()
Expand Down Expand Up @@ -347,15 +349,32 @@ eda_quantiles_plot <- function(
group = .data$.trt_group,
color = .data$.trt_group
)
) +
ggplot2::geom_point(
)

if (plot_observations) {
p <- p +
ggplot2::geom_point(
data = data,
ggplot2::aes(
x = !!xdata,
y = !!ydata,
color = !!trt,
),
alpha = 0.25
)
}

p <- p +
ggplot2::geom_point(
ggplot2::aes(
shape = .data$.trt_group
)
) +
ggplot2::geom_smooth(method = "lm", formula = y ~ x, level = conf_int) +
ggplot2::theme_bw()



p <- add_error_bars_to_plot(obs, p, NULL, error_bars, conf_int)
caption <- p$labels$caption

Expand Down
11 changes: 9 additions & 2 deletions R/gof.R
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ gof_residuals_time_boxplots <- function(
#' @param ntime_col An unquoted column name for nominal time since dose
#' @param trt_col An unquoted column name for treatment group"
#' @param residual_references Numeric vector of reference residual lines to add, default -2 and 2
#' @param legend_location String for legend position (top, bottom, left, right)
#' @param style A named list of arguments passed to style_plot()
#'
#' @return a ggarrange plot
Expand Down Expand Up @@ -715,12 +716,15 @@ gof_residuals_trt_boxplots <- function(
ntime_col,
trt_col = NULL,
residual_references = c(-2, 2),
legend_location = c("top", "bottom", "left", "right", "none"),
style = list()
) {
checkmate::assertDataFrame(data)
checkmate::assert(checkmate::check_class(fit, "lme"))
checkmate::assert_numeric(residual_references, null.ok = TRUE)

legend_location <- match.arg(legend_location)

dv <- rlang::enquo(dv_col)
conc <- rlang::enquo(conc_col)
time <- rlang::enquo(ntime_col)
Expand Down Expand Up @@ -772,10 +776,13 @@ gof_residuals_trt_boxplots <- function(
trt_plot <- ggpubr::ggarrange(
plotlist = trtg_plots,
ncol = 1,
common.legend = TRUE
common.legend = TRUE,
legend = legend_location
)
if (!is.null(style$title))

if (!is.null(style$title)) {
trt_plot <- ggpubr::annotate_figure(trt_plot, top = style$title)
}

return(trt_plot)
}
Expand Down
4 changes: 4 additions & 0 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ predict_with_observations_plot <- function(
attr(p, "fill_colors") <- stats::setNames("grey", ci_label)
# default open circle for line group
attr(p, "secondary_shapes") <- stats::setNames(1, "Predictions")
# default black color for predictions line
attr(p, "prediction_colors") <- stats::setNames("black", "Predictions")

# Add reference line(s)
p <- add_horizontal_references(p, reference_threshold)
Expand Down Expand Up @@ -378,6 +380,8 @@ predict_with_quantiles_plot <- function(
# Add attributes for styling
attr(p, "fill_colors") <- stats::setNames("grey", ci_label)
attr(p, "secondary_shapes") <- stats::setNames(1, "Predictions")
# default black color for predictions line
attr(p, "prediction_colors") <- stats::setNames("black", "Predictions")

p <- add_horizontal_references(p, reference_threshold)
p <- p + ggplot2::theme_bw() + ggplot2::labs(caption = caption)
Expand Down
5 changes: 4 additions & 1 deletion R/style.R
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,10 @@ style_plot <- function(
p,
aesthetic = "color",
groups = color_groups,
default_map = attr(p, "reference_colors") %||% character(0),
default_map = c(
attr(p, "reference_colors") %||% character(0),
attr(p, "prediction_colors") %||% character(0)
),
user_values = colors,
user_labels = labels,
scale_fn = ggplot2::scale_color_manual
Expand Down
3 changes: 3 additions & 0 deletions man/eda_quantiles_plot.Rd

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

3 changes: 3 additions & 0 deletions man/gof_residuals_trt_boxplots.Rd

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

Loading