PinPath 0.99.3
PinPath allows you to visualize your data onto pathways diagrams, and pinpoint where the relevant changes occur. Results from (epi)genomics, transcriptomics, (phospho)proteomics, metabolomics and many more experiments can be visualized onto pathway diagrams from WikiPathways and KEGG. You can also visualize your own custom GPML and KGML files. As long as your data can be linked to genes, proteins, or metabolites, you can visualize it using PinPath.
This vignette will cover visualizing differential expression analysis results
onto WikiPathways pathway diagrams.
First, make sure you install and load all necessary packages.
if (!requireNamespace("BiocManager", quietly=TRUE))
install.packages("BiocManager")
BiocManager::install("PinPath")
Besides PinPath, we will also use the rWikipathways and org.Hs.eg.db packages in this vignette.
library(PinPath)
library(rWikiPathways)
library(org.Hs.eg.db)
The example dataset we will use compares the expression of transcripts in lung cancer biopsies versus normal tissue. Differential expression analysis has already been performed, generating log2FCs and p-values for each gene.
lung_expr <- read.csv(
system.file("extdata","data-lung-cancer.csv", package ="PinPath"),
stringsAsFactors = FALSE)
In the pathway, we want to show which gene is significantly differentially expressed. For this, we will use an adjusted p-value cutoff of 0.05.
lung_expr$Significant <- ifelse(lung_expr$adj.P.Value < 0.05, "Yes", "No")
After we have loaded and prepared the differential expression analysis statistics, we need to define how to color the statistics in the pathway diagram. In this vignette, we will plot the log2FC and significance of each gene on the pathway diagram. We can start by loading the default color palette.
colorList <- PinPath::defaultColorList(lung_expr[,c("log2FC", "Significant")])
In the next step, we can adjust the default color palette to the desired color values. For instance, we want to display a green color when a gene is differentially expressed and a white color when it is not.
colorList[["Significant"]]$Color <- c(
"Yes" = "green",
"No" = "white")
Furthermore, we can set the minimum and maximum value of the log2FC color gradient to -1.5 and 1.5, respectively. Note that values exceeding these bounds are clipped and mapped to the colors representing the respective minimum or maximum.
colorList[["log2FC"]]$ColorVal <- c(
"MinVal" = -1.5,
"MidVal" = 0,
"MaxVal" = 1.5)
We can now plot the differential expression statistics on the WP5087: Pleural mesothelioma pathway. If not specified otherwise, the pathway and legend image will be saved in your working directory. The pathway image will be opened by default.
# WP5087: Pleural mesothelioma
pathway_id <- "WP5087"
infile <- rWikiPathways::getPathway(pathway_id)
# Draw pathway
pathVis <- PinPath::drawGPML(
infile = infile,
annGenes = "org.Hs.eg.db",
inputDB = "ENSEMBL",
featureIDs = lung_expr$GeneID,
colorVar = lung_expr[,c("log2FC", "Significant")],
colorList = colorList,
nodeTable = TRUE,
legend = TRUE,
openFile = FALSE) # <-- set to TRUE to open the image automatically
Pathway image:
Legend image:
You can also plot the pathway as a network. In contrast to the pathway diagram, every element (e.g., gene/protein) is represented exactly once in the network.
pathVis <- PinPath::GPML2Network(
infile = infile,
annGenes = "org.Hs.eg.db",
inputDB = "ENSEMBL",
featureIDs = lung_expr$GeneID,
colorVar = lung_expr[,c("log2FC", "Significant")],
colorList = colorList,
nodeSize = 0.5,
nodeTable = TRUE,
legend = FALSE,
openFile = FALSE) # <-- set to TRUE to open the image automatically
Network image:
Legend image:
sessionInfo()
## R version 4.6.0 RC (2026-04-17 r89917)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.4 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.23-bioc/R/lib/libRblas.so
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0 LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: America/New_York
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] BiocStyle_2.39.0
##
## loaded via a namespace (and not attached):
## [1] tidyselect_1.2.1 viridisLite_0.4.3 gridBase_0.4-7
## [4] dplyr_1.2.1 farver_2.1.2 blob_1.3.0
## [7] bitops_1.0-9 viridis_0.6.5 filelock_1.0.3
## [10] Biostrings_2.79.5 S7_0.2.2 RCurl_1.98-1.18
## [13] ggraph_2.2.2 fastmap_1.2.0 BiocFileCache_3.1.0
## [16] tweenr_2.0.3 rWikiPathways_1.31.0 XML_3.99-0.23
## [19] digest_0.6.39 lifecycle_1.0.5 KEGGREST_1.51.1
## [22] RSQLite_2.4.6 magrittr_2.0.5 compiler_4.6.0
## [25] rlang_1.2.0 sass_0.4.10 tools_4.6.0
## [28] igraph_2.3.0 yaml_2.3.12 data.table_1.18.2.1
## [31] knitr_1.51 labeling_0.4.3 graphlayouts_1.2.3
## [34] bit_4.6.0 curl_7.1.0 xml2_1.5.2
## [37] RColorBrewer_1.1-3 withr_3.0.2 purrr_1.2.2
## [40] BiocGenerics_0.57.1 grid_4.6.0 polyclip_1.10-7
## [43] stats4_4.6.0 ggplot2_4.0.3 scales_1.4.0
## [46] MASS_7.3-65 dichromat_2.0-0.1 cli_3.6.6
## [49] rmarkdown_2.31 crayon_1.5.3 generics_0.1.4
## [52] otel_0.2.0 PinPath_0.99.3 rjson_0.2.23
## [55] httr_1.4.8 DBI_1.3.0 cachem_1.1.0
## [58] ggforce_0.5.0 stringr_1.6.0 AnnotationDbi_1.73.1
## [61] BiocManager_1.30.27 XVector_0.51.0 vctrs_0.7.3
## [64] jsonlite_2.0.0 bookdown_0.46 IRanges_2.45.0
## [67] S4Vectors_0.49.2 bit64_4.8.0 ggrepel_0.9.8
## [70] systemfonts_1.3.2 magick_2.9.1 jquerylib_0.1.4
## [73] tidyr_1.3.2 glue_1.8.1 shape_1.4.6.1
## [76] stringi_1.8.7 gtable_0.3.6 tibble_3.3.1
## [79] pillar_1.11.1 rappdirs_0.3.4 htmltools_0.5.9
## [82] Seqinfo_1.1.0 R6_2.6.1 dbplyr_2.5.2
## [85] httr2_1.2.2 textshaping_1.0.5 tidygraph_1.3.1
## [88] evaluate_1.0.5 Biobase_2.71.0 png_0.1-9
## [91] memoise_2.0.1 bslib_0.10.0 Rcpp_1.1.1-1
## [94] gridExtra_2.3 svglite_2.2.2 org.Hs.eg.db_3.23.1
## [97] xfun_0.57 pkgconfig_2.0.3