plot enrichment results
1
0
Entering edit mode
Manuela • 0
@07de4584
Last seen 18 months ago
Italy

Hi, I have a Reactome enrichment result, obtained from the reactome website. it is an excel with all the categories, ratios, p-values.. how could I visualize the enrichment results? ggplot2? enrichplot? How should I convert the data to let them readable with a code like the ones below? sorry but I'm very new in R Thank you!

Code should be placed in three backticks as shown below

library(DOSE)
data(geneList)
de <- names(geneList)[1:100]
x <- enrichDO(de)
barplot(x)


library(ggplot2)
library(forcats)
ggplot(result_reactome_121, showCategory = 10,
       aes(richFactor,
           fct_reorder(Description, richFactor))) +
  geom_segment(aes(xend=0, yend = Description)) +
  geom_point(aes(color=p.adjust, size = Count)) +
  scale_color_gradientn
(colours=c("#f7ca64", "#46bac2",
           "#7e62a3"),
  trans = "log10",
  guide=guide_colorbar(reverse=TRUE,
                       order=1)) +
  scale_size_continuous(range=c(2, 10)) +
  theme_dose(12) +
  xlab("Rich Factor") +
  lab(NULL) +
  ggtitle("Biological Processes")

# Error in barplot.default(x) : 'height' must be a vector or a matrix


sessionInfo( )

R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.0.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Rome
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.4.2 DOSE_3.26.1  

loaded via a namespace (and not attached):
 [1] KEGGREST_1.40.0         fastmatch_1.1-3         gtable_0.3.3            GOSemSim_2.26.0        
 [5] Biobase_2.60.0          lattice_0.21-8          vctrs_0.6.3             tools_4.3.1            
 [9] bitops_1.0-7            generics_0.1.3          stats4_4.3.1            parallel_4.3.1         
[13] tibble_3.2.1            fansi_1.0.4             AnnotationDbi_1.62.1    RSQLite_2.3.1          
[17] blob_1.2.4              pkgconfig_2.0.3         Matrix_1.5-4.1          data.table_1.14.8      
[21] S4Vectors_0.38.1        lifecycle_1.0.3         GenomeInfoDbData_1.2.10 stringr_1.5.0          
[25] HDO.db_0.99.1           compiler_4.3.1          Biostrings_2.68.1       munsell_0.5.0          
[29] fgsea_1.26.0            codetools_0.2-19        GenomeInfoDb_1.36.1     RCurl_1.98-1.12        
[33] pillar_1.9.0            crayon_1.5.2            GO.db_3.17.0            BiocParallel_1.34.2    
[37] cachem_1.0.8            tidyselect_1.2.0        stringi_1.7.12          dplyr_1.1.2            
[41] reshape2_1.4.4          splines_4.3.1           cowplot_1.1.1           fastmap_1.1.1          
[45] grid_4.3.1              colorspace_2.1-0        cli_3.6.1               magrittr_2.0.3         
[49] utf8_1.2.3              withr_2.5.0             scales_1.2.1            bit64_4.0.5            
[53] XVector_0.40.0          httr_1.4.6              bit_4.0.5               qvalue_2.32.0          
[57] png_0.1-8               memoise_2.0.1           IRanges_2.34.0          rlang_1.1.1            
[61] Rcpp_1.0.10             glue_1.6.2              DBI_1.1.3               BiocManager_1.30.21    
[65] BiocGenerics_0.46.0     R6_2.5.1                plyr_1.8.8              zlibbioc_1.46.0        
enrichplot clusterProfiler • 1.6k views
ADD COMMENT
0
Entering edit mode
@lluis-revilla-sancho
Last seen 9 days ago
European Union

If you want to directly use ggplot2 you will need to convert the enrich result to a data.frame with as.data.frame(result_reactome_121) and then you can use ggplot()

ADD COMMENT
0
Entering edit mode

not needed to convert to data.frame. See our demo in https://pubmed.ncbi.nlm.nih.gov/34557778/. Users can use ggplot() directly to visualize enrichment result in clusterProfiler.

ADD REPLY
0
Entering edit mode

The user tried your demo, specifically the plot code is the same as in the "Visualization using Ggplot2" section but reportedly it doesn't work.
I would prefer to follow the vignette, as it is tested more frequently and keep up with changes in code of the package and within R.

ADD REPLY
0
Entering edit mode
# Error in barplot.default(x) : 'height' must be a vector or a matrix

This error is from barplot(x).

And the reason is that the enrichplot package is not loaded and there is no barplot method available for enrichResults object in the R session.

This error is not related to the ggplot() supports.

ADD REPLY
0
Entering edit mode

Ah, I see what you mean now. Thanks, sorry for the confusion. I didn't realize the barplot call.

ADD REPLY

Login before adding your answer.

Traffic: 457 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6