Home > Blockchain >  How to merge heatmap with goplot in R ggplot?
How to merge heatmap with goplot in R ggplot?

Time:11-29

I created a heatmap using pheatmap package as follows:

test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)]   3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)]   2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)]   4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Gene", 1:20, sep = "")

a=pheatmap(test)
a

heatmap

And I created GOplot using GOplot package as follows: dput(circ)

structure(list(category = c("Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms", "Enriched Terms", "Enriched Terms", 
"Enriched Terms", "Enriched Terms"), ID = c("inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "inflammatory response", 
"inflammatory response", "inflammatory response", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "T cell activation", "T cell activation", 
"T cell activation", "cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"cytokine mediated signaling pathway", "cytokine mediated signaling pathway", 
"T cell proliferation", "T cell proliferation", "T cell proliferation", 
"T cell proliferation", "T cell proliferation", "T cell proliferation", 
"T cell proliferation", "T cell proliferation", "T cell proliferation", 
"T cell proliferation", "T cell proliferation", "T cell proliferation", 
"T cell proliferation", "T cell proliferation", "T cell proliferation", 
"T cell proliferation", "T cell proliferation", "T cell proliferation", 
"T cell proliferation", "T cell proliferation", "T cell proliferation", 
"T cell proliferation", "T cell proliferation", "T cell proliferation", 
"T cell proliferation", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"wound healing", "wound healing", "wound healing", "wound healing", 
"response to progesterone", "response to progesterone", "response to progesterone", 
"response to progesterone", "response to progesterone", "response to progesterone", 
"response to progesterone", "response to progesterone", "response to progesterone", 
"response to progesterone", "response to progesterone"), term = c("GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", "GO:0006954", 
"GO:0006954", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", "GO:0042110", 
"GO:0042110", "GO:0042110", "GO:0042110", "GO:0019221", "GO:0019221", 
"GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", 
"GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", 
"GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", 
"GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", 
"GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", 
"GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", 
"GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", "GO:0019221", 
"GO:0019221", "GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", 
"GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", 
"GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", 
"GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", 
"GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", "GO:0042098", 
"GO:0042098", "GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", 
"GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", 
"GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", 
"GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", 
"GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", 
"GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", 
"GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", 
"GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", "GO:0042060", 
"GO:0032570", "GO:0032570", "GO:0032570", "GO:0032570", "GO:0032570", 
"GO:0032570", "GO:0032570", "GO:0032570", "GO:0032570", "GO:0032570", 
"GO:0032570"), count = c(72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 
72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 
72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 
72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 
72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 
72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 72L, 47L, 
47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 
47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 
47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 47L, 
47L, 47L, 47L, 47L, 47L, 47L, 47L, 38L, 38L, 38L, 38L, 38L, 38L, 
38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 
38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 38L, 
38L, 38L, 38L, 38L, 38L, 38L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 
25L, 25L, 25L, 25L, 25L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 
39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 
39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 
39L, 39L, 39L, 39L, 39L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 
11L, 11L, 11L), genes = c("CDO1", "HLA-DRB1", "ACP5", "HMGB2", 
"HMOX1", "ADCY1", "F7", "CD163", "TYROBP", "FCER1G", "CIITA", 
"FCGR3A", "CXCL9", "CCL2", "CCR1", "CCL5", "MMP3", "ABCC2", "ALOX15", 
"SGK1", "FPR3", "APOD", "SCUBE1", "SERPINC1", "PDE5A", "IL1B", 
"CYBB", "SLAMF8", "TRAF3IP2", "IL18", "METRNL", "IL17B", "IRAK2", 
"IL20RB", "IRF5", "PTAFR", "IL1RL2", "ITGB2", "PTGIR", "ITGB6", 
"PDCD4", "GGT1", "PTN", "BMPR1B", "PLA2G2D", "SPHK1", "CXCL17", 
"SCG2", "SIGLEC10", "TRIM55", "C1QA", "LILRB4", "RHBDF2", "SOCS3", 
"GRN", "RELB", "PSTPIP1", "ECM1", "NFAM1", "BCL6B", "ACE2", "CD6", 
"CD14", "TIMP1", "GPR68", "CD36", "CD74", "ADGRE5", "TNFAIP3", 
"LYZ", "HCK", "CD96", "ERBB2", "HLA-DQA1", "HLA-DQB1", "HLA-DRB1", 
"ZNF683", "EOMES", "ICOS", "FCER1G", "CCL2", "CCL5", "WAS", "RASAL3", 
"SOCS1", "PDE5A", "IL1B", "STX11", "IL7", "TRAF3IP2", "TNFRSF9", 
"IL18", "TNFRSF14", "IL20RB", "IRF1", "ITGAX", "IL1RL2", "ITGB2", 
"ITK", "LAPTM5", "BMP4", "CLEC4F", "PLA2G2D", "LILRB4", "SH2B3", 
"VTCN1", "RELB", "SH2D2A", "TSPAN32", "RUNX3", "CD6", "CD7", 
"LMO1", "CD86", "CD70", "CD74", "PAX1", "MPZL2", "LEF1", "FCER1G", 
"IFITM3", "CXCL9", "CCL2", "CCR1", "CCL5", "CNTFR", "CD300LF", 
"PYDC1", "MST1R", "SOCS1", "IL1B", "IL17RD", "IL2RB", "IL7", 
"IL10RA", "TRAF3IP2", "IL15RA", "IL18", "TNFRSF14", "IRAK2", 
"IL20RB", "IRF1", "IRF5", "IL1RL2", "LAPTM5", "PXDN", "IL1RAPL2", 
"SPHK1", "CXCL17", "LILRB4", "SH2B3", "ECM1", "GREM2", "CD70", 
"CD74", "TNFAIP3", "HCK", "ERBB2", "HLA-DQA1", "HLA-DRB1", "CCL5", 
"RASAL3", "PDE5A", "IL1B", "TNFRSF9", "IL18", "TNFRSF14", "IL20RB", 
"IRF1", "ITGAX", "ITGB2", "LAPTM5", "BMP4", "PLA2G2D", "LILRB4", 
"VTCN1", "SH2D2A", "TSPAN32", "CD6", "LMO1", "CD86", "CD70", 
"HGFAC", "NRG1", "ERBB2", "HMOX1", "F7", "FCER1G", "FCGR3A", 
"CCL2", "C1QTNF1", "VAV3", "FGG", "MMP3", "POU2F3", "ALOX15", 
"MIA3", "WAS", "ENPP4", "SCUBE1", "SERPINC1", "IL1B", "GATA2", 
"ITGA5", "ITGB6", "BMP4", "DST", "LILRB4", "IL24", "KRT6A", "RAP2B", 
"SH2B3", "DSP", "TSPAN32", "TFPI", "TIMP1", "EVPLL", "CD36", 
"TNFAIP3", "PAX7", "PARD3", "NRG1", "ERBB2", "CCL2", "SOCS1", 
"RELN", "PTN", "SPHK1", "DSG1", "ABHD2", "SOCS3", "OXTR"), logFC = c(-2.737960452, 
1.241037398, 1.374760702, -1.103596949, 1.079758824, 3.086032109, 
-2.877651668, 1.09476118, 1.118517102, 1.041377427, 1.319558299, 
1.118681141, 2.891440638, 1.122498237, 1.92052302, 1.54657149, 
2.538427301, -2.69483845, -3.915575094, 1.319202149, 1.697645266, 
-2.86918927, 2.1371583, -5.659311147, -1.53119513, 1.945184259, 
1.347387517, 1.722650321, -1.180236204, 1.21734454, 1.084121694, 
-5.283056691, 1.205271542, 1.917439533, 1.256984968, 1.180701005, 
-3.027851614, 1.24994078, 1.527263076, -2.185935071, -1.146129256, 
-5.061405849, -3.572421784, 4.006705524, 2.224401737, 1.169631321, 
-3.463052584, -2.572606019, 1.94368823, -5.940020275, 1.152347835, 
1.716108464, 1.201977508, 1.706652811, 1.062033751, 1.233980975, 
1.310927918, 1.903484885, 1.115666204, 1.293787307, -3.656400355, 
1.959492212, 1.067545802, 1.499824047, 1.404434777, -2.937891421, 
1.107773701, 1.043144439, 1.777494393, 1.646834437, 1.156112282, 
1.10944754, -4.210238561, 1.865313935, 1.513262912, 1.241037398, 
1.782577274, 2.516774087, 2.339406632, 1.041377427, 1.122498237, 
1.54657149, 1.191237579, 1.472211185, 1.857872456, -1.53119513, 
1.945184259, 1.511626606, -1.727937842, -1.180236204, 1.911680124, 
1.21734454, 1.334667618, 1.917439533, 1.484782869, 1.212649627, 
-3.027851614, 1.24994078, 1.811227395, 1.233641, -2.12693152, 
-1.836124452, 2.224401737, 1.716108464, 1.035261508, -2.405733686, 
1.233980975, 1.267228904, 2.207264277, 1.410751117, 1.959492212, 
2.971479523, -4.825751399, 1.047624972, 2.837308276, 1.107773701, 
-4.987747449, -1.74915527, 1.247360205, 1.041377427, 1.058227706, 
2.891440638, 1.122498237, 1.92052302, 1.54657149, -4.172482769, 
1.333487402, 4.152707357, -1.785658712, 1.857872456, 1.945184259, 
-1.95196654, 1.941367702, -1.727937842, 1.057464494, -1.180236204, 
1.020161179, 1.21734454, 1.334667618, 1.205271542, 1.917439533, 
1.484782869, 1.256984968, -3.027851614, 1.233641, 1.788558045, 
-5.462904275, 1.169631321, -3.463052584, 1.716108464, 1.035261508, 
1.903484885, -2.291272692, 2.837308276, 1.107773701, 1.777494393, 
1.156112282, -4.210238561, 1.865313935, 1.241037398, 1.54657149, 
1.472211185, -1.53119513, 1.945184259, 1.911680124, 1.21734454, 
1.334667618, 1.917439533, 1.484782869, 1.212649627, 1.24994078, 
1.233641, -2.12693152, 2.224401737, 1.716108464, -2.405733686, 
1.267228904, 2.207264277, 1.959492212, -4.825751399, 1.047624972, 
2.837308276, 5.993222336, -2.978513041, -4.210238561, 1.079758824, 
-2.877651668, 1.041377427, 1.118681141, 1.122498237, 1.376906496, 
-1.914010292, -5.261606201, 2.538427301, -3.653580929, -3.915575094, 
-1.138879528, 1.191237579, 1.613578374, 2.1371583, -5.659311147, 
1.945184259, -1.574242178, 1.141089282, -2.185935071, -2.12693152, 
-1.138578308, 1.716108464, 4.7309855, 2.559918081, 1.135394507, 
1.035261508, -1.581412595, 2.207264277, -1.836137414, 1.499824047, 
-5.643250914, -2.937891421, 1.777494393, -4.220593474, -1.301224439, 
-2.978513041, -4.210238561, 1.122498237, 1.857872456, -2.263900849, 
-3.572421784, 1.169631321, -4.277817031, 1.778735721, 1.706652811, 
-2.319315751), adj_pval = c(3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 
3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 3.96e-05, 0.00237, 0.00237, 
0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 
0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 
0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 
0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 
0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 
0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 0.00237, 
0.00237, 0.00237, 0.00237, 0.00542, 0.00542, 0.00542, 0.00542, 
0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 
0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 
0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 
0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 
0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00542, 0.00593, 
0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 
0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 
0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 0.00593, 
0.00593, 0.00593, 0.00593, 0.00631, 0.00631, 0.00631, 0.00631, 
0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 
0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 
0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 
0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 
0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 0.00631, 
0.00682, 0.00682, 0.00682, 0.00682, 0.00682, 0.00682, 0.00682, 
0.00682, 0.00682, 0.00682, 0.00682), zscore = c(3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.77123616632825, 
3.77123616632825, 3.77123616632825, 3.77123616632825, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.64662478744736, 3.64662478744736, 
3.64662478744736, 3.64662478744736, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3.24442842261525, 3.24442842261525, 3.24442842261525, 3.24442842261525, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
0.160128153805087, 0.160128153805087, 0.160128153805087, 0.160128153805087, 
-0.301511344577764, -0.301511344577764, -0.301511344577764, -0.301511344577764, 
-0.301511344577764, -0.301511344577764, -0.301511344577764, -0.301511344577764, 
-0.301511344577764, -0.301511344577764, -0.301511344577764)), class = "data.frame", row.names = c(NA, 
-232L))

and

b=GOBar(circ, display = 'multiple')
b

goplot

Next, I wanted to merge a, b as single figure. I tried

ggarrange(a,b,labels = c("A", "B"), ncol = 1, nrow = 1)

But it ouput only Goplot as b keeping a as blank:

CodePudding user response:

Have you tried patchwork? You can combine many types of figures in different ways with it.

https://patchwork.data-imaginist.com/

CodePudding user response:

The issue is that pheatmap returns a pheatmap object. Basically it is a list which besides the plot contains several other elements. Hence, to combine the heatmap with another plot you have to extract the element which contains the "plot", which is the element called gtable:

Note: IMHO the issue is not related to your GOplot so for the sake of simplicity I replaced it with a simple ggplot based on mtcars.

library(pheatmap)
library(ggpubr)

set.seed(123)

a <- pheatmap(test)

b <- ggplot(mtcars, aes(hp, mpg))  
  geom_point()

ggarrange(a$gtable, b, labels = c("A", "B"))

  • Related