1. Overview

This vignette is the fifth chapter in the “Pathway Significance Testing with pathwayPCA” workflow, providing a detailed perspective to the Inspect Results section of the Quickstart Guide. This vignette will discuss graphing the pathway-specific \(p\)-values, FDR values, and associated log-scores. Also, we will discuss how to plot the gene- or protein-specific loadings within a certain pathway and further how to plot the correlation between a gene or protein within a pathway and the principal component representing that pathway.

Before we move on, we will outline our steps. After reading this vignette, you should be able to

  1. Plot the log-score rank of the top pathways.
  2. Plot the feature loadings for a single pathway.
  3. Plot the correlations between a pathway principal component and the features within that pathway.

1.1 Packages

First, load the pathwayPCA package and the tidyverse package suite.


1.2 Example Results

First, we will replicate the data setup from the previous vignette chapters on importing data and creating data objects ( Chapter 2: Import and Tidy Data and Chapter 3: Creating -Omics Data Objects, respectively). See these chapters for detailed explination of the code below.

We will resume inspection of the analysis results from the chapter 4 vignette for the AESPCA method.

2. Plot Pathway Significance Levels

The first element of this results data object is a data frame of pathways and their significance levels (pVals_df).

Given the \(p\)-values from these pathways, we will now graph their score (negative log of the \(p\)-value) and description for the top 15 most-significant pathways.

2.2 Tidy the Pathway Results

For the data frame containing the survival data pathway \(p\)-values, we will transform the data for better graphics. This code takes in the pathway \(p\)-values data frame from the AESPCA method output and gathers it into a “tidy” data frame (compatible with ggplot). We also add on a column for the negative natural logarithm of the pathway \(p\)-values (called score) and recode the label of the \(p\)-value adjustment method.

2.3 Plot Significant Survival Pathways for One Adjustment

Now we will plot the pathway \(p\)-values for the most significant pathways as a horizontal bar chart. For more information on how to modify ggplot graphs, or to learn how to create your own, please see Chang’s R Graphics Cookbook or Wickham’s ggplot2: Elegant Graphics for Data Analysis.

First, we select the rows of the \(p\)-values data frame which correspond to the adjustment method we are interested in. We will select the Benjamini and Hochberg FDR-adjustment method.

Now we plot the pathway significance level for the pathways based on this FDR-adjustment method.

2.4 Plot Significant Survival Pathways for All Adjustments

If we were interested in comparing adjustment methods, we can. This figure shows that a few of the simulated pathways are significant at the \(\alpha = 0.01\) for either the Benjamini and Hochberg or Bonferroni FWER approaches. The vertical black line is at \(-\log(p = 0.01)\). This figure is slightly different from the figures shown in the Graph Top Pathways subsection of the Quickstart Guide.

3. Inspecting the Driving Genes

Now that we have a few significant pathways, we can look at the loadings of each gene onto the first AES-PC from these pathways.

3.1 Extract Pathway Decomposition

We will chose the top two significant pathways for closer inspection, and we want to ascertain which genes load onto the pathway PCs. Notice that the pathway loadings are named by the internal pathway key, so we need to use the getPathPCL() to match this key to its pathway and extract the pathway PCs and loadings (PC & L) list from the colonSurv_aespcOut object. Here are the loading vectors and pathway details from PID_EPHB_FWD_PATHWAY:

This tells us that pathway491 represents the EPHB forward signaling pathway.

We can also extract the PCs and loadings vectors for KEGG_ASTHMA (the Asthma pathway), which we will compare later.

pathway177_ls <- getPathPCLs(colonSurv_aespcOut, "KEGG_ASTHMA")

3.2 Gene Loadings

3.2.1 Wrangle Pathway Loadings

Given the loading vectors from the EPHB forward signaling pathway, we need to wrangle them into a data frame that the ggplot() function can use. For this, we’ve written a function that you can modify as you need. This function takes in the pathway PC & L list returned by the getPathPCLs() function and returns a data frame with all the components necessary for a plot of the gene loadings. For more aesthetically-pleasing plots, we set the default for one PC or loading vector per figure.

We can use this function to “tidy up” the loadings from the EPHB forward signaling pathway:

3.2.2 Plot the Gene Loadings

We also wrote a function to create a ggplot graph object which uses this tidy data frame.

This is the resulting loading bar plot for the EPHB forward signaling pathway (because all of the loadings are between -1 and 1, we set the significant figures to 2):

For comparison, this is the bar plot for the asthma pathway (pathway177 in our -Omics data container):

3.3 Gene Correlations with PCs

3.3.1 Calculate Pathway Correlations

Additionally, we can calculate the correlation between gene expression in the assay corresponding to the EPHB forward signaling pathway and the PC vectors extracted from this pathway. Thus, we need to extract the recorded gene levels corresponding to the non-zero loadings for the PCs, calculate the Spearman correlations between these values and their extracted PCs, then wrangle these correlations into a data frame that the ggplot() function can use. We have written an additional function that you can modify as you need. This function takes in the Omics data container (that you created in Chapter 3) and the PC & L list returned by getPathPCLs(). This function returns a data frame with all the components necessary for a plot of the assay-PC correlations.

We can use this function to “tidy up” the loadings from the EPHB forward signaling pathway:

4. Plot patient-specific pathway activities

estimate pathway activities for each patient, both for protein expressions and copy number expressions separately

This is the circle plot for the IL-1 signaling pathway:

Blue stands for negative PC1 score, Red stands for positive PC1 score. The inner loop stands for copy numbers, outer loop stands for protein expression.

5. Review

We have has covered in this vignette:

  1. Plotting the log-score rank of the top pathways.
  2. Plotting the feature loadings for a single pathway.
  3. Plotting the correlations between a pathway principal component and the features within that pathway.

We are exploring options to connect this package to other pathway-testing software. We are further considering other summary functions and/or graphics to help display the output of our *_pVals() functions. If you have any questions, comments, complaints, or suggestions, please submit an issue ticket and give us some feedback. Also you can visit our development page.

Here is the R session information for this vignette:

#> R version 3.6.2 (2019-12-12)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 7 x64 (build 7601) Service Pack 1
#> Matrix products: default
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> other attached packages:
#>  [1] circlize_0.4.8   pathwayPCA_1.1.4 forcats_0.4.0    stringr_1.4.0   
#>  [5] dplyr_0.8.3      purrr_0.3.3      readr_1.3.1      tidyr_1.0.0     
#>  [9] tibble_2.1.3     ggplot2_3.2.1    tidyverse_1.3.0 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.3          lubridate_1.7.4     lattice_0.20-38    
#>  [4] assertthat_0.2.1    zeallot_0.1.0       rprojroot_1.3-2    
#>  [7] digest_0.6.23       utf8_1.1.4          plyr_1.8.5         
#> [10] R6_2.4.1            cellranger_1.1.0    backports_1.1.5    
#> [13] lars_1.2            reprex_0.3.0        evaluate_0.14      
#> [16] httr_1.4.1          pillar_1.4.3        GlobalOptions_0.1.1
#> [19] rlang_0.4.2         lazyeval_0.2.2      readxl_1.3.1       
#> [22] rstudioapi_0.10     Matrix_1.2-18       rmarkdown_2.0      
#> [25] pkgdown_1.4.1       labeling_0.3        desc_1.2.0         
#> [28] splines_3.6.2       munsell_0.5.0       broom_0.5.3        
#> [31] compiler_3.6.2      modelr_0.1.5        xfun_0.11          
#> [34] pkgconfig_2.0.3     shape_1.4.4         htmltools_0.4.0    
#> [37] tidyselect_0.2.5    fansi_0.4.0         crayon_1.3.4       
#> [40] dbplyr_1.4.2        withr_2.1.2         MASS_7.3-51.5      
#> [43] grid_3.6.2          nlme_3.1-143        jsonlite_1.6       
#> [46] gtable_0.3.0        lifecycle_0.1.0     DBI_1.1.0          
#> [49] magrittr_1.5        scales_1.1.0        cli_2.0.0          
#> [52] stringi_1.4.3       reshape2_1.4.3      farver_2.0.1       
#> [55] fs_1.3.1            xml2_1.2.2          ellipsis_0.3.0     
#> [58] generics_0.0.2      vctrs_0.2.1         tools_3.6.2        
#> [61] glue_1.3.1          hms_0.5.2           parallel_3.6.2     
#> [64] survival_3.1-8      yaml_2.2.0          colorspace_1.4-1   
#> [67] rvest_0.3.5         memoise_1.1.0       knitr_1.26         
#> [70] haven_2.2.0