Contents

1 Introduction

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 KEGG pathway diagrams.

2 Installation

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 org.Hs.eg.db package in this vignette.

library(PinPath)
library(org.Hs.eg.db)

3 Dataset

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")

4 Set colors

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)

5 Plot pathway

We can now plot the differential expression statistics on the hsa05207: Chemical carcinogenesis - receptor activation 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.

# Select pathway
pathway_id <- "hsa05207"
infile <- BiocFileCache::bfcrpath(
    BiocFileCache::BiocFileCache(),
    paste0("https://rest.kegg.jp/get/",pathway_id,"/kgml"))

# Plot pathway
pathVis <- PinPath::drawKGML(
    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:

6 Plot network

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::KGML2Network(
    infile = infile,
    annGenes = "org.Hs.eg.db",
    inputDB = "ENSEMBL",
    featureIDs = lung_expr$GeneID,
    colorVar = lung_expr[,c("log2FC", "Significant")],
    colorList = colorList,
    nodeTable = TRUE,
    legend = FALSE,
    openFile = FALSE) # <-- set to TRUE to open the image automatically

Network image:

Legend image:

7 Session info

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] viridis_0.6.5        filelock_1.0.3       Biostrings_2.79.5   
## [10] S7_0.2.2             ggraph_2.2.2         fastmap_1.2.0       
## [13] BiocFileCache_3.1.0  tweenr_2.0.3         XML_3.99-0.23       
## [16] digest_0.6.39        lifecycle_1.0.5      KEGGREST_1.51.1     
## [19] RSQLite_2.4.6        magrittr_2.0.5       compiler_4.6.0      
## [22] rlang_1.2.0          sass_0.4.10          tools_4.6.0         
## [25] igraph_2.3.0         yaml_2.3.12          knitr_1.51          
## [28] labeling_0.4.3       graphlayouts_1.2.3   bit_4.6.0           
## [31] curl_7.1.0           RColorBrewer_1.1-3   withr_3.0.2         
## [34] purrr_1.2.2          BiocGenerics_0.57.1  grid_4.6.0          
## [37] polyclip_1.10-7      stats4_4.6.0         ggplot2_4.0.3       
## [40] scales_1.4.0         MASS_7.3-65          dichromat_2.0-0.1   
## [43] cli_3.6.6            rmarkdown_2.31       crayon_1.5.3        
## [46] generics_0.1.4       otel_0.2.0           PinPath_0.99.3      
## [49] httr_1.4.8           DBI_1.3.0            cachem_1.1.0        
## [52] ggforce_0.5.0        stringr_1.6.0        AnnotationDbi_1.73.1
## [55] BiocManager_1.30.27  XVector_0.51.0       vctrs_0.7.3         
## [58] jsonlite_2.0.0       bookdown_0.46        IRanges_2.45.0      
## [61] S4Vectors_0.49.2     bit64_4.8.0          ggrepel_0.9.8       
## [64] systemfonts_1.3.2    magick_2.9.1         jquerylib_0.1.4     
## [67] tidyr_1.3.2          glue_1.8.1           stringi_1.8.7       
## [70] gtable_0.3.6         tibble_3.3.1         pillar_1.11.1       
## [73] rappdirs_0.3.4       htmltools_0.5.9      Seqinfo_1.1.0       
## [76] R6_2.6.1             dbplyr_2.5.2         httr2_1.2.2         
## [79] textshaping_1.0.5    tidygraph_1.3.1      evaluate_1.0.5      
## [82] Biobase_2.71.0       png_0.1-9            memoise_2.0.1       
## [85] bslib_0.10.0         Rcpp_1.1.1-1         gridExtra_2.3       
## [88] svglite_2.2.2        org.Hs.eg.db_3.23.1  xfun_0.57           
## [91] pkgconfig_2.0.3