From f35c30b7b5689bc6dcf3599476877f5c912822cc Mon Sep 17 00:00:00 2001 From: almeidasilvaf Date: Fri, 17 Nov 2023 15:18:01 +0100 Subject: [PATCH] Added option to plot PCA with only colors (no shapes mapped to variables) --- R/visualization.R | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/R/visualization.R b/R/visualization.R index 9ad31cf..9378412 100644 --- a/R/visualization.R +++ b/R/visualization.R @@ -301,13 +301,20 @@ pca_plot <- function( ) } + gpoint <- geom_point(aes(color = .data[[color_by]]), size = 3, alpha = 0.7) + if(!is.null(shape_by)) { + gpoint <- geom_point( + aes( + color = .data[[color_by]], + shape = .data[[shape_by]] + ), + size = 3, alpha = 0.7 + ) + } + # Plot PCA p_pca <- ggplot(pdata, aes(x = .data[[pc[1]]], y = .data[[pc[2]]])) + - geom_point( - aes( - color = .data[[color_by]], shape = .data[[shape_by]] - ), size = 3, alpha = 0.7 - ) + + gpoint + point_mean + scale_color_manual(values = pal) + labs(