## ----setup, echo=FALSE, results="hide"----------------------------------------
knitr::opts_chunk$set(
    tidy = FALSE,
    cache = FALSE,
    dev = "png",
    message = FALSE, error = FALSE, warning = TRUE)

## ----install-pinpath, message = FALSE, warning = FALSE, eval=FALSE------------
# if (!requireNamespace("BiocManager", quietly=TRUE))
#     install.packages("BiocManager")
# 
# BiocManager::install("PinPath")

## ----install-others, message = FALSE, warning = FALSE, eval=FALSE-------------
# library(PinPath)
# library(rWikiPathways)
# library(org.Hs.eg.db)

## ----dataset, message = FALSE, warning = FALSE--------------------------------
lung_expr <- read.csv(
    system.file("extdata","data-lung-cancer.csv", package ="PinPath"), 
    stringsAsFactors = FALSE)

## ----significance, results = 'asis'-------------------------------------------
lung_expr$Significant <- ifelse(lung_expr$adj.P.Value < 0.05, "Yes", "No")

## ----default-color-values-----------------------------------------------------
colorList <- PinPath::defaultColorList(lung_expr[,c("log2FC", "Significant")])

## ----modify-significant-color-------------------------------------------------
colorList[["Significant"]]$Color <- c(
    "Yes" = "green",
    "No" = "white")

## ----modify-log2FC-color------------------------------------------------------
colorList[["log2FC"]]$ColorVal <- c(
    "MinVal" = -1.5,
    "MidVal" = 0,
    "MaxVal" = 1.5)

## ----plot-pathway, message = FALSE, warning = FALSE---------------------------
# 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

## ----plot-network, message = FALSE, warning = FALSE---------------------------
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

## ----sessionInfo--------------------------------------------------------------
sessionInfo()

