Introduction to the netresponse R package


# Global options

netresponse - probabilistic tools for functional network analysis

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


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.

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.


# 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.
res <- detect.responses(D, network, mixture.method = "vdp", pca.basis = TRUE)

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

PCA visualization

vis <- plot_responses(res,, 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

Network visualization

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

Heatmap visualization

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

Boxplot visualization

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

See also mode = "response.barplot"

Color scale

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

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-1'

# Sample - response probabilities (soft cluster assignment)
response.probs <- sample2response(res,
tail(round(response.probs, 6))

# Sample - response hard assignments
hard.clusters <- response2sample(res,

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, 

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))

Citing NetResponse

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


Version information

This document was written using:


Try the netresponse package in your browser

Any scripts or data that you put into this service are public.

netresponse documentation built on Nov. 8, 2020, 5:04 p.m.