gseaNb - junjunlab/GseaVis GitHub Wiki
Input
You can put the clusterProfiler GSEA
/gseGO
/gseKEGG
enrichment results as input, here just use GSEA
function returned result as input to be test data.
Load test data
let's load our test data:
# load data
test_data <- system.file("extdata", "gseaRes.RDS", package = "GseaVis")
gseaRes <- readRDS(test_data)
gseaRes
# Gene Set Enrichment Analysis
#
#...@organism UNKNOWN
#...@setType UNKNOWN
#...@geneList Named num [1:27970] 6.02 5.96 5.84 5.8 5.72 ...
- attr(*, "names")= chr [1:27970] "Ecscr" "Gm32341" "B130034C11Rik" "Hkdc1" ...
#...nPerm
#...pvalues adjusted by 'BH' with cutoff <1
#...4917 enriched terms found
'data.frame': 4917 obs. of 11 variables:
$ ID : chr "GOBP_REGULATION_OF_VASCULOGENESIS" "GOBP_AMEBOIDAL_TYPE_CELL_MIGRATION" "GOBP_REGULATION_OF_OSSIFICATION" "GOBP_NEGATIVE_REGULATION_OF_EPITHELIAL_CELL_PROLIFERATION" ...
$ Description : chr "GOBP_REGULATION_OF_VASCULOGENESIS" "GOBP_AMEBOIDAL_TYPE_CELL_MIGRATION" "GOBP_REGULATION_OF_OSSIFICATION" "GOBP_NEGATIVE_REGULATION_OF_EPITHELIAL_CELL_PROLIFERATION" ...
$ setSize : int 14 382 106 110 322 209 228 278 11 34 ...
$ enrichmentScore: num 0.803 -0.345 -0.461 -0.456 -0.346 ...
$ NES : num 1.85 -1.39 -1.61 -1.58 -1.36 ...
$ pvalue : num 0.000273 0.00051 0.000528 0.000543 0.000853 ...
$ p.adjust : num 0.667 0.667 0.667 0.667 0.686 ...
$ qvalues : num 0.667 0.667 0.667 0.667 0.686 ...
$ rank : num 1515 7626 6611 7802 7751 ...
$ leading_edge : chr "tags=29%, list=5%, signal=27%" "tags=36%, list=27%, signal=27%" "tags=39%, list=24%, signal=30%" "tags=42%, list=28%, signal=30%" ...
$ core_enrichment: chr "Adm/Ramp2/Hey2/Asb4" "Akap12/Ceacam1/Zeb2/Foxp1/Efnb2/Tpbg/Hyal1/Mmp9/Slc8a1/Pfn2/Ltb4r2/Ilk/Bcar1/Gipc1/Plpp3/Arhgef7/Prkx/Epha2/Hda"| __truncated__ "Ddr2/Ifitm5/S1pr1/Tgfb1/Intu/Sox11/Bmp7/Bmpr2/Mdk/Smad3/Fbn2/Tent5a/Adgrv1/Calca/Matn1/Enpp1/Twist1/Alox5/Ccn1/"| __truncated__ "Sparc/Tgfbr3/Ift172/Flt1/Sfrp2/Ceacam1/Pex2/Cdkn1b/Maged1/Efnb2/Klf9/Sfn/Nupr1/Aqp11/Tgfb2/Robo1/Tgfb1/Nr2f2/Rb"| __truncated__ ...
#...Citation
T Wu, E Hu, S Xu, M Chen, P Guo, Z Dai, T Feng, L Zhou, W Tang, L Zhan, X Fu, S Liu, X Bo, and G Yu.
clusterProfiler 4.0: A universal enrichment tool for interpreting omics data.
The Innovation. 2021, 2(3):100141
classic plot
Give a specific term name to plot:
# all plot
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS')
Only retain curve:
# retain curve
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
subPlot = 1)
Retain curve and heatmap:
# retain curve and heatmap
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
subPlot = 2)
Wrap the term name if it is so long:
# wrap the term title
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
subPlot = 2,
termWidth = 30)
Mark your gene in this pathway:
# add gene in specific pathway
mygene <- c("Entpd8","Htr2a","Nt5e","Actn3","Entpd1",
"Pfkp", "Tpi1","Igf1","Ddit4","Ak9")
# plot
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
subPlot = 2,
addGene = mygene)
Change gene name color and arrow type:
# change gene color and arrow type
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
subPlot = 2,
addGene = mygene,
arrowType = 'open',
geneCol = 'black')
Retain all plot:
# all plot
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
subPlot = 3,
addGene = mygene,
rmSegment = TRUE)
New style GSEA
Let's see new style plot:
# new style GSEA
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
newGsea = T)
Remove point:
# new style GSEA remove point
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
newGsea = T,
addPoint = F)
You can change heatmap color:
# change heatmap color
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
newGsea = T,
addPoint = F,
newHtCol = c("blue","white", "red"))
Add gene name:
# new style GSEA with gene name
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
newGsea = T,
addGene = mygene)
Remove segment line:
# remove red segment
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
newGsea = T,
rmSegment = T,
addGene = mygene)
Remove heatmap:
# remove heatmap
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
newGsea = T,
rmSegment = T,
rmHt = T,
addGene = mygene)
Add NES and Pvalue
You can also add NES scores and Pvalue:
# add pvalue and NES
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
newGsea = T,
addGene = mygene,
addPval = T)
Control pvalue label position and color:
# control label ajustment
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
newGsea = T,
addGene = mygene,
addPval = T,
pvalX = 0.75,pvalY = 0.8,
pCol = 'black',
pHjust = 0)
Classic plot with pvalue label:
# clsaasic with pvalue
gseaNb(object = gseaRes,
geneSetID = 'GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
addGene = mygene,
addPval = T,
pvalX = 0.75,pvalY = 0.8,
pCol = 'black',
pHjust = 0)
Multiple GSEA plot
You can use loop function to plot multiple GSEA plots:
# bacth plot
terms <- c('GOBP_NUCLEOSIDE_DIPHOSPHATE_METABOLIC_PROCESS',
'GOBP_REGULATION_OF_OSSIFICATION',
'GOBP_TISSUE_MIGRATION',
'GOBP_CELL_MATRIX_ADHESION')
# plot
lapply(terms, function(x){
gseaNb(object = gseaRes,
geneSetID = x,
addPval = T,
pvalX = 0.75,pvalY = 0.75,
pCol = 'black',
pHjust = 0)
}) -> gseaList
# combine
cowplot::plot_grid(plotlist = gseaList,ncol = 2,align = 'hv')
Retain curve and heatmap:
# retain curve and heatmap
# plot
lapply(terms, function(x){
gseaNb(object = gseaRes,
geneSetID = x,
addPval = T,
pvalX = 0.75,pvalY = 0.75,
pCol = 'black',
pHjust = 0,
subPlot = 2)
}) -> gseaList1
# combine
cowplot::plot_grid(plotlist = gseaList1,ncol = 2,align = 'hv')
New style plot:
# new style plot
# plot
lapply(terms, function(x){
gseaNb(object = gseaRes,
geneSetID = x,
newGsea = T,
addPval = T,
pvalX = 0.75,pvalY = 0.75,
pCol = 'black',
pHjust = 0,
subPlot = 2)
}) -> gseaList1
# combine
cowplot::plot_grid(plotlist = gseaList1,ncol = 2,align = 'hv')
More parameters
More parameters pleas refer to:
?gseaNb