R/SSgsea.R

Defines functions Ssgsea

Documented in Ssgsea

#' Title
#'
#' @param bulkdata A matrix with genes in rows and samples in columns.
#' @param tissue  One of "BLOOD","LIVER","LUNG","MUSCLE","OVARY","HEART","BONE",
#'  "ESOPHAGUS","STOMACH","GASTRIC","PANCREAS","CEREBELLUM",
#'  "NEUROTYPES","RETINA","EYE","THYMUS","INTESTINE","ADRENAL",
#'  "ESOPHAGEAL","DUODENAL","OLFACTORY","CEREBRUM".
#' @importFrom singscore rankGenes
#' @importFrom GSEABase getGmt
#' @importFrom GSVA gsva
#' @return A data frame of Mixed cellular fractions.
#' @export
#'
#' @examples
#'  Bulk <- Bulk_GSE60424
#'  res <- Ssgsea(bulkdata = Bulk,
#'                tissue = "BLOOD")
#'

Ssgsea <- function(bulkdata,tissue) {


  rankData <- singscore::rankGenes(bulkdata)


  probpath <- system.file("extdata", "c8.all.v7.4.symbols.gmt", package = "deconvBench")

  geneset <- GSEABase::getGmt(probpath)

  Tissue <- c("BLOOD","LIVER","LUNG","MUSCLE","OVARY","HEART","BONE",
              "ESOPHAGUS","STOMACH","GASTRIC","PANCREAS","CEREBELLUM",
              "NEUROTYPES","RETINA","EYE","THYMUS","INTESTINE","ADRENAL",
              "ESOPHAGEAL","DUODENAL","OLFACTORY","CEREBRUM")

  if(any(Tissue==tissue)){


    tissue_geneset <- geneset[names(geneset)[grep(tissue,names(geneset))]]


    ssgseaScore <- GSVA::gsva(as.matrix(bulkdata),
                              tissue_geneset,
                              method='ssgsea',
                              kcdf='Gaussian',
                              abs.ranking=TRUE)

    ssGSEA_res <- t(ssgseaScore)

  }else{stop("Please enter one of the sample tissue types:BLOOD,LIVER,LUNG, MUSCLE,OVARY,HEART,
             BONE,ESOPHAGUS,STOMACH,GASTRIC,PANCREAS,CEREBELLUM,NEUROTYPES,RETINA,EYE,THYMUS,
             INTESTINE,ADRENAL,ESOPHAGEAL,DUODENAL,OLFACTORY,CEREBRUM")

  }

  res_Ssgsea <- ssGSEA_res

  return(res_Ssgsea)

}
libcell/deconvBench documentation built on Sept. 24, 2022, 12:36 p.m.