irGSEA.merge: Merge the enrichment score assay

View source: R/irGSEA.merge.R

irGSEA.mergeR Documentation

Merge the enrichment score assay

Description

Merge the enrichment score assay among various Seurat objects

Usage

irGSEA.merge(
  object.x = NULL,
  object.y = NULL,
  method = c("AUCell", "UCell", "singscore", "ssgsea", "JASMINE", "viper"),
  overwrite = T
)

Arguments

object.x

Seurat object (V4 or V5).

object.y

The list includes various Seurat objects. The verison of Seurat object should be the same as the version of object.x.

method

A vector. Default c("AUCell", "UCell", "singscore", "ssgsea", "JASMINE", "viper").

overwrite

Default True. The same geneset name exists in two gene scoring matrices, the newly added geneset will overwrite the previous geneset if the overwrite is true. The newly added geneset will be forcibly renamed as "geneset's name + serial number" if the overwrite is false.

Value

Seurat object including score matrix.

Examples

## Not run: 
# load PBMC dataset by R package SeuratData
library(Seurat)
library(SeuratData)
# download 3k PBMCs from 10X Genomics
InstallData("pbmc3k")
library(Seurat)

library(RcppML)
library(irGSEA)
library(tidyverse)
library(clusterProfiler)
data("pbmc3k.final")
pbmc3k.final <- SeuratObject::UpdateSeuratObject(pbmc3k.final)

# download gmt file
gmt_url1 <- "https://data.broadinstitute.org/"
gmt_url2 <- "gsea-msigdb/msigdb/release/2023.2.Hs/",
gmt_url3 <- "h.all.v2023.2.Hs.symbols.gmt"
gmt_url <- paste0(gmt_url1, gmt_url2, gmt_url3)
local_gmt <- "./h.all.v2023.2.Hs.symbols.gmt"
download.file(gmt_url , local_gmt)
msigdb <- clusterProfiler::read.gmt("./h.all.v2023.2.Hs.symbols.gmt")

# convert to list[hallmarker] required by irGSEA package
msigdb$term <- factor(msigdb$term)
msigdb <- msigdb %>%
  dplyr::group_split(term, .keep = F) %>%
  purrr::map( ~.x %>% dplyr::pull(gene) %>% unique(.)) %>%
  purrr::set_names(levels(msigdb$term))

pbmc3k.final1 <- irGSEA.score(object = pbmc3k.final, assay = "RNA", slot = "data",
                              custom = T, geneset = msigdb[1:25],
                              method = c("AUCell", "UCell", "singscore", "ssgsea"),
                              kcdf = 'Gaussian')
pbmc3k.final2 <- irGSEA.score(object = pbmc3k.final, assay = "RNA", slot = "data",
                              custom = T, geneset = msigdb[26:50],
                              method = c("AUCell", "UCell", "singscore", "ssgsea"),
                              kcdf = 'Gaussian')

pbmc3k.final3 <- irGSEA.merge(object.x = pbmc3k.final1,
                              object.y = pbmc3k.final2,
                              method = c("AUCell", "UCell", "singscore", "ssgsea"),
                              overwrite = T)


## End(Not run)


chuiqin/irGSEA documentation built on July 27, 2024, 6:27 a.m.