DIY GSEA

Authors

[Editor] Hu Zheng;

[Contributors]

Modified

2026-01-17

Note

Hiplot website

This page is the tutorial for source code version of the Hiplot DIY GSEA plugin. You can also use the Hiplot website to achieve no code ploting. For more information please see the following link:

https://hiplot.cn/basic/diy-gsea?lang=en

Make your geneset.

Setup

  • System Requirements: Cross-platform (Linux/MacOS/Windows)

  • Programming language: R

  • Dependent packages: data.table; jsonlite; clusterProfiler

# Install packages
if (!requireNamespace("data.table", quietly = TRUE)) {
  install.packages("data.table")
}
if (!requireNamespace("jsonlite", quietly = TRUE)) {
  install.packages("jsonlite")
}
if (!requireNamespace("clusterProfiler", quietly = TRUE)) {
  BiocManager::install("clusterProfiler")
}

# Load packages
library(data.table)
library(jsonlite)
library(clusterProfiler)
sessioninfo::session_info("attached")
─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.2 (2025-10-31)
 os       Ubuntu 24.04.3 LTS
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  C.UTF-8
 ctype    C.UTF-8
 tz       UTC
 date     2026-01-17
 pandoc   3.1.3 @ /usr/bin/ (via rmarkdown)
 quarto   1.8.27 @ /usr/local/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────
 package         * version date (UTC) lib source
 clusterProfiler * 4.18.4  2025-12-15 [1] Bioconduc~
 data.table      * 1.18.0  2025-12-24 [1] RSPM
 jsonlite        * 2.0.0   2025-03-27 [1] RSPM

 [1] /home/runner/work/_temp/Library
 [2] /opt/R/4.5.2/lib/R/site-library
 [3] /opt/R/4.5.2/lib/R/library
 * ── Packages attached to the search path.

──────────────────────────────────────────────────────────────────────────────

Data Preparation

# Load data
data1 <- data.table::fread(jsonlite::read_json("https://hiplot.cn/ui/basic/diy-gsea/data.json")$exampleData$textarea[[1]])
data1 <- as.data.frame(data1)
data2 <- data.table::fread(jsonlite::read_json("https://hiplot.cn/ui/basic/diy-gsea/data.json")$exampleData$textarea[[2]])
data2 <- as.data.frame(data2)

# convert data structure
data1[,2] <- as.numeric(data1[,2])
geneList <- data1[,2]
names(geneList) <- data1[,1]
geneList <- sort(geneList, decreasing = TRUE)
term <- data.frame(term=data2[,1], gene=data2[,2])

# View data
head(term)
                         term   gene
1 GO_ADAPTIVE_IMMUNE_RESPONSE ADAM17
2 GO_ADAPTIVE_IMMUNE_RESPONSE  AICDA
3 GO_ADAPTIVE_IMMUNE_RESPONSE  ALCAM
4 GO_ADAPTIVE_IMMUNE_RESPONSE  ANXA1
5 GO_ADAPTIVE_IMMUNE_RESPONSE   BATF
6 GO_ADAPTIVE_IMMUNE_RESPONSE  BCL10

Visualization

# DIY GSEA
y <- clusterProfiler::GSEA(geneList, TERM2GENE = term, pvalueCutoff = 1)
p <- gseaplot(
  y,
  y@result$Description[1],
  color = "#000000",
  by = "runningScore",
  color.line = "#4CAF50",
  color.vline= "#FA5860",
  title = "DIY GSEA Plot",
  )

p
FigureΒ 1: DIY GSEA