R: Create a scatterplot showing correlation between specific...
scatter_plot
R Documentation
Create a scatterplot showing correlation between specific nodes in the network
for each pre-specified group.
Description
This function takes the output of het_cv_glasso or
mixglasso and creates a plot showing the correlation between specified
node pairs in the network for all groups. The subplots for each node pair are
arranged in a numPairs by numGroups grid. Partial correlations associated
with each node pair are also displayed.
A network clustering object as returned by
het_cv_glasso or mixglasso.
data
Observed data for the nodes, a numObs by numNodes matrix. Note
that nodes need to be in the same ordering as in node.names.
node.pairs
A matrix of size numPairs by 2, where each row contains a
pair of nodes to display. If node.names is specified, names in node.pairs
must correspond to elements of node.names.
display
If TRUE, print the plot to the current output device.
node.names
Names for the nodes in the network. If NULL, names from
net.clustering will be used.
group.names
Names for the clusters or groups. If NULL, names from
net.clustering will be used (by default these are integets 1:numClusters).
cex
Scale factor for text and symbols in plot.
Value
Returns a ggplot2 object. If display=TRUE, additionally displays the
plot.
Examples
n = 500
p = 10
s = 0.9
n.comp = 3
# Create different mean vectors
Mu = matrix(0,p,n.comp)
# Define non-zero means in each group (non-overlapping)
nonzero.mean = split(sample(1:p),rep(1:n.comp,length=p))
# Set non-zero means to fixed value
for(k in 1:n.comp){
Mu[nonzero.mean[[k]],k] = -2/sqrt(ceiling(p/n.comp))
}
# Generate data
sim.result = sim_mix_networks(n, p, n.comp, s, Mu=Mu)
mixglasso.result = mixglasso(sim.result$data, n.comp=3)
mixglasso.clustering = mixglasso.result$models[[mixglasso.result$bic.opt]]
# Specify edges
node.pairs = rbind(c(1,3), c(6,9),c(7,8))
# Create scatter plots of specified edges
scatter_plot(mixglasso.clustering, data=sim.result$data,
node.pairs=node.pairs)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(nethet)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/nethet/scatter_plot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: scatter_plot
> ### Title: Create a scatterplot showing correlation between specific nodes
> ### in the network for each pre-specified group.
> ### Aliases: scatter_plot
>
> ### ** Examples
>
> n = 500
> p = 10
> s = 0.9
> n.comp = 3
>
> # Create different mean vectors
> Mu = matrix(0,p,n.comp)
>
> # Define non-zero means in each group (non-overlapping)
> nonzero.mean = split(sample(1:p),rep(1:n.comp,length=p))
>
> # Set non-zero means to fixed value
> for(k in 1:n.comp){
+ Mu[nonzero.mean[[k]],k] = -2/sqrt(ceiling(p/n.comp))
+ }
>
> # Generate data
> sim.result = sim_mix_networks(n, p, n.comp, s, Mu=Mu)
> mixglasso.result = mixglasso(sim.result$data, n.comp=3)
> mixglasso.clustering = mixglasso.result$models[[mixglasso.result$bic.opt]]
>
> # Specify edges
> node.pairs = rbind(c(1,3), c(6,9),c(7,8))
>
> # Create scatter plots of specified edges
> scatter_plot(mixglasso.clustering, data=sim.result$data,
+ node.pairs=node.pairs)
>
>
>
>
>
> dev.off()
null device
1
>