1 Install packages

BiocManager::install("clusterProfiler", version = "3.18")
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
    CRAN: https://cran.rstudio.com
Bioconductor version 3.18 (BiocManager 1.30.22), R 4.3.1 (2023-06-16)
Installing package(s) 'clusterProfiler'
also installing the dependency ‘gson’

trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-x86_64/contrib/4.3/gson_0.1.0.tgz'
Content type 'application/x-gzip' length 228958 bytes (223 KB)
==================================================
downloaded 223 KB

trying URL 'https://bioconductor.org/packages/3.18/bioc/bin/macosx/big-sur-x86_64/contrib/4.3/clusterProfiler_4.10.1.tgz'
Content type 'application/x-compressed-tar' length 1061872 bytes (1.0 MB)
==================================================
downloaded 1.0 MB

The downloaded binary packages are in
    /var/folders/2b/gcm1xy2n6s50jqf9f3ln87140000gn/T//RtmpKXHInf/downloaded_packages
Installation paths not writeable, unable to update packages
  path: /Users/christinacomo/Library/Caches/org.R-project.R/R/renv/sandbox/R-4.3/x86_64-apple-darwin20/b06620f4
  packages:
    boot, codetools, foreign, KernSmooth, lattice, nlme, survival
Old packages: 'aplot', 'backports', 'biglm', 'BiocFileCache',
  'BiocManager', 'biomaRt', 'Biostrings', 'brio', 'broom', 'BSgenome',
  'bslib', 'cachem', 'callr', 'circlize', 'cli', 'crayon',
  'data.table', 'DBI', 'dbplyr', 'digest', 'downlit', 'dqrng', 'edgeR',
  'evaluate', 'farver', 'fastmap', 'fs', 'future', 'future.apply',
  'GenomeInfoDb', 'GenomicFeatures', 'ggplot2', 'ggpmisc', 'ggpp',
  'gh', 'gplots', 'gtable', 'highr', 'Hmisc', 'htmltools', 'httr2',
  'knitr', 'lme4', 'locfit', 'markdown', 'matrixStats', 'munsell',
  'nloptr', 'openssl', 'pkgbuild', 'pkgdown', 'pkgload', 'processx',
  'promises', 'ragg', 'RcppArmadillo', 'RcppEigen', 'RcppHNSW',
  'reactR', 'renv', 'reticulate', 'rlang', 'rmarkdown', 'roxygen2',
  'RSQLite', 'rstudioapi', 'Rvcg', 'S4Arrays', 'Seurat',
  'SeuratObject', 'shape', 'shiny', 'Signac', 'sp', 'SparseArray',
  'SparseM', 'spatstat.data', 'spatstat.explore', 'spatstat.sparse',
  'spatstat.utils', 'spdep', 'stringi', 'systemfonts', 'testthat',
  'textshaping', 'tidyr', 'tinytex', 'uwot', 'xfun', 'XML', 'xopen',
  'zlibbioc'
Update all/some/none? [a/s/n]: 
n

2 Load libraries

library(enrichplot)

Registered S3 method overwritten by 'data.table':
  method           from
  print.data.table     
library(clusterProfiler)
Warning: package ‘clusterProfiler’ was built under R version 4.3.3
clusterProfiler v4.10.1  For help: https://yulab-smu.top/biomedical-knowledge-mining-book/

If you use clusterProfiler in published research, please cite:
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

Attaching package: ‘clusterProfiler’

The following object is masked from ‘package:stats’:

    filter
library(ggplot2)
Warning: package ‘ggplot2’ was built under R version 4.3.2
Need help getting started? Try the R Graphics Cookbook: https://r-graphics.org
library(org.Mm.eg.db)
Loading required package: AnnotationDbi
Warning: package ‘AnnotationDbi’ was built under R version 4.3.2
Loading required package: stats4
Loading required package: BiocGenerics

Attaching package: ‘BiocGenerics’

The following objects are masked from ‘package:stats’:

    IQR, mad, sd, var, xtabs

The following objects are masked from ‘package:base’:

    anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval,
    evalq, Filter, Find, get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget, order, paste,
    pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which.max, which.min

Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with 'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: IRanges
Loading required package: S4Vectors
Warning: package ‘S4Vectors’ was built under R version 4.3.2

Attaching package: ‘S4Vectors’

The following object is masked from ‘package:clusterProfiler’:

    rename

The following object is masked from ‘package:utils’:

    findMatches

The following objects are masked from ‘package:base’:

    expand.grid, I, unname


Attaching package: ‘IRanges’

The following object is masked from ‘package:clusterProfiler’:

    slice


Attaching package: ‘AnnotationDbi’

The following object is masked from ‘package:clusterProfiler’:

    select

3 Read in data

marks.0 <- read.csv('/Users/christinacomo/Library/CloudStorage/OneDrive-TheUniversityofColoradoDenver/10xVisium/Ethan Hughes/outputs/markers0.csv')
marks.1 <- read.csv('/Users/christinacomo/Library/CloudStorage/OneDrive-TheUniversityofColoradoDenver/10xVisium/Ethan Hughes/outputs/markers1.csv')
marks.2 <- read.csv('/Users/christinacomo/Library/CloudStorage/OneDrive-TheUniversityofColoradoDenver/10xVisium/Ethan Hughes/outputs/markers2.csv')

4 Cluster 0 GSEA processing

nrow(marks.0)
[1] 4649
head(gene_list)
4933412O06Rik          Klf4          Fosb A730071L15Rik       Gm15446           Fos 
     1.946718      1.401628      1.360267      1.304687      1.141706      1.102555 
gse.0 <- gseGO(geneList=gene_list, 
             ont ="ALL", 
             keyType = "SYMBOL",
             minGSSize = 3, 
             maxGSSize = 800, 
             nPermSimple = 5000000,
             verbose = TRUE, 
             OrgDb = org.Mm.eg.db, 
             pAdjustMethod = "none")
preparing geneSet collections...
GSEA analysis...
Warning in preparePathwaysAndStats(pathways, stats, minSize, maxSize, gseaParam,  :
  There are duplicate gene names, fgsea may produce unexpected results.
Warning in fgseaMultilevel(pathways = pathways, stats = stats, minSize = minSize,  :
  For some pathways, in reality P-values are less than 1e-10. You can set the `eps` argument to zero for better estimation.
leading edge analysis...
done...

Dot Plot

Category netplot

# categorySize can be either 'pvalue' or 'geneNum'
cnetplot(gse.0, categorySize="pvalue", foldChange=gene_list, showCategory = 3)
Warning in cnetplot.enrichResult(x, ...) :
  Use 'color.params = list(foldChange = your_value)' instead of 'foldChange'.
 The foldChange parameter will be removed in the next version.
Scale for size is already present.
Adding another scale for size, which will replace the existing scale.

Ridgeplot

ridgeplot(gse.0) + labs(x = "enrichment distribution")
Picking joint bandwidth of 0.0454

GSEA plot

PubMed trend of enriched terms

pmcplot(terms, 2010:2018, proportion=FALSE)
ℹ The package "europepmc" is required for `pmcplot()`.
✖ Would you like to install it?

1: Yes
2: No
1
Installing package into ‘/Users/christinacomo/Desktop/renv/library/R-4.3/x86_64-apple-darwin20’
(as ‘lib’ is unspecified)
also installing the dependencies ‘triebeard’, ‘urltools’

trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-x86_64/contrib/4.3/triebeard_0.4.1.tgz'
Content type 'application/x-gzip' length 1212325 bytes (1.2 MB)
==================================================
downloaded 1.2 MB

trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-x86_64/contrib/4.3/urltools_1.7.3.tgz'
Content type 'application/x-gzip' length 987031 bytes (963 KB)
==================================================
downloaded 963 KB

trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-x86_64/contrib/4.3/europepmc_0.4.3.tgz'
Content type 'application/x-gzip' length 452683 bytes (442 KB)
==================================================
downloaded 442 KB

The downloaded binary packages are in
    /var/folders/2b/gcm1xy2n6s50jqf9f3ln87140000gn/T//RtmpDo2bnT/downloaded_packages

LS0tCnRpdGxlOiAiR1NFQSBBbmFseXNpczogSW52ZXN0aWdhdGluZyBRdWllc2NlbnQgT1BDcywgQ29tbyAwNi4yNi4yNCIKYXV0aG9yOiAiQ2hyaXN0aW5hIENvbW8iCm91dHB1dDoKICBodG1sX25vdGVib29rOgogICAgdG9jOiBUUlVFCiAgICB0b2NfZGVwdGg6IDMKICAgIHRvY19mbG9hdDogVFJVRQogICAgdGhlbWU6IHVuaXRlZAogICAgaGlnaGxpZ2h0OiB0YW5nbwplZGl0b3Jfb3B0aW9uczogCiAgY2h1bmtfb3V0cHV0X3R5cGU6IGlubGluZQotLS0KIyAx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