Running fedup with two test sets

Catherine Ross

This is an R package that tests for enrichment and depletion of user-defined pathways using a Fisher’s exact test. The method is designed for versatile pathway annotation formats (eg. gmt, txt, xlsx) to allow the user to run pathway analysis on custom annotations. This package is also integrated with Cytoscape to provide network-based pathway visualization that enhances the interpretability of the results.

This vignette will explain how to use fedup when testing two sets of genes for pathway enrichment and depletion.

System prerequisites

R version ≥ 4.1
R packages:

Installation

Install fedup from Bioconductor:

if(!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("fedup")

Or install the development version from Github:

devtools::install_github("rosscm/fedup", quiet = TRUE)

Load necessary packages:

library(fedup)
library(dplyr)
library(tidyr)
library(ggplot2)

Running the package

Input data

Load test genes (geneDouble) and pathways annotations (pathwaysGMT):

Take a look at the data structure:

To see more info on this data, run ?geneDouble or ?pathwaysGMT. You could also run example("prepInput", package = "fedup") or example("readPathways", package = "fedup") to see exactly how the data was generated using the prepInput() and readPathways() functions. ? and example() can be used on any other functions mentioned here to see their documentation and run examples.

The sample geneDouble list object contains three vector elements: background , FASN_negative, and FASN_positive. The background consists of all genes that the test sets (in this case FASN_negative and FASN_positive) will be compared against. FASN_negative consists of genes that form negative genetic interactions with the FASN gene after CRISPR-Cas9 knockout. FASN_positive consists of genes that form positve genetic interactions with FASN. If you’re interested in seeing how this data set was constructed, check out the code. Also, the paper the data was taken from is found here.

Given that FASN is a fatty acid synthase, we would expect to see enrichment of the negative interactions for pathways associated with sensitization of fatty acid synthesis, as well as enrichment of the positive interactions for pathways associated with suppression of the function. Conversely, we expect to find depletion for pathways not at all involved with FASN biology. Let’s see!

Pathway analysis

Now use runFedup on the sample data:

The fedupRes output is a list of length length(which(names(geneDouble) != "background")), corresponding to the number of test sets in geneDouble (i.e., 2).

View fedup results for FASN_negative sorted by pvalue:

set <- "FASN_negative"
print(head(fedupRes[[set]][which(fedupRes[[set]]$status == "enriched"),]))
#>                                                                                                                                          pathway
#> 1:                                                                      ASPARAGINE N-LINKED GLYCOSYLATION%REACTOME DATABASE ID RELEASE 74%446203
#> 2: BIOSYNTHESIS OF THE N-GLYCAN PRECURSOR (DOLICHOL LIPID-LINKED OLIGOSACCHARIDE, LLO) AND TRANSFER TO A NASCENT PROTEIN%REACTOME%R-HSA-446193.1
#> 3:                                                  DISEASES ASSOCIATED WITH N-GLYCOSYLATION OF PROTEINS%REACTOME DATABASE ID RELEASE 74%3781860
#> 4:                                                        INTRA-GOLGI AND RETROGRADE GOLGI-TO-ER TRAFFIC%REACTOME DATABASE ID RELEASE 74%6811442
#> 5:                                                                         RAB REGULATION OF TRAFFICKING%REACTOME DATABASE ID RELEASE 74%9007101
#> 6:                                                                                            DISEASES OF GLYCOSYLATION%REACTOME%R-HSA-3781865.1
#>    size real_frac expected_frac fold_enrichment   status
#> 1:  286  8.179420    1.53336329        5.334300 enriched
#> 2:   78  3.693931    0.42125365        8.768901 enriched
#> 3:   17  2.110818    0.09548416       22.106472 enriched
#> 4:  183  4.749340    0.99415862        4.777246 enriched
#> 5:  120  3.693931    0.62345540        5.924933 enriched
#> 6:  139  3.957784    0.74702314        5.298074 enriched
#>                                     real_gene       pvalue       qvalue
#> 1:      MOGS,DOLPP1,ALG9,ALG12,ALG3,MPDU1,... 1.596605e-12 2.294321e-09
#> 2:      DOLPP1,ALG9,ALG12,ALG3,MPDU1,ALG8,... 6.358461e-09 4.568554e-06
#> 3:       MOGS,ALG9,ALG12,ALG3,MPDU1,MGAT2,... 3.054616e-08 1.463161e-05
#> 4:  ARL1,RAB18,RAB3GAP2,VPS52,NAA35,TMED9,... 2.516179e-07 9.039372e-05
#> 5: RAB18,TSC1,RAB3GAP2,TSC2,TBC1D20,RAB10,... 4.945154e-07 1.421237e-04
#> 6:       MOGS,ALG9,ALG12,ALG3,MPDU1,MGAT2,... 7.240716e-07 1.734151e-04
print(head(fedupRes[[set]][which(fedupRes[[set]]$status == "depleted"),]))
#>                                                               pathway size
#> 1:                        GPCR LIGAND BINDING%REACTOME%R-HSA-500792.3  454
#> 2: OLFACTORY SIGNALING PATHWAY%REACTOME DATABASE ID RELEASE 74%381753  396
#> 3:       CLASS A 1 (RHODOPSIN-LIKE RECEPTORS)%REACTOME%R-HSA-373076.7  323
#> 4:             NEURONAL SYSTEM%REACTOME DATABASE ID RELEASE 74%112316  379
#> 5:           PEPTIDE LIGAND-BINDING RECEPTORS%REACTOME%R-HSA-375276.5  195
#> 6:             KERATINIZATION%REACTOME DATABASE ID RELEASE 74%6805567  217
#>    real_frac expected_frac fold_enrichment   status    real_gene      pvalue
#> 1: 0.0000000     2.3702539       0.0000000 depleted              0.000318537
#> 2: 0.0000000     1.9096832       0.0000000 depleted              0.001508862
#> 3: 0.0000000     1.6906313       0.0000000 depleted              0.003316944
#> 4: 0.5277045     2.0950348       0.2518834 depleted KCNK2,PRKAB1 0.026904721
#> 5: 0.0000000     1.0166255       0.0000000 depleted              0.057057149
#> 6: 0.0000000     0.8425073       0.0000000 depleted              0.079543380
#>        qvalue
#> 1: 0.01760530
#> 2: 0.05420587
#> 3: 0.10361845
#> 4: 0.42024004
#> 5: 0.57670567
#> 6: 0.67813171

Here we see the strongest enrichment for the ASPARAGINE N-LINKED GLYCOSYLATION pathway. Given that FASN mutant cells show a strong dependence on lipid uptake, this enrichment for negative interactions with genes involved in glycosylation is expected. We also see significant enrichment for other related pathways, including DISEASES ASSOCIATED WITH N-GLYCOSYLATION OF PROTEINS and DISEASES OF GLYCOSYLATION. Conversely, we see significant depletion for functions not associated with these processes, such as OLFACTORY SIGNALING PATHWAY, GPCR LIGAND BINDING and KERATINIZATION. Nice!

Let’s also view fedup results for FASN_positive, sorted by pvalue:

set <- "FASN_positive"
print(head(fedupRes[[set]][which(fedupRes[[set]]$status == "enriched"),]))
#>                                                                                          pathway
#> 1:     L13A-MEDIATED TRANSLATIONAL SILENCING OF CERULOPLASMIN EXPRESSION%REACTOME%R-HSA-156827.3
#> 2: GTP HYDROLYSIS AND JOINING OF THE 60S RIBOSOMAL SUBUNIT%REACTOME DATABASE ID RELEASE 74%72706
#> 3:                    CAP-DEPENDENT TRANSLATION INITIATION%REACTOME DATABASE ID RELEASE 74%72737
#> 4:                                      EUKARYOTIC TRANSLATION INITIATION%REACTOME%R-HSA-72613.3
#> 5:                               TRANSLATION INITIATION COMPLEX FORMATION%REACTOME%R-HSA-72649.3
#> 6:          RIBOSOMAL SCANNING AND START CODON RECOGNITION%REACTOME DATABASE ID RELEASE 74%72702
#>    size real_frac expected_frac fold_enrichment   status
#> 1:  112  7.382550     0.4718041        15.64749 enriched
#> 2:  113  7.382550     0.4774208        15.46340 enriched
#> 3:  120  7.382550     0.5167378        14.28684 enriched
#> 4:  120  7.382550     0.5167378        14.28684 enriched
#> 5:   59  5.369128     0.2583689        20.78086 enriched
#> 6:   59  5.369128     0.2583689        20.78086 enriched
#>                                 real_gene       pvalue       qvalue
#> 1: EIF3A,RPL35,EIF3D,RPS3,EIF3G,EIF4H,... 9.628857e-18 8.562503e-15
#> 2: EIF3A,RPL35,EIF3D,RPS3,EIF3G,EIF4H,... 1.191719e-17 8.562503e-15
#> 3: EIF3A,RPL35,EIF3D,RPS3,EIF3G,EIF4H,... 4.970934e-17 1.785808e-14
#> 4: EIF3A,RPL35,EIF3D,RPS3,EIF3G,EIF4H,... 4.970934e-17 1.785808e-14
#> 5:  EIF3A,EIF3D,RPS3,EIF3G,EIF4H,RPS5,... 5.796507e-15 1.388264e-12
#> 6:  EIF3A,EIF3D,RPS3,EIF3G,EIF4H,RPS5,... 5.796507e-15 1.388264e-12
print(head(fedupRes[[set]][which(fedupRes[[set]]$status == "depleted"),]))
#>                                                                         pathway
#> 1:                                  GPCR LIGAND BINDING%REACTOME%R-HSA-500792.3
#> 2:                       NEURONAL SYSTEM%REACTOME DATABASE ID RELEASE 74%112316
#> 3:           OLFACTORY SIGNALING PATHWAY%REACTOME DATABASE ID RELEASE 74%381753
#> 4:                 CLASS A 1 (RHODOPSIN-LIKE RECEPTORS)%REACTOME%R-HSA-373076.7
#> 5:                        G ALPHA (I) SIGNALLING EVENTS%REACTOME%R-HSA-418594.6
#> 6: TRANSMISSION ACROSS CHEMICAL SYNAPSES%REACTOME DATABASE ID RELEASE 74%112315
#>    size real_frac expected_frac fold_enrichment   status real_gene      pvalue
#> 1:  454 0.0000000      2.370254       0.0000000 depleted           0.002390509
#> 2:  379 0.0000000      2.095035       0.0000000 depleted           0.005261657
#> 3:  396 0.0000000      1.909683       0.0000000 depleted           0.007449873
#> 4:  323 0.0000000      1.690631       0.0000000 depleted           0.017309826
#> 5:  396 0.3355705      2.106268       0.1593199 depleted    AHCYL1 0.034808044
#> 6:  238 0.0000000      1.314311       0.0000000 depleted           0.035700272
#>        qvalue
#> 1: 0.03240718
#> 2: 0.05953545
#> 3: 0.07989155
#> 4: 0.13667154
#> 5: 0.21016453
#> 6: 0.21198880

Dot plot

Prepare data for plotting via dplyr and tidyr:

Since we’re dealing with two test sets here, it’s important we create the sign column in fedupPlot to distinguish between them. Take a look at ?dplyr::bind_rows for details on how the output fedup results list (fedupRes) was bound into a single dataframe and ?tidyr::separate for how the sign column was created.

Plot significant results (qvalue < 0.05) in the form of a dot plot via plotDotPlot. Colour and facet the points by the sign column:

Look at all those chick… enrichments! This is a bit overwhelming, isn’t it? How do we interpret these 156 fairly redundant pathways in a way that doesn’t hurt our tired brains even more? Oh I know, let’s use an enrichment map!

Enrichment map

First, make sure to have Cytoscape downloaded and and open on your computer. You’ll also need to install the EnrichmentMap (≥ v3.3.0) and AutoAnnotate apps.

Then format results for compatibility with EnrichmentMap using writeFemap:

Prepare a pathway annotation file (gmt format) from the pathway list you passed to runFedup using the writePathways function (you don’t need to run this function if your pathway annotations are already in gmt format, but it doesn’t hurt to make sure):

Cytoscape is open right? If so, run these lines and let the plotFemap magic happen:

To note here, the EM nodes were coloured manually (by the same colours passed to plotDotPlot) in Cytoscape via the Change Colors option in the EM panel. A feature for automated dataset colouring is set to be released in version 3.3.2 of EnrichmentMap.

This has effectively summarized the 156 pathways from our dot plot into 21 unique biological themes (including 4 unclustered pathways). We can now see clear themes in the data pertaining to negative FASN genetic interactions, such as diseases glycosylation, proteins, golgi transport, and rab regulation trafficking. These can be compared and constrasted with the enrichment seen for FASN positive interactions.

Session information

sessionInfo()
#> R version 4.1.0 (2021-05-18)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.2 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.13-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.13-bioc/R/lib/libRlapack.so
#> 
#> 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       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggplot2_3.3.3 tidyr_1.1.3   dplyr_1.0.6   fedup_1.0.0  
#> 
#> loaded via a namespace (and not attached):
#>  [1] bitops_1.0-7        matrixStats_0.58.0  fs_1.5.0           
#>  [4] usethis_2.0.1       devtools_2.4.1      RColorBrewer_1.1-2 
#>  [7] httr_1.4.2          rprojroot_2.0.2     repr_1.1.3         
#> [10] tools_4.1.0         backports_1.2.1     bslib_0.2.5.1      
#> [13] utf8_1.2.1          R6_2.5.0            DBI_1.1.1          
#> [16] BiocGenerics_0.38.0 colorspace_2.0-1    withr_2.4.2        
#> [19] uchardet_1.1.0      tidyselect_1.1.1    prettyunits_1.1.1  
#> [22] processx_3.5.2      curl_4.3.1          compiler_4.1.0     
#> [25] graph_1.70.0        cli_2.5.0           desc_1.3.0         
#> [28] labeling_0.4.2      sass_0.4.0          scales_1.1.1       
#> [31] callr_3.7.0         pbdZMQ_0.3-5        stringr_1.4.0      
#> [34] digest_0.6.27       rmarkdown_2.8       R.utils_2.10.1     
#> [37] base64enc_0.1-3     pkgconfig_2.0.3     htmltools_0.5.1.1  
#> [40] sessioninfo_1.1.1   highr_0.9           fastmap_1.1.0      
#> [43] ggthemes_4.2.4      rlang_0.4.11        farver_2.1.0       
#> [46] jquerylib_0.1.4     generics_0.1.0      jsonlite_1.7.2     
#> [49] zip_2.1.1           R.oo_1.24.0         RCurl_1.98-1.3     
#> [52] magrittr_2.0.1      Matrix_1.3-3        Rcpp_1.0.6         
#> [55] IRkernel_1.2        munsell_0.5.0       fansi_0.4.2        
#> [58] lifecycle_1.0.0     R.methodsS3_1.8.1   stringi_1.6.2      
#> [61] yaml_2.2.1          MASS_7.3-54         RJSONIO_1.3-1.4    
#> [64] pkgbuild_1.2.0      plyr_1.8.6          grid_4.1.0         
#> [67] parallel_4.1.0      forcats_0.5.1       crayon_1.4.1       
#> [70] lattice_0.20-44     IRdisplay_1.0       knitr_1.33         
#> [73] ps_1.6.0            pillar_1.6.1        igraph_1.2.6       
#> [76] uuid_0.1-4          base64url_1.4       stats4_4.1.0       
#> [79] pkgload_1.2.1       XML_3.99-0.6        glue_1.4.2         
#> [82] evaluate_0.14       data.table_1.14.0   remotes_2.3.0      
#> [85] png_0.1-7           vctrs_0.3.8         testthat_3.0.2     
#> [88] gtable_0.3.0        purrr_0.3.4         assertthat_0.2.1   
#> [91] cachem_1.0.5        openxlsx_4.2.3      xfun_0.23          
#> [94] RCy3_2.12.0         signal_0.7-6        tibble_3.1.2       
#> [97] dplR_1.7.2          memoise_2.0.0       ellipsis_0.3.2