R语言绘图 | GO富集柱状图

文摘   2024-11-05 11:00   美国  

一边学习,一边总结,一边分享!

由于微信改版,一直有同学反映。存在长时间接收不到公众号的推文。那么请跟随以下步骤,将小杜的生信筆記设置为星标,不错过每一条推文教程。

欢迎关注《小杜的生信笔记》!!

如何加入社群

小杜的生信笔记仅有微信社群

1. 微信群:付费社群。添加小杜好友,加友请知:加友须知!!,加入社群请查看小杜生信笔记付费加友入群声明

入群声明

2. 小杜个人微信:若你有好的教程或想法,可添加小杜个人微信。值得注意的是,小杜个人微信并不支持免费咨询长时间咨询,但支持小问题2-3个免费咨询。

小杜微信:

知识星球:

本期教程


2022年教程总汇

https://mp.weixin.qq.com/s/Lnl258WhbK2a8pRZFuIyVg

2023年教程总汇

https://mp.weixin.qq.com/s/wCTswNP8iHMNvu5GQauHdg

code

library(ggplot2)
library(dplyr)

所需数据格式:GO富集结果

category_colors <- c("Biological Process" = "#66c2a5", "Molecular Function" = "#fc8d62", 
"Cellular Component" = "#8da0cb")

ggplot(data, aes(x = Count, y = reorder(Term, Count), fill = Category)) +
geom_bar(stat = "identity", color = "black",width = 0.8) +
scale_fill_manual(values = category_colors) +
facet_grid(Category ~ ., scales = "free_y",
space = "free_y", switch = "y") + # switch 'y' to move category labels to left
theme_classic() +
labs(x = "Number of Genes", y = "", title = "") +
theme(
strip.text.y.left = element_text(angle = 90, hjust = 0, face = "bold"), # Move labels to the left without borders
strip.placement = "outside", # Place strip labels outside the plot area
strip.background = element_blank(), # Remove the strip background
panel.spacing.y = unit(0.0, "lines"), ## 修改每个图之间的间距
legend.position = "none",
axis.text.x = element_text(angle = 0, hjust = 1, colour = "black", size = 10),
axis.text.y = element_text(colour = "black", size = 10)
) +
scale_x_continuous(expand = c(0, 0)) +
geom_text(aes(label = Count), hjust = -0.2, size = 3.5) # Display count on bars

R版本信息

> sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8
[2] LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.utf8

time zone: Asia/Shanghai
tzcode source: internal

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

other attached packages:
[1] writexl_1.5.0
[2] ggVennDiagram_1.5.2
[3] GEOquery_2.72.0
[4] biomaRt_2.60.1
[5] ggrepel_0.9.5
[6] DESeq2_1.44.0
[7] SummarizedExperiment_1.34.0
[8] Biobase_2.64.0
[9] MatrixGenerics_1.16.0
[10] matrixStats_1.3.0
[11] GenomicRanges_1.56.1
[12] GenomeInfoDb_1.40.1
[13] IRanges_2.38.1
[14] S4Vectors_0.42.1
[15] BiocGenerics_0.50.0
[16] factoextra_1.0.7
[17] pheatmap_1.0.12
[18] ggsci_3.2.0
[19] lubridate_1.9.3
[20] forcats_1.0.0
[21] stringr_1.5.1
[22] purrr_1.0.2
[23] readr_2.1.5
[24] tibble_3.2.1
[25] tidyverse_2.0.0
[26] autoReg_0.3.3
[27] igraph_2.0.3
[28] plyr_1.8.9
[29] corrplot_0.94
[30] reshape2_1.4.4
[31] ggpubr_0.6.0
[32] readxl_1.4.3
[33] tidyr_1.3.1
[34] dplyr_1.1.4
[35] ggplot2_3.5.1

loaded via a namespace (and not attached):
[1] fs_1.6.4 httr_1.4.7
[3] RColorBrewer_1.1-3 insight_0.20.3
[5] numDeriv_2016.8-1.1 tools_4.4.0
[7] backports_1.5.0 sjlabelled_1.2.0
[9] utf8_1.2.4 R6_2.5.1
[11] lazyeval_0.2.2 mgcv_1.9-1
[13] jomo_2.7-6 withr_3.0.1
[15] prettyunits_1.2.0 cli_3.6.3
[17] textshaping_0.4.0 exactRankTests_0.8-35
[19] officer_0.6.6 labeling_0.4.3
[21] mvtnorm_1.2-6 askpass_1.2.0
[23] systemfonts_1.1.0 yulab.utils_0.1.7
[25] gfonts_0.2.0 parallelly_1.38.0
[27] limma_3.60.4 rstudioapi_0.16.0
[29] RSQLite_2.3.7 httpcode_0.3.0
[31] generics_0.1.3 shape_1.4.6.1
[33] crosstalk_1.2.1 car_3.1-2
[35] zip_2.3.1 Matrix_1.7-0
[37] fansi_1.0.6 abind_1.4-5
[39] lifecycle_1.0.4 carData_3.0-5
[41] gtsummary_2.0.1 SparseArray_1.4.8
[43] BiocFileCache_2.12.0 blob_1.2.4
[45] promises_1.3.0 crayon_1.5.3
[47] mitml_0.4-5 lattice_0.22-6
[49] KEGGREST_1.44.1 pillar_1.9.0
[51] knitr_1.48 boot_1.3-31
[53] future.apply_1.11.2 codetools_0.2-20
[55] pan_1.9 glue_1.6.2
[57] fontLiberation_0.1.0 data.table_1.15.4
[59] vctrs_0.6.5 png_0.1-8
[61] cellranger_1.1.0 gtable_0.3.5
[63] cachem_1.1.0 xfun_0.47
[65] S4Arrays_1.4.1 mime_0.12
[67] prodlim_2024.06.25 rsconnect_1.3.1
[69] survival_3.7-0 iterators_1.0.14
[71] lava_1.8.0 statmod_1.5.0
[73] nlme_3.1-166 bit64_4.0.5
[75] fontquiver_0.2.1 progress_1.2.3
[77] filelock_1.0.3 maxstat_0.7-25
[79] rpart_4.1.23 colorspace_2.1-1
[81] DBI_1.2.3 nnet_7.3-19
[83] tidyselect_1.2.1 bit_4.0.5
[85] compiler_4.4.0 curl_5.2.2
[87] glmnet_4.1-8 httr2_1.0.3
[89] flextable_0.9.6 mice_3.16.0
[91] pammtools_0.5.93 xml2_1.3.6
[93] fontBitstreamVera_0.1.1 DelayedArray_0.30.1
[95] plotly_4.10.4 checkmate_2.3.2
[97] scales_1.3.0 pec_2023.04.12
[99] rappdirs_0.3.3 digest_0.6.37
[101] minqa_1.2.8 rmarkdown_2.28
[103] XVector_0.44.0 htmltools_0.5.8.1
[105] pkgconfig_2.0.3 lme4_1.1-35.5
[107] dbplyr_2.5.0 fastmap_1.2.0
[109] rlang_1.1.4 htmlwidgets_1.6.4
[111] UCSC.utils_1.0.0 shiny_1.9.1
[113] farver_2.1.2 jsonlite_1.8.8
[115] BiocParallel_1.38.0 magrittr_2.0.3
[117] Formula_1.2-5 GenomeInfoDbData_1.2.12
[119] patchwork_1.2.0 munsell_0.5.1
[121] Rcpp_1.0.13 gdtools_0.3.7
[123] stringi_1.8.4 zlibbioc_1.50.0
[125] MASS_7.3-61 tidycmprsk_1.1.0
[127] parallel_4.4.0 listenv_0.9.1
[129] sjmisc_2.8.10 Biostrings_2.72.1
[131] splines_4.4.0 hms_1.1.3
[133] locfit_1.5-9.10 timereg_2.0.5
[135] uuid_1.2-1 ggsignif_0.6.4
[137] crul_1.5.0 evaluate_0.24.0
[139] nloptr_2.1.1 tzdb_0.4.0
[141] foreach_1.5.2 httpuv_1.6.15
[143] moonBook_0.3.1 openssl_2.2.1
[145] future_1.34.0 broom_1.0.6
[147] xtable_1.8-4 rstatix_0.7.2
[149] later_1.3.2 viridisLite_0.4.2
[151] ragg_1.3.2 memoise_2.0.1
[153] AnnotationDbi_1.66.0 timechange_0.3.0
[155] globals_0.16.3

若我们的教程对你有所帮助,请点赞+收藏+转发,大家的支持是我们更新的动力!!

本期教程,我们已上传云盘,社群同学可直接访问。

往期部分文章

1. 最全WGCNA教程(替换数据即可出全部结果与图形)

推荐大家购买最新的教程,若是已经购买以前WGNCA教程的同学,可以在对应教程留言,即可获得最新的教程。(注:此教程也仅基于自己理解,不仅局限于此,难免有不恰当地方,请结合自己需求,进行改动。)


2. 精美图形绘制教程

3. 转录组分析教程

4. 转录组下游分析

小杜的生信筆記 ,主要发表或收录生物信息学教程,以及基于R分析和可视化(包括数据分析,图形绘制等);分享感兴趣的文献和学习资料!!

小杜的生信筆記
小杜的生信筆記,生信小白,初来乍到请多指教。 主要学习分享,转录组数据分析,基于R语言数据分析和绘制图片等,以及相关文献的分享。
 最新文章