|
70 | 70 | #' across everything |
71 | 71 | #' @importFrom tidyr unite separate_rows |
72 | 72 | #' @importFrom ggplot2 ggplot ggtitle annotate geom_vline theme geom_hline |
73 | | -#' theme_bw geom_text aes_string element_blank coord_flip aes element_text |
| 73 | +#' theme_bw geom_text element_blank coord_flip aes element_text |
74 | 74 | #' scale_color_manual scale_x_discrete scale_y_discrete expansion |
75 | 75 | #' @importFrom stats model.matrix as.formula cor var |
76 | 76 | #' @importFrom methods is as |
77 | 77 | #' @importFrom MASS ginv |
78 | 78 | #' @importFrom magrittr %>% |
79 | 79 | #' @importFrom S4Vectors DataFrame |
| 80 | +#' @importFrom rlang .data |
80 | 81 | #' |
81 | 82 | VisualizeDesign <- function(sampleData, designFormula = NULL, |
82 | 83 | flipCoordFitted = FALSE, flipCoordCoocc = FALSE, |
@@ -304,12 +305,24 @@ VisualizeDesign <- function(sampleData, designFormula = NULL, |
304 | 305 | ggp <- lapply(split( |
305 | 306 | plot_data, f = plot_data$groupby), |
306 | 307 | function(w) { |
307 | | - gg <- ggplot2::ggplot( |
308 | | - w, |
309 | | - ggplot2::aes_string( |
310 | | - x = ifelse(length(plot_terms) == 1, 1, plot_terms[2]), |
311 | | - y = plot_terms[1], |
312 | | - label = "value")) + |
| 308 | + if (length(plot_terms) == 1) { |
| 309 | + gg <- ggplot2::ggplot( |
| 310 | + w, |
| 311 | + ggplot2::aes( |
| 312 | + x = 1, |
| 313 | + y = .data[[plot_terms[1]]], |
| 314 | + label = .data$value) |
| 315 | + ) |
| 316 | + } else { |
| 317 | + gg <- ggplot2::ggplot( |
| 318 | + w, |
| 319 | + ggplot2::aes( |
| 320 | + x = .data[[plot_terms[2]]], |
| 321 | + y = .data[[plot_terms[1]]], |
| 322 | + label = .data$value) |
| 323 | + ) |
| 324 | + } |
| 325 | + gg <- gg + |
313 | 326 | ggplot2::scale_x_discrete( |
314 | 327 | expand = ggplot2::expansion(mult = 0, add = 0.5) |
315 | 328 | ) + |
@@ -371,14 +384,26 @@ VisualizeDesign <- function(sampleData, designFormula = NULL, |
371 | 384 | plot_data, f = plot_data$groupby), |
372 | 385 | function(w) { |
373 | 386 | w <- w %>% dplyr::select(dplyr::all_of(keepcols)) %>% dplyr::distinct() |
374 | | - gp <- ggplot2::ggplot( |
375 | | - w, |
376 | | - ggplot2::aes_string( |
377 | | - x = ifelse(length(plot_terms) == 1, 1, plot_terms[2]), |
378 | | - y = plot_terms[1], |
379 | | - fill = "nSamples", |
380 | | - label = "nSamples" |
381 | | - )) + |
| 387 | + if (length(plot_terms) == 1) { |
| 388 | + gp <- ggplot2::ggplot( |
| 389 | + w, |
| 390 | + ggplot2::aes( |
| 391 | + x = 1, |
| 392 | + y = .data[[plot_terms[1]]], |
| 393 | + fill = .data$nSamples, |
| 394 | + label = .data$nSamples |
| 395 | + )) |
| 396 | + } else { |
| 397 | + gp <- ggplot2::ggplot( |
| 398 | + w, |
| 399 | + ggplot2::aes( |
| 400 | + x = .data[[plot_terms[2]]], |
| 401 | + y = .data[[plot_terms[1]]], |
| 402 | + fill = .data$nSamples, |
| 403 | + label = .data$nSamples |
| 404 | + )) |
| 405 | + } |
| 406 | + gp <- gp + |
382 | 407 | ggplot2::geom_tile(color = "black") + |
383 | 408 | ggplot2::scale_x_discrete( |
384 | 409 | expand = ggplot2::expansion(mult = 0, add = 0) |
|
0 commit comments