Contents

1 netresponse - probabilistic tools for functional network analysis

For bug reports and maintainer contact details, see the README file

1.1 Background

Condition-specific network activation is characteristic for cellular systems and other real-world interaction networks. If measurements of network states are available across a versatile set of conditions or time points, it becomes possible to construct a global view of network activation patterns. Different parts of the network respond to different conditions, and in different ways. Systematic, data-driven identification of these responses will help to obtain a holistic view of network activity [1-2]. This package provides robust probabilistic algorithms for functional network analysis [1, 3].

The methods are based on nonparametric probabilistic modeling and variational learning, and provide general exploratory tools to investigate the structure

NetResponse detects and characterizes subnetworks that exhibit context-specific activation patterns across versatile collections of functional measurements, such as gene expression data. The implementations are partially based on the agglomerative independent variable group analysis (AIVGA) and variational Dirichlet process Gaussian mixture models (Kurihara et al. 2007). The tools are particularly useful for global exploratory analysis of genome-wide interaction networks and versatile collections of gene expression data, and in general to discover subnetworks with alternative states.

1.2 Usage examples

Examples on running NetResponse algorithm and visualizing the results. The algorithm combines network and functional information to detect coherent subnetworks that reveal distinct activation modes across conditions.

library(netresponse)

# Generate simulated data
res <- generate.toydata(Dim = 3, Nc = 3, Ns = 200, sd0 = 3, rgam.shape = 1, rgam.scale = 1)

D <- res$data
component.means <- res$means
component.sds   <- res$sds
sample2comp     <- res$sample2comp

# Use fully connected network
network <- matrix(rep(1, 9), nrow = 3) 

# Fit NetResponse model
# Various network formats are supported, see help(detect.responses) for
# details. With large data sets, consider the 'speedup' option.
set.seed(4243)
res <- detect.responses(D, network, mixture.method = "vdp", pca.basis = TRUE)

# List subnets (each is a list of nodes)
subnet.id <- names(get.subnets(res))[[1]]

1.2.1 PCA visualization

library(ggplot2)
vis <- plot_responses(res, subnet.id, plot_mode = "pca")
# Modify the resulting ggplot2 object to enhance visualization
p <- vis$p # Pick the ggplot2 object from results
p <- p + geom_point(size = 3) # Modify point size
print(p) 

1.2.2 Network visualization

vis <- plot_responses(res, subnet.id, plot_mode = "network")

1.2.3 Heatmap visualization

vis <- plot_responses(res, subnet.id, plot_mode = "heatmap")

1.2.4 Boxplot visualization

vis <- plot_responses(res, subnet.id, plot_mode = "boxplot_data")

See also mode = “response.barplot”

1.2.5 Color scale

plot_scale(vis$breaks, vis$palette, two.sided = TRUE)

1.2.6 Cluster assignments

The sample-response assignments from the mixture model are soft ie. defined as continuous probabilities. Retrieve the hard clustering ie. list of samples for each response, response for each sample, based the highest probability:

subnet.id <- 'Subnet-1'

# Sample - response probabilities (soft cluster assignment)
response.probs <- sample2response(res, subnet.id)
tail(round(response.probs, 6))
##              Mode-1   Mode-2
## Sample-195 0.998520 0.001480
## Sample-196 0.000073 0.999927
## Sample-197 0.000230 0.999770
## Sample-198 0.009301 0.990699
## Sample-199 0.000661 0.999339
## Sample-200 0.313022 0.686978
# Sample - response hard assignments
hard.clusters <- response2sample(res, subnet.id)
print(hard.clusters)
## $`Mode-1`
##   [1] "Sample-1"   "Sample-2"   "Sample-6"   "Sample-7"   "Sample-8"  
##   [6] "Sample-9"   "Sample-10"  "Sample-11"  "Sample-12"  "Sample-13" 
##  [11] "Sample-14"  "Sample-15"  "Sample-16"  "Sample-17"  "Sample-18" 
##  [16] "Sample-19"  "Sample-21"  "Sample-22"  "Sample-24"  "Sample-26" 
##  [21] "Sample-28"  "Sample-30"  "Sample-32"  "Sample-33"  "Sample-34" 
##  [26] "Sample-35"  "Sample-36"  "Sample-37"  "Sample-38"  "Sample-40" 
##  [31] "Sample-41"  "Sample-44"  "Sample-46"  "Sample-50"  "Sample-52" 
##  [36] "Sample-54"  "Sample-55"  "Sample-56"  "Sample-58"  "Sample-59" 
##  [41] "Sample-61"  "Sample-63"  "Sample-65"  "Sample-66"  "Sample-68" 
##  [46] "Sample-69"  "Sample-71"  "Sample-72"  "Sample-73"  "Sample-74" 
##  [51] "Sample-76"  "Sample-77"  "Sample-78"  "Sample-79"  "Sample-80" 
##  [56] "Sample-81"  "Sample-82"  "Sample-84"  "Sample-85"  "Sample-86" 
##  [61] "Sample-88"  "Sample-89"  "Sample-90"  "Sample-92"  "Sample-94" 
##  [66] "Sample-95"  "Sample-96"  "Sample-97"  "Sample-98"  "Sample-99" 
##  [71] "Sample-100" "Sample-101" "Sample-102" "Sample-104" "Sample-105"
##  [76] "Sample-106" "Sample-107" "Sample-108" "Sample-109" "Sample-112"
##  [81] "Sample-113" "Sample-115" "Sample-116" "Sample-118" "Sample-120"
##  [86] "Sample-121" "Sample-123" "Sample-126" "Sample-127" "Sample-128"
##  [91] "Sample-129" "Sample-130" "Sample-132" "Sample-133" "Sample-135"
##  [96] "Sample-136" "Sample-137" "Sample-138" "Sample-140" "Sample-141"
## [101] "Sample-143" "Sample-145" "Sample-146" "Sample-150" "Sample-151"
## [106] "Sample-153" "Sample-156" "Sample-157" "Sample-159" "Sample-160"
## [111] "Sample-161" "Sample-162" "Sample-163" "Sample-164" "Sample-167"
## [116] "Sample-168" "Sample-169" "Sample-170" "Sample-171" "Sample-172"
## [121] "Sample-175" "Sample-177" "Sample-178" "Sample-181" "Sample-182"
## [126] "Sample-183" "Sample-184" "Sample-186" "Sample-189" "Sample-190"
## [131] "Sample-191" "Sample-192" "Sample-193" "Sample-194" "Sample-196"
## [136] "Sample-197" "Sample-198" "Sample-199"
## 
## $`Mode-2`
##  [1] "Sample-3"   "Sample-4"   "Sample-5"   "Sample-20"  "Sample-23" 
##  [6] "Sample-25"  "Sample-27"  "Sample-29"  "Sample-31"  "Sample-39" 
## [11] "Sample-42"  "Sample-43"  "Sample-45"  "Sample-47"  "Sample-48" 
## [16] "Sample-49"  "Sample-51"  "Sample-53"  "Sample-57"  "Sample-60" 
## [21] "Sample-62"  "Sample-64"  "Sample-67"  "Sample-70"  "Sample-75" 
## [26] "Sample-83"  "Sample-87"  "Sample-91"  "Sample-93"  "Sample-103"
## [31] "Sample-110" "Sample-111" "Sample-114" "Sample-117" "Sample-119"
## [36] "Sample-122" "Sample-124" "Sample-125" "Sample-131" "Sample-134"
## [41] "Sample-139" "Sample-142" "Sample-144" "Sample-147" "Sample-148"
## [46] "Sample-149" "Sample-152" "Sample-154" "Sample-155" "Sample-158"
## [51] "Sample-165" "Sample-166" "Sample-173" "Sample-174" "Sample-176"
## [56] "Sample-179" "Sample-180" "Sample-185" "Sample-187" "Sample-188"
## [61] "Sample-195" "Sample-200"

Retrieve model parameters for a given subnetwork (Gaussian mixture means, covariance diagonal, and component weights; see help(get.model.parameters) for details):

params <- get.model.parameters(res, subnet.id) 
names(params)
## [1] "mu"          "sd"          "w"           "free.energy" "Nparams"    
## [6] "qofz"        "nodes"

1.3 Nonparametric Gaussian mixture models

Nonparametric Gaussian mixtures with variational Dirichlet processes based on implementations by Kurihara et al. (2007) and Honkela et al..

# Generate 2-dimensional simulated data with 3 clusters
res <- generate.toydata(Dim = 2, Nc = 3, Ns = 200, sd0 = 3, rgam.shape = 1, rgam.scale = 1)

D <- res$data
real.means <- res$means
real.sds   <- res$sds
real.sample2comp     <- res$sample2comp

# Infinite Gaussian mixture model with       
# Variational Dirichlet Process approximation       
mixt <- vdp.mixt( D )
            
# Centroids of the detected Gaussian components       
estimated.means <- mixt$posterior$centroids

# The colors denote the known clusters
# The blue ball denotes the original (known) cluster centroids and
# the triangle denotes the estimated centroids
plot(D, col = real.sample2comp, pch = 1)
points(real.means, col = "blue", pch = 16, cex = 2)
points(estimated.means, col = "blue", pch = 17, cex = 2)

# Hard mixture component assignment for each sample
estimated.sample2comp <- apply(mixt$posterior$qOFz, 1, which.max)

# Compare known and estimated mixture components
# (note that cluster indices may have switched due to unidentifiability)
# nearly all samples have one-to-one match between the real and estimated 
# clusters
head(table(estimated.sample2comp, real.sample2comp))
##                      real.sample2comp
## estimated.sample2comp  1  2  3
##                     1 75  0 19
##                     2  3  0 48
##                     3  0 55  0

1.3.1 Citing NetResponse

Please cite Lahti et al. (2010) with the package.

citation("netresponse")
## 
## To cite netrespose (algorithm and package) in publications use:
## 
##   Leo Lahti et al. Global modeling of transcriptional responses in
##   interaction networks Bioinformatics 26(21):2713--20, 2010.
## 
## A BibTeX entry for LaTeX users is
## 
##   @Article{,
##     title = {Global modeling of transcriptional responses in interaction networks},
##     author = {Leo Lahti and Juha E.A. Knuuttila and Samuel Kaski},
##     journal = {Bioinformatics},
##     year = {2010},
##     volume = {26},
##     issue = {21},
##     pages = {2713--20},
##   }
## 
## For ICMg functionality, please cite additionally the references listed
## in help(ICMg.combined.sampler). Thanks for Olli-Pekka Huovilainen and
## Antonio Gusmao for contributions to the R/C implementation of the
## netresponse algorithm and Juuso Parkkinen for ICMg.

1.3.2 Version information

This document was written using:

sessionInfo()
## R Under development (unstable) (2021-10-19 r81077)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.15-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.15-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] grid      stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] netresponse_1.55.0  reshape2_1.4.4      mclust_5.4.7       
##  [4] minet_3.53.0        rmarkdown_2.11      Rgraphviz_2.39.0   
##  [7] graph_1.73.0        BiocGenerics_0.41.0 knitr_1.36         
## [10] BiocStyle_2.23.0   
## 
## loaded via a namespace (and not attached):
##  [1] qvalue_2.27.0       tidyselect_1.1.1    xfun_0.27          
##  [4] bslib_0.3.1         purrr_0.3.4         splines_4.2.0      
##  [7] lattice_0.20-45     colorspace_2.0-2    vctrs_0.3.8        
## [10] generics_0.1.1      htmltools_0.5.2     stats4_4.2.0       
## [13] yaml_2.2.1          utf8_1.2.2          rlang_0.4.12       
## [16] jquerylib_0.1.4     pillar_1.6.4        DBI_1.1.1          
## [19] glue_1.4.2          RColorBrewer_1.1-2  lifecycle_1.0.1    
## [22] plyr_1.8.6          stringr_1.4.0       munsell_0.5.0      
## [25] gtable_0.3.0        mvtnorm_1.1-3       evaluate_0.14      
## [28] fastmap_1.1.0       parallel_4.2.0      fansi_0.5.0        
## [31] highr_0.9           Rcpp_1.0.7          scales_1.1.1       
## [34] BiocManager_1.30.16 magick_2.7.3        jsonlite_1.7.2     
## [37] ggplot2_3.3.5       digest_0.6.28       stringi_1.7.5      
## [40] bookdown_0.24       dplyr_1.0.7         dmt_0.8.20         
## [43] tools_4.2.0         magrittr_2.0.1      sass_0.4.0         
## [46] tibble_3.1.5        crayon_1.4.1        pkgconfig_2.0.3    
## [49] MASS_7.3-54         ellipsis_0.3.2      Matrix_1.3-4       
## [52] assertthat_0.2.1    R6_2.5.1            igraph_1.2.7       
## [55] compiler_4.2.0