Build functional gene modules with GNET2

Chen Chen

2019-10-29

1. Introduction

GNET2 is a R package used for build regulator network and cluster genes to functional groups with E-M process. It iteratively perform TF assigning and Gene assigning, until the assignment of genes did not change, or max number of iterations is reached.

2. Installation

To install, open R and type:

install.packages("devtools")
library("devtools")
install_github("chrischen1/GNET2")

3. Build module networks

We first generate random expression data and a list of regulator gene names.

The input is typically a p by n matrix of expression data of p genes and n samples, for example log2 RPKM from RNA-Seq.

set.seed(2)
init_group_num = 8
init_method = 'boosting'
exp_data <- matrix(rnorm(600*12),600,12)
reg_names <- paste0('TF',1:20)
rownames(exp_data) <- c(reg_names,paste0('gene',1:(nrow(exp_data)-length(reg_names))))
colnames(exp_data) <- paste0('condition_',1:ncol(exp_data))
se <- SummarizedExperiment::SummarizedExperiment(assays=list(counts=exp_data))

The module construction process make take a few time, depending on the size of data and maximum iterations allowed.

gnet_result <- gnet(se,reg_names,init_method,init_group_num,heuristic = TRUE)
#> Determining initial group number...
#> Building module networks...
#> Iteration 1
#> Iteration 2
#> Iteration 3
#> Done.

4. Plot the modules and trees

Plot the regulators module and heatmap of the expression inferred downstream genes for each sample. It can be interpreted as two parts: the bars at the top shows how samples are splited by the regression tree and the heatmap at the bottom shows how downstream genes are regulated by each subgroup determined by the regulators.

plot_gene_group(gnet_result,group_idx = 1)
#> The "ward" method has been renamed to "ward.D"; note new "ward.D2"

Plot the tree of the first group

plot_tree(gnet_result,group_idx = 1)

Plot the correlation of each group and auto detected knee point.

group_above_kn <- plot_group_correlation(gnet_result)

print(group_above_kn)
#> [1] 1 2 3

The group indices in group_above_kn can been used as a list of indices of the data point with correlation higher than the knee point. You may consider use them only for further analysis.

sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.10-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.10-bioc/R/lib/libRlapack.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        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] GNET2_1.2.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.2                  lattice_0.20-38            
#>  [3] tidyr_1.0.0                 visNetwork_2.0.8           
#>  [5] assertthat_0.2.1            zeallot_0.1.0              
#>  [7] digest_0.6.22               R6_2.4.0                   
#>  [9] GenomeInfoDb_1.22.0         plyr_1.8.4                 
#> [11] backports_1.1.5             stats4_3.6.1               
#> [13] evaluate_0.14               ggplot2_3.2.1              
#> [15] pillar_1.4.2                zlibbioc_1.32.0            
#> [17] rlang_0.4.1                 lazyeval_0.2.2             
#> [19] data.table_1.12.6           rstudioapi_0.10            
#> [21] S4Vectors_0.24.0            Matrix_1.2-17              
#> [23] rmarkdown_1.16              DiagrammeR_1.0.1           
#> [25] labeling_0.3                BiocParallel_1.20.0        
#> [27] downloader_0.4              readr_1.3.1                
#> [29] stringr_1.4.0               htmlwidgets_1.5.1          
#> [31] igraph_1.2.4.1              RCurl_1.95-4.12            
#> [33] munsell_0.5.0               DelayedArray_0.12.0        
#> [35] compiler_3.6.1              influenceR_0.1.0           
#> [37] rgexf_0.15.3                xfun_0.10                  
#> [39] pkgconfig_2.0.3             BiocGenerics_0.32.0        
#> [41] htmltools_0.4.0             tidyselect_0.2.5           
#> [43] SummarizedExperiment_1.16.0 tibble_2.1.3               
#> [45] gridExtra_2.3               GenomeInfoDbData_1.2.2     
#> [47] IRanges_2.20.0              matrixStats_0.55.0         
#> [49] XML_3.98-1.20               viridisLite_0.3.0          
#> [51] crayon_1.3.4                dplyr_0.8.3                
#> [53] bitops_1.0-6                grid_3.6.1                 
#> [55] jsonlite_1.6                gtable_0.3.0               
#> [57] lifecycle_0.1.0             magrittr_1.5               
#> [59] scales_1.0.0                stringi_1.4.3              
#> [61] XVector_0.26.0              reshape2_1.4.3             
#> [63] viridis_0.5.1               brew_1.0-6                 
#> [65] vctrs_0.2.0                 xgboost_0.90.0.2           
#> [67] RColorBrewer_1.1-2          tools_3.6.1                
#> [69] Biobase_2.46.0              glue_1.3.1                 
#> [71] purrr_0.3.3                 hms_0.5.1                  
#> [73] Rook_1.1-1                  parallel_3.6.1             
#> [75] yaml_2.2.0                  colorspace_1.4-1           
#> [77] GenomicRanges_1.38.0        knitr_1.25