KEGGlincs Workflows

Shana White


Overview of KEGGlincs

The package KEGGlincs and the functions contained within it are designed such that users can explore KEGG pathways in a more meaningful and informative manner both visually and analytically. This method of pathway analysis is approached via functions that handle the following (related) objectives:

The idea of ‘expanded’ nodes and edges should become very clear after reviewing the following example KEGGlincs workflows. Please keep in mind, the individual functions detailed in the following workflows are incorporated into the KEGG_lincs ‘master function’; these workflows are designed to provide users a with a better understanding of how this function works, how pathway topology is represented in KGML files, and how this package could be used with non-LINCS edge data (see Workflow 2).

Workflow 1: Visualize detailed ‘expanded’ KEGG pathways

No data added to edges

This workflow is intended to give users insight into the ‘expansion’ of KEGG pathway mapping via manipulation of the source KGML file. The only input required is the KEGG pathway ID for your pathway of choice. The primary goal for this method of pathway re-generation is to give users insight into the complexity that underlies many KEGG pathways but is in a sense ‘hidden’, yet hard-coded, in the curated KGML files. Users can also see the exact pathway topology that is used for input in analyses such as SPIA (Signaling Pathway Impact Analysis).

Initialize KEGGlincs package (development phase)


Download and parse the most current KGML file for Fox0 signaling pathway

FoxO_KGML <- get_KGML("hsa04068")

#Information from KGML can be accessed using the following syntax:
slot(FoxO_KGML, "pathwayInfo")
## [ Title ]: FoxO signaling pathway
## [ Name ]: path:hsa04068
## [ Organism ]: hsa
## [ Number ] :04068
## [ Image ] :
## [ Link ] :

The code chunks below are useful for viewing the original pathway image.

#Get address for pathway with active links:
slot(slot(FoxO_KGML, "pathwayInfo"), "image")
## [1] ""
#Download a static pathway image (png file) to working directory:
image_link <- slot(slot(FoxO_KGML, "pathwayInfo"), "image")
download.file(image_link, basename(image_link), mode = "wb")
Rendering of the png file for the p53 signaling pathway from KEGG:

The following commands produce ‘expanded’ node and edge sets

Note that KEGG IDs are converted to gene/compound symbols; this conversion accounts for the majority of computing time behind the expand_KEGG_mappings function. For quicker map generation, users may chose to change the argument convert_KEGG_IDs to FALSE; this will result in edges being identified by pairs of accession numbers instead of symbols in the final pathway map (example at end of this workflow using KEGG_lincs master function).

FoxO_KEGG_mappings <- expand_KEGG_mappings(FoxO_KGML)
FoxO_edges <- expand_KEGG_edges(FoxO_KGML, FoxO_KEGG_mappings)
Compare counts for ‘expanded’ vs. ‘unexpanded’ nodes and edges:
length(graph::nodes(FoxO_KGML)) # 'Un-expanded' nodes
## [1] 98
nrow(FoxO_KEGG_mappings)        # 'Expanded' nodes
## [1] 168

length(graph::edges(FoxO_KGML)) # 'Un-expanded' edges
## [1] 77
nrow(FoxO_edges)                # 'Expanded' edges
## [1] 472
Add graphing information to nodes and edges and get graph object:

Note: While the node_mapping_info function is rather trivial, the edge_mapping_info functions differently when data is added.

#Modify existing data sets; specify as nodes and edges
FoxO_node_mapping_info <- node_mapping_info(FoxO_KEGG_mappings)
FoxO_edge_mapping_info <- edge_mapping_info(FoxO_edges)

#Create an igraph object
GO <- get_graph_object(FoxO_node_mapping_info, FoxO_edge_mapping_info)
## [1] "igraph"
Finally, transform graph object and send to Cytoscape with one command:
cyto_vis(GO, "FoxO Pathway with Expanded Edges[no data added]")
Graph rendered in Cytoscape:

Edge Color Key:

Red: Activation or Expression *

Orange: Activating PTM **

Green: PTM (no activation/inhibition activity defined)

Blue: Inhibition

Purple: Inhibiting PTM

Black(solid): Binding/Association

Black(dashed): Indirect effect (no activation/inhibition activity defined)

*Any dashed colored line indicates that the effect is indirect

**PTM = post-translational modification or, as KEGG defines them, ‘molecular events’.

  • The specific types of PTMS (indicated by edge label) include:
    • +p: phosphorylation
    • -p: dephosphorylation
    • +g: glycosylation
    • +u: ubiquitination
    • +m: methylation

Notice that the original KEGG pathway image includes visual elements such as cellular-component-demarcations and certain edges (especially those ‘connecting’ genes to other pathways) that are not rendered in Cytoscape. These are features that are either not explicitly part of the pathway topology (i.e. not nodes or edges connecting nodes) or have not been hard-coded in the KGML file. The node labels may also differ between maps (KEGGlincs labels nodes as the first ‘alias’ in the respective KGML slot as there is no corresponding ‘label’ slot).

*Note: to have the pathway maps automatically formatted for convenient viewing and proper node size, please use the function cyto_vis_auto: This function requires systems to have the R package RCy3 installed, which is not yet available for all systems.

Otherwise please follow the steps under CytoscapeSettings.Rmd to reproduce the maps generated in this vignette.

Alternative: KEGG_lincs master function

The steps above may be avoided if the user does not wish to generate intermediary files/objects by making use of the function KEGG_lincs as follows:


If users would like the Cytoscape-rendered map along with the detailed list of expanded edges (as an R object), KEGG_lincs can be invoked as follows:

FoxO_edges <- KEGG_lincs("hsa04068")

To speed up the mapping process (at the expense of having edges labelled with pairs of gene accession numbers as opposed to symbols) users may change the default convert_KEGG_IDs argumet to FALSE

KEGG_lincs("hsa04068", convert_KEGG_IDs = FALSE)

*Note: As with cyto_vis, please use the function KEGG_lincs_auto (after sourcing cyto_vis_auto) available from : #####Graph rendered in Cytoscape without edge accession numbers converted: