Skip to content

Commit

Permalink
Merge pull request #39 from grst/master
Browse files Browse the repository at this point in the history
Make compatible with GSVA >=1.36.0
  • Loading branch information
dviraran authored May 5, 2020
2 parents 23d8f48 + b8ce5e4 commit 06d1b85
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions R/xCell.R
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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)

Expand Down

0 comments on commit 06d1b85

Please sign in to comment.