chuiqin / irGSEA

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

Question on Heatmap #38

Open randystyle21 opened 5 months ago

randystyle21 commented 5 months ago

Dr. Fan,

Maybe this is irrelevant to irGSEA, probably more related to the Heatmap package but is there anyway that I can keep the pathway order? It seems like even if I use cluster_row=FALSE parameter, irGSEA packages changes the order of the pathways.

So I tried to factor it as below : pathway_figure <- factor(pathway_figure, levels= c("GOBP-PANCREATIC-A-CELL-DIFFERENTIATION", "GOMF-LIGAND-GATED-SODIUM-CHANNEL-ACTIVITY", "GOBP-REGULATION-OF-CHRONIC-INFLAMMATORY-RESPONSE", "GOMF-PROTEIN-SEQUESTERING-ACTIVITY", "GOBP-TRANSDIFFERENTIATION", "GOBP-AMYLIN-RECEPTOR-SIGNALING-PATHWAY"))

But the result of the heatmap is not in this order, even if I set up cluster_row=FALSE. Is there anyway that I can keep the order as intended? I generally use NULL and set up the top anyway but sometimes I needed to select relevant pathway for the sake of publication.

Thanks a ton in advance!!

chuiqin commented 5 months ago

Yes, this is a bug. I fixed this BUG in the new version of irGSEA. This bug can be fixed by uninstalling the old version of irGSEA and installing the latest version of irGSEA (version 3.2.5). Thanks for your feedback on this bug, here is the code demonstration.

library(Seurat)
library(SeuratData)
# download 3k PBMCs from 10X Genomics
# InstallData("pbmc3k")
data("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')

result.dge <- irGSEA.integrate(object = pbmc3k.final,
                               group.by = "seurat_annotations",
                               metadata = NULL, col.name = NULL,
                               method = c("AUCell","UCell","singscore","ssgsea"))

rownames(pbmc3k.final[["AUCell"]])[1:20]
# [1] "HALLMARK-ADIPOGENESIS"
# [2] "HALLMARK-ALLOGRAFT-REJECTION"
# [3] "HALLMARK-ANDROGEN-RESPONSE"
# [4] "HALLMARK-ANGIOGENESIS"
# [5] "HALLMARK-APICAL-JUNCTION"
# [6] "HALLMARK-APICAL-SURFACE"
# [7] "HALLMARK-APOPTOSIS"
# [8] "HALLMARK-BILE-ACID-METABOLISM"
# [9] "HALLMARK-CHOLESTEROL-HOMEOSTASIS"
# [10] "HALLMARK-COAGULATION"
# [11] "HALLMARK-COMPLEMENT"
# [12] "HALLMARK-DNA-REPAIR"
# [13] "HALLMARK-E2F-TARGETS"
# [14] "HALLMARK-EPITHELIAL-MESENCHYMAL-TRANSITION"
# [15] "HALLMARK-ESTROGEN-RESPONSE-EARLY"
# [16] "HALLMARK-ESTROGEN-RESPONSE-LATE"
# [17] "HALLMARK-FATTY-ACID-METABOLISM"
# [18] "HALLMARK-G2M-CHECKPOINT"
# [19] "HALLMARK-GLYCOLYSIS"
# [20] "HALLMARK-HEDGEHOG-SIGNALING"
irGSEA.heatmap(object = result.dge, method = "RRA",
               show.geneset = rownames(pbmc3k.final[["AUCell"]])[1:20],
               cluster_rows = F)

image