From 395559b0256aacf0ed340019477eeba911a12569 Mon Sep 17 00:00:00 2001 From: Sebastien Vigneau Date: Fri, 17 Feb 2023 14:31:42 -0500 Subject: [PATCH 1/2] Update cluster_logfc.R for compatibility with R>4 Updated for compatibility with R >4.0.0. Since R 4.0.0, matrices have two classes, "matrix" and "array", which leads to a "condition has length > 1" error when running `if (!class(expr.mat)=="dgCMatrix")`. The "inherits" or "is" functions should be used instead of "==" for checking the class (https://developer.r-project.org/Blog/public/2019/11/09/when-you-think-class.-think-again/index.html). --- R/cluster_logfc.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/cluster_logfc.R b/R/cluster_logfc.R index db38b52..84853ae 100644 --- a/R/cluster_logfc.R +++ b/R/cluster_logfc.R @@ -16,7 +16,8 @@ if (is.factor(cluster.ids)==F) { cluster.ids <- as.factor(cluster.ids) } -if (!class(expr.mat)=="dgCMatrix") { +if (!inherits(expr.mat, "dgCMatrix")) { +#if (!class(expr.mat)=="dgCMatrix") { expr.mat <- Matrix(expr.mat,sparse=TRUE) } From a3fce0f42afcf8c36d0fde2c00eb28260ca4be26 Mon Sep 17 00:00:00 2001 From: Sebastien Vigneau Date: Fri, 17 Feb 2023 14:47:21 -0500 Subject: [PATCH 2/2] Update wmw_gsea.R for compatibility with R>4 Updated for compatibility with R >4.0.0. Since R 4.0.0, matrices have two classes, "matrix" and "array", which leads to a "condition has length > 1" error when running `if (!class(expr.mat)=="matrix")`. The "inherits" or "is" functions should be used instead of "==" for checking the class (https://developer.r-project.org/Blog/public/2019/11/09/when-you-think-class.-think-again/index.html). --- R/wmw_gsea.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/wmw_gsea.R b/R/wmw_gsea.R index 0d7b513..2ca8f14 100644 --- a/R/wmw_gsea.R +++ b/R/wmw_gsea.R @@ -18,7 +18,8 @@ wmw_gsea <- function(expr.mat,cluster.cells,log.fc.cluster,gene.sets) { -if (!class(expr.mat)=="matrix") { +if (!inherits(expr.mat, "matrix")) { +#if (!class(expr.mat)=="matrix") { expr.mat <- as.matrix(expr.mat) }