From 01849e409e0d8efbc78368632be10274e9bcc703 Mon Sep 17 00:00:00 2001 From: sreichl Date: Fri, 9 Sep 2022 15:43:14 +0200 Subject: [PATCH] skip empty metadata columns in 2D plots --- workflow/scripts/plot_2d.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/workflow/scripts/plot_2d.R b/workflow/scripts/plot_2d.R index 810d1a2..bab9002 100644 --- a/workflow/scripts/plot_2d.R +++ b/workflow/scripts/plot_2d.R @@ -53,6 +53,12 @@ height_panel <- ceiling(ncol(metadata)/n_col) * height scatter_plots <- list() for (col in colnames(metadata)){ + + # check if metadata column is only NA + if(all(is.na(metadata[col]))){ + next + } + tmp_data <- cbind(data, metadata[col]) tmp_plot <- ggplot(tmp_data, aes_string(x=colnames(tmp_data)[1], y=colnames(tmp_data)[2])) + geom_point(aes_string(color=col), size=size, stroke=0, alpha=alpha) +