From b8ce5e4bfb1771d4245534c61ef5c87c68c4330d Mon Sep 17 00:00:00 2001 From: Gregor Sturm Date: Tue, 5 May 2020 17:42:45 +0200 Subject: [PATCH] Make compatible with GSVA >=1.36.0 GSVA >= 1.36.0 does not support `parallel.type` any more. Instead it automatically uses the backend registered by BiocParallel, the argument is, therefore, not required any more. GSVA 1.36.0 is shipped with the latest, R4.0.0 Bioconductor release. --- R/xCell.R | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/R/xCell.R b/R/xCell.R index 5482d93..578d641 100644 --- a/R/xCell.R +++ b/R/xCell.R @@ -93,7 +93,9 @@ xCellAnalysis <- function(expr, signatures=NULL, genes=NULL, spill=NULL, rnaseq= #' @param genes list of genes to use in the analysis. #' @param file.name string for the file name for saving the scores. Default is NULL. #' @param parallel.sz integer for the number of threads to use. Default is 4. -#' @param parallel.type Type of cluster architecture when using snow. 'SOCK' or 'FORK'. Fork is faster, but is not supported in windows. +#' @param parallel.type Type of cluster architecture when using snow. 'SOCK' or 'FORK'. +#' Fork is faster, but is not supported in windows. +#' This argument is ignored in GSVA versions >= 1.36.0. Register a `BiocParallel` backend instead. #' @return the raw xCell scores rawEnrichmentAnalysis <- function(expr, signatures, genes, file.name = NULL, parallel.sz = 4, parallel.type = 'SOCK') { @@ -111,8 +113,16 @@ rawEnrichmentAnalysis <- function(expr, signatures, genes, file.name = NULL, par expr <- apply(expr, 2, rank) # Run ssGSEA analysis for the ranked gene expression dataset - scores <- GSVA::gsva(expr, signatures, method = "ssgsea", - ssgsea.norm = FALSE,parallel.sz = parallel.sz,parallel.type = parallel.type) + if(packageVersion("GSVA") >= "1.36.0") { + # GSVA >= 1.36.0 does not support `parallel.type` any more. + # Instead it automatically uses the backend registered by BiocParallel. + scores <- GSVA::gsva(expr, signatures, method = "ssgsea", + ssgsea.norm = FALSE,parallel.sz = parallel.sz) + } else { + scores <- GSVA::gsva(expr, signatures, method = "ssgsea", + ssgsea.norm = FALSE,parallel.sz = parallel.sz,parallel.type = parallel.type) + } + scores = scores - apply(scores,1,min)