Skip to content

Commit

Permalink
Added option to plot PCA with only colors (no shapes mapped to variab…
Browse files Browse the repository at this point in the history
…les)
  • Loading branch information
almeidasilvaf committed Nov 17, 2023
1 parent 9725b09 commit f35c30b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f35c30b

Please sign in to comment.