From 482ac378f21193d3d0f42d15d1f748965c79e798 Mon Sep 17 00:00:00 2001 From: jonathan dreyfuss Date: Mon, 15 Jan 2024 11:57:40 -0500 Subject: [PATCH] multi_covar_pca doesn't create PDF if name is NA --- DESCRIPTION | 2 +- R/multi_covar_pca.R | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 486e2a7..2ebfaec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ezlimmaplot Title: Bioinformatics plots using limma and ggplot2, some from output of ezlimma -Version: 0.0.2.9003 +Version: 0.0.2.9004 Authors@R: c(person("Jonathan", "Dreyfuss", role = c("aut", "cre"), email = "jdreyf@bu.edu"), person("Hui", "Pan", role = "aut"), person("Grace", "Daher", role="ctb")) diff --git a/R/multi_covar_pca.R b/R/multi_covar_pca.R index 61c322e..947da88 100644 --- a/R/multi_covar_pca.R +++ b/R/multi_covar_pca.R @@ -17,8 +17,12 @@ multi_covar_pca <- function(object, pheno.df, name='covar_pca', grp.var='grp', c manual.shape = NULL, plot=TRUE){ stopifnot(c(grp.var, covars) %in% colnames(pheno.df)) pca.lst <- list() - grDevices::pdf(paste0(name, ".pdf")) - on.exit(grDevices::dev.off()) + + if (!is.na(name)){ + grDevices::pdf(paste0(name, ".pdf")) + on.exit(grDevices::dev.off()) + } + for (cvr.ind in 1:length(covars)){ pca.lst[[ covars[cvr.ind] ]] <- ezpca(object=object, pheno.df=pheno.df, shape=grp.var, color=covars[cvr.ind], name=NA, alpha=alpha, all.size=all.size, facet=facet, rm.leg.title=rm.leg.title, labels=labels,