# Gene regulatory network inference

Fabricio Almeida-Silva1 and Thiago Motta Venancio1

1Universidade Estadual do Norte Fluminense Darcy Ribeiro, RJ, Brazil

#### 29 August 2021

# Contents

# 1 Installation

    if(!requireNamespace('BiocManager', quietly = TRUE))
      install.packages('BiocManager')

    BiocManager::install("BioNERO")

    # Load package after installation
    library(BioNERO)
    set.seed(123) # for reproducibility

# 2 Introduction and algorithm description

In the previous vignette, we explored all aspects of gene coexpression networks (GCNs), which are represented as undirected weighted graphs. It is undirected because, for a given link between gene A and gene B, we can only say that these genes are coexpressed, but we cannot know whether gene A controls gene B or otherwise. Further, weighted means that some coexpression relationships between gene pairs are stronger than others. In this vignette, we will demonstrate how to infer gene regulatory networks (GRNs) from expression data with BioNERO. GRNs display interactions between regulators (e.g., transcription factors or miRNAs) and their targets (e.g., genes). Hence, they are represented as directed unweighted graphs.

Numerous algorithms have been developed to infer GRNs from expression data. However, the algorithm performances are highly dependent on the benchmark data set. To solve this uncertainty, Marbach et al. (2012) proposed the application of the “wisdom of the crowds” principle to GRN inference. This approach consists in inferring GRNs with different algorithms, ranking the interactions identified by each method, and calculating the average rank for each interaction across all algorithms used. This way, we can have consensus, high-confidence edges to be used in biological interpretations. For that, `BioNERO` implements three popular algorithms: GENIE3 (Huynh-Thu et al. 2010), ARACNE (Margolin et al. 2006) and CLR (Faith et al. 2007).

# 3 Data preprocessing

Before inferring the GRN, we will preprocess the expression data the same way we did in the previous vignette.

    # Load example data set
    data(zma.se)

    # Preprocess the expression data
    final_exp <- exp_preprocess(zma.se, min_exp = 10, variance_filter = TRUE, n=2000)
    ## Number of removed samples: 1

# 4 Gene regulatory network inference

`BioNERO` requires only 2 objects for GRN inference: the expression data (SummarizedExperiment, matrix or data frame) and a character vector of regulators (transcription factors or miRNAs). The transcription factors used in this vignette were downloaded from PlantTFDB 4.0 (Jin et al. 2017).

    data(zma.tfs)
    head(zma.tfs)
    ##              Gene Family
    ## 6  Zm00001d022525    Dof
    ## 25 Zm00001d037605   GATA
    ## 28 Zm00001d049540    NAC
    ## 45 Zm00001d042287    MYB
    ## 46 Zm00001d042288    NAC
    ## 54 Zm00001d039371    TCP

## 4.1 Consensus GRN inference

Inferring GRNs based on the wisdom of the crowds principle can be done with a single function: `exp2grn()`. This function will infer GRNs with GENIE3, ARACNE and CLR, calculate average ranks for each interaction and filter the resulting network based on the optimal scale-free topology (SFT) fit. In the filtering step, n different networks are created by subsetting the top n quantiles. For instance, if a network of 10,000 edges is given as input with `nsplit = 10`, 10 different networks will be created: the first with 1,000 edges, the second with 2,000 edges, and so on, with the last network being the original input network. Then, for each network, the function will calculate the SFT fit and select the best fit.

    # Using 10 trees for demonstration purposes. Use the default: 1000
    grn <- exp2grn(exp = final_exp, regulators = zma.tfs$Gene, nTrees=10)
    ## The top number of edges that best fits the scale-free topology is 247

    head(grn)
    ##          Regulator         Target
    ## 291 Zm00001d041474 Zm00001d027374
    ## 304 Zm00001d042263 Zm00001d045042
    ## 280 Zm00001d041474 Zm00001d006602
    ## 281 Zm00001d041474 Zm00001d006942
    ## 289 Zm00001d041474 Zm00001d018668
    ## 145 Zm00001d028432 Zm00001d014349

## 4.2 Algorithm-specific GRN inference

This section is directed to users who, for some reason (e.g., comparison, exploration), want to infer GRNs with particular algorithms. The available algorithms are:

GENIE3: a regression-tree based algorithm that decomposes the prediction of GRNs for n genes into n regression problems. For each regression problem, the expression profile of a target gene is predicted from the expression profiles of all other genes using random forests (default) or extra-trees.

    # Using 10 trees for demonstration purposes. Use the default: 1000
    genie3 <- grn_infer(final_exp, method = "genie3", regulators = zma.tfs$Gene,
                        nTrees=10)
    head(genie3)
    ##                Node1          Node2    Weight
    ## 33124 Zm00001d041474 Zm00001d030526 0.4543919
    ## 48251 Zm00001d010227 Zm00001d042512 0.4345670
    ## 3999  Zm00001d030617 Zm00001d003756 0.4153485
    ## 6030  Zm00001d041474 Zm00001d006112 0.4129481
    ## 17154 Zm00001d013777 Zm00001d015301 0.4106367
    ## 2993  Zm00001d034751 Zm00001d002543 0.4061533
    dim(genie3)
    ## [1] 60137     3

ARACNE: information-theoretic algorithm that aims to remove indirect interactions inferred by coexpression.

    aracne <- grn_infer(final_exp, method = "aracne", regulators = zma.tfs$Gene)
    head(aracne)
    ##                Node1          Node2   Weight
    ## 23861 Zm00001d038832 Zm00001d021147 1.789818
    ## 1758  Zm00001d038832 Zm00001d000432 1.692232
    ## 11337 Zm00001d038832 Zm00001d011086 1.692232
    ## 27014 Zm00001d011139 Zm00001d024274 1.674840
    ## 51070 Zm00001d011139 Zm00001d045069 1.658043
    ## 28387 Zm00001d038832 Zm00001d025784 1.641802
    dim(aracne)
    ## [1] 411   3

CLR: extension of the relevance networks algorithm that uses mutual information to identify regulatory interactions.

    clr <- grn_infer(final_exp, method = "clr", regulators = zma.tfs$Gene)
    head(clr)
    ##                Node1          Node2   Weight
    ## 26302 Zm00001d046937 Zm00001d023376 12.70216
    ## 11267 Zm00001d046937 Zm00001d011080 12.25336
    ## 12540 Zm00001d041474 Zm00001d012007 10.74023
    ## 51019 Zm00001d042263 Zm00001d045042 10.50925
    ## 17810 Zm00001d041474 Zm00001d015811 10.33216
    ## 29278 Zm00001d046937 Zm00001d026632 10.20075
    dim(clr)
    ## [1] 26657     3

Users can also infer GRNs with the 3 algorithms at once using the function `exp_combined()`. The resulting edge lists are stored in a list of 3 elements.1 1 1 NOTE: Under the hood, `exp2grn()` uses `exp_combined()` followed by averaging ranks with `grn_average_rank()` and filtering with `grn_filter()`.

    grn_list <- grn_combined(final_exp, regulators = zma.tfs$Gene, nTrees=10)
    head(grn_list$genie3)
    ##                Node1          Node2    Weight
    ## 5628  Zm00001d034751 Zm00001d005791 0.4974681
    ## 13817 Zm00001d038832 Zm00001d012857 0.4409274
    ## 40787 Zm00001d038832 Zm00001d036480 0.4278640
    ## 59659 Zm00001d010227 Zm00001d053223 0.4170315
    ## 29653 Zm00001d034751 Zm00001d027342 0.4012469
    ## 11069 Zm00001d052229 Zm00001d011034 0.3923846
    head(grn_list$aracne)
    ##                Node1          Node2   Weight
    ## 23861 Zm00001d038832 Zm00001d021147 1.789818
    ## 1758  Zm00001d038832 Zm00001d000432 1.692232
    ## 11337 Zm00001d038832 Zm00001d011086 1.692232
    ## 27014 Zm00001d011139 Zm00001d024274 1.674840
    ## 51070 Zm00001d011139 Zm00001d045069 1.658043
    ## 28387 Zm00001d038832 Zm00001d025784 1.641802
    head(grn_list$clr)
    ##                Node1          Node2   Weight
    ## 26302 Zm00001d046937 Zm00001d023376 12.70216
    ## 11267 Zm00001d046937 Zm00001d011080 12.25336
    ## 12540 Zm00001d041474 Zm00001d012007 10.74023
    ## 51019 Zm00001d042263 Zm00001d045042 10.50925
    ## 17810 Zm00001d041474 Zm00001d015811 10.33216
    ## 29278 Zm00001d046937 Zm00001d026632 10.20075

# 5 Gene regulatory network analysis

After inferring the GRN, `BioNERO` allows users to perform some common downstream analyses.

## 5.1 Hub gene identification

GRN hubs are defined as the top 10% most highly connected regulators, but this percentile is flexible in `BioNERO`.2 2 2 NOTE: Remember: GRNs are represented as directed graphs. This implies that only regulators are taken into account when identifying hubs. The goal here is to identify regulators (e.g., transcription factors) that control the expression of several genes. They can be identified with `get_hubs_grn()`.

    hubs <- get_hubs_grn(grn)
    hubs
    ##              Gene Degree
    ## 1  Zm00001d038832     19
    ## 2  Zm00001d041474     13
    ## 3  Zm00001d025339     11
    ## 4  Zm00001d046937     11
    ## 5  Zm00001d052229     11
    ## 6  Zm00001d010227     11
    ## 7  Zm00001d030617     11
    ## 8  Zm00001d039989     10
    ## 9  Zm00001d038227     10
    ## 10 Zm00001d011139      9
    ## 11 Zm00001d044315      9
    ## 12 Zm00001d028974      9
    ## 13 Zm00001d013777      9
    ## 14 Zm00001d003822      8
    ## 15 Zm00001d046568      8
    ## 16 Zm00001d020020      7
    ## 17 Zm00001d014377      7
    ## 18 Zm00001d034751      7
    ## 19 Zm00001d054038      7
    ## 20 Zm00001d031655      6
    ## 21 Zm00001d042267      6
    ## 22 Zm00001d036148      6
    ## 23 Zm00001d018081      6
    ## 24 Zm00001d035440      6
    ## 25 Zm00001d027957      6
    ## 26 Zm00001d042263      5
    ## 27 Zm00001d002654      5

## 5.2 Network visualization

    plot_grn(grn)

GRNs can also be visualized interactively for exploratory purposes.

    plot_grn(grn, interactive = TRUE, dim_interactive = c(500,500))

Finally, `BioNERO` can also be used for visualization and hub identification in protein-protein (PPI) interaction networks. The functions `get_hubs_ppi()` and `plot_ppi()` work the same way as their equivalents for GRNs (`get_hubs_grn()` and `plot_grn()`).

# Session information

This vignette was created under the following conditions:

    sessionInfo()
    ## R version 4.1.1 (2021-08-10)
    ## Platform: x86_64-w64-mingw32/x64 (64-bit)
    ## Running under: Windows Server 2012 R2 x64 (build 9600)
    ##
    ## Matrix products: default
    ##
    ## locale:
    ## [1] LC_COLLATE=C
    ## [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] BioNERO_1.0.4    BiocStyle_2.20.2
    ##
    ## loaded via a namespace (and not attached):
    ##   [1] snow_0.4-3                  readxl_1.3.1
    ##   [3] backports_1.2.1             circlize_0.4.13
    ##   [5] Hmisc_4.5-0                 plyr_1.8.6
    ##   [7] igraph_1.2.6                splines_4.1.1
    ##   [9] GENIE3_1.14.0               BiocParallel_1.26.2
    ##  [11] GenomeInfoDb_1.28.2         ggnetwork_0.5.10
    ##  [13] ggplot2_3.3.5               sva_3.40.0
    ##  [15] digest_0.6.27               foreach_1.5.1
    ##  [17] htmltools_0.5.2             magick_2.7.3
    ##  [19] GO.db_3.13.0                fansi_0.5.0
    ##  [21] magrittr_2.0.1              checkmate_2.0.0
    ##  [23] memoise_2.0.0               cluster_2.1.2
    ##  [25] doParallel_1.0.16           limma_3.48.3
    ##  [27] openxlsx_4.2.4              ComplexHeatmap_2.8.0
    ##  [29] fastcluster_1.2.3           Biostrings_2.60.2
    ##  [31] annotate_1.70.0             matrixStats_0.60.1
    ##  [33] jpeg_0.1-9                  colorspace_2.0-2
    ##  [35] ggrepel_0.9.1               blob_1.2.2
    ##  [37] haven_2.4.3                 xfun_0.25
    ##  [39] dplyr_1.0.7                 crayon_1.4.1
    ##  [41] RCurl_1.98-1.4              jsonlite_1.7.2
    ##  [43] genefilter_1.74.0           impute_1.66.0
    ##  [45] survival_3.2-13             iterators_1.0.13
    ##  [47] glue_1.4.2                  gtable_0.3.0
    ##  [49] zlibbioc_1.38.0             XVector_0.32.0
    ##  [51] GetoptLong_1.0.5            DelayedArray_0.18.0
    ##  [53] car_3.0-11                  shape_1.4.6
    ##  [55] BiocGenerics_0.38.0         abind_1.4-5
    ##  [57] scales_1.1.1                edgeR_3.34.0
    ##  [59] DBI_1.1.1                   rstatix_0.7.0
    ##  [61] Rcpp_1.0.7                  xtable_1.8-4
    ##  [63] htmlTable_2.2.1             clue_0.3-59
    ##  [65] foreign_0.8-81              bit_4.0.4
    ##  [67] preprocessCore_1.54.0       Formula_1.2-4
    ##  [69] stats4_4.1.1                htmlwidgets_1.5.3
    ##  [71] httr_1.4.2                  RColorBrewer_1.1-2
    ##  [73] ellipsis_0.3.2              farver_2.1.0
    ##  [75] pkgconfig_2.0.3             XML_3.99-0.7
    ##  [77] nnet_7.3-16                 sass_0.4.0
    ##  [79] locfit_1.5-9.4              utf8_1.2.2
    ##  [81] dynamicTreeCut_1.63-1       labeling_0.4.2
    ##  [83] reshape2_1.4.4              tidyselect_1.1.1
    ##  [85] rlang_0.4.11                AnnotationDbi_1.54.1
    ##  [87] cellranger_1.1.0            munsell_0.5.0
    ##  [89] tools_4.1.1                 cachem_1.0.6
    ##  [91] generics_0.1.0              RSQLite_2.2.8
    ##  [93] statnet.common_4.5.0        broom_0.7.9
    ##  [95] evaluate_0.14               stringr_1.4.0
    ##  [97] fastmap_1.1.0               yaml_2.2.1
    ##  [99] RhpcBLASctl_0.20-137        knitr_1.33
    ## [101] bit64_4.0.5                 zip_2.2.0
    ## [103] purrr_0.3.4                 KEGGREST_1.32.0
    ## [105] nlme_3.1-152                compiler_4.1.1
    ## [107] rstudioapi_0.13             curl_4.3.2
    ## [109] png_0.1-7                   ggsignif_0.6.2
    ## [111] minet_3.50.0                tibble_3.1.4
    ## [113] statmod_1.4.36              geneplotter_1.70.0
    ## [115] bslib_0.2.5.1               stringi_1.7.4
    ## [117] highr_0.9                   forcats_0.5.1
    ## [119] lattice_0.20-44             Matrix_1.3-4
    ## [121] vctrs_0.3.8                 networkD3_0.4
    ## [123] pillar_1.6.2                lifecycle_1.0.0
    ## [125] BiocManager_1.30.16         jquerylib_0.1.4
    ## [127] GlobalOptions_0.1.2         cowplot_1.1.1
    ## [129] data.table_1.14.0           bitops_1.0-7
    ## [131] GenomicRanges_1.44.0        R6_2.5.1
    ## [133] latticeExtra_0.6-29         bookdown_0.23
    ## [135] network_1.17.1              rio_0.5.27
    ## [137] gridExtra_2.3               IRanges_2.26.0
    ## [139] codetools_0.2-18            assertthat_0.2.1
    ## [141] SummarizedExperiment_1.22.0 DESeq2_1.32.0
    ## [143] rjson_0.2.20                S4Vectors_0.30.0
    ## [145] GenomeInfoDbData_1.2.6      intergraph_2.0-2
    ## [147] mgcv_1.8-36                 hms_1.1.0
    ## [149] parallel_4.1.1              grid_4.1.1
    ## [151] rpart_4.1-15                tidyr_1.1.3
    ## [153] NetRep_1.2.4                coda_0.19-4
    ## [155] rmarkdown_2.10              carData_3.0-4
    ## [157] MatrixGenerics_1.4.3        Cairo_1.5-12.2
    ## [159] ggpubr_0.4.0                ggnewscale_0.4.5
    ## [161] Biobase_2.52.0              WGCNA_1.70-3
    ## [163] base64enc_0.1-3

# References

Faith, Jeremiah J., Boris Hayete, Joshua T. Thaden, Ilaria Mogno, Jamey Wierzbowski, Guillaume Cottarel, Simon Kasif, James J. Collins, and Timothy S. Gardner. 2007. “Large-scale mapping and validation of Escherichia coli transcriptional regulation from a compendium of expression profiles.” PLoS Biology 5 (1): 0054–0066. https://doi.org/10.1371/journal.pbio.0050008.

Huynh-Thu, Vân Anh, Alexandre Irrthum, Louis Wehenkel, and Pierre Geurts. 2010. “Inferring regulatory networks from expression data using tree-based methods.” PLoS ONE 5 (9): 1–10. https://doi.org/10.1371/journal.pone.0012776.

Jin, J, F Tian, D C Yang, Y Q Meng, L Kong, J Luo, and G Gao. 2017. “PlantTFDB 4.0: toward a central hub for transcription factors and regulatory interactions in plants.” Nucleic Acids Res 45 (D1): D1040–D1045. https://doi.org/10.1093/nar/gkw982.

Marbach, Daniel, James C. Costello, Robert Küffner, Nicole M. Vega, Robert J. Prill, Diogo M. Camacho, Kyle R. Allison, et al. 2012. “Wisdom of crowds for robust gene network inference.” Nature Methods 9 (8): 796–804. https://doi.org/10.1038/nmeth.2016.

Margolin, Adam A., Ilya Nemenman, Katia Basso, Chris Wiggins, Gustavo Stolovitzky, Riccardo Dalla Favera, and Andrea Califano. 2006. “ARACNE: An algorithm for the reconstruction of gene regulatory networks in a mammalian cellular context.” BMC Bioinformatics 7 (SUPPL.1): 1–15. https://doi.org/10.1186/1471-2105-7-S1-S7.