chuiqin / irGSEA

The integration of single cell rank-based gene set enrichment analysis
Other
106 stars 17 forks source link

Q:how to show two groups in one scatterplot? #11

Open doctorSXY opened 2 years ago

doctorSXY commented 2 years ago

I tried to use "scatterplot <- irGSEA.density.scatterplot(object,split.by = "orig.ident", method = "UCell", show.geneset = "HALLMARK-INFLAMMATORY-RESPONSE", reduction = "umap")" but i failed. what can i do to improve? Thanks!

chuiqin commented 2 years ago

Because there is no parameter ("split.by") in the irGSEA.density.scatterplot function. But you can achieve faceted effects with simple ggplot2 syntax.

# load PBMC dataset by R package SeuratData
library(Seurat)
library(SeuratData)
# download 3k PBMCs from 10X Genomics
InstallData("pbmc3k")
data("pbmc3k.final")
pbmc3k.final <- SeuratObject::UpdateSeuratObject(pbmc3k.final)

# Seurat object
pbmc3k.final <- irGSEA.score(object = pbmc3k.final, assay = "RNA",
slot = "data", msigdb = T, species = "Homo sapiens",
category = "H", geneid = "symbol",
method = c("AUCell", "UCell", "singscore", "ssgsea"), kcdf = 'Gaussian')

irGSEA.density.scatterplot1 <- irGSEA.density.scatterplot(object = pbmc3k.final,
method = "UCell", show.geneset = "HALLMARK-INFLAMMATORY-RESPONSE",
reduction = "umap")

# If I want to facet by cluster
a <- irGSEA.density.scatterplot(pbmc3k.final,
                           method = "UCell",
                           show.geneset = "HALLMARK-INFLAMMATORY-RESPONSE",
                           reduction = "umap")
a$data$`seurat_clusters` <- pbmc3k.final$seurat_clusters
a
a+facet_wrap(~`seurat_clusters`)

image image

doctorSXY commented 2 years ago

Thank you so much for your suggestion!