Last data update: 2014.03.03

R: Random networks and data sampling
generateNetworkR Documentation

Random networks and data sampling

Description

1. Random network generation; 2. sampling of data from a given network topology

Usage

sampleRndNetwork(Sgenes, scaleFree=TRUE, gamma=2.5, maxOutDegree=length(Sgenes), maxInDegree=length(Sgenes), trans.close=TRUE, DAG=FALSE)

sampleData(Phi, m, prob=NULL, uninformative=0, type="binary", replicates=4, typeI.err=0.05, typeII.err=0.2, alpha=sample(seq(0.1,0.9,by=0.1),ncol(Phi),replace=TRUE), beta=sample(5:50,ncol(Phi),replace=TRUE), lambda=matrix(sample(seq(0.01,0.49,by=0.01),ncol(Phi)*2,replace=TRUE),ncol=2), meansH1=rep(0.5, ncol(Phi)), meansH0=rep(-0.5, ncol(Phi)), sdsH1=sample(seq(0.1,1,by=0.1),ncol(Phi),replace=TRUE), sdsH0=sample(seq(0.1,1,by=0.1),ncol(Phi),replace=TRUE))

Arguments

Sgenes

character vector of S-genes

scaleFree

should the network topology be scale free?

gamma

for scale free networks: out-degrees of nodes are sampled from frac{1}{Z} * (0:maxOutDegree)^{-γ}, where Z is a normalization factor

maxOutDegree

maximal out-degree of nodes

maxInDegree

maximal in-degree of nodes prior to transitive closure

trans.close

Should the transitive closure of the graph be returned? Default: TRUE

DAG

Should only DAGs be sampled? Default: FALSE

Phi

adjacency matrix

m

number of E-genes to sample

prob

probability for each S-gene to get an E-gene attached

uninformative

additional number of uninformative E-genes, i.e. E-genes carrying no information about the nested structure

type

"binary" = binary data; "density" = log 'p-value' densities sampled from beta-uniform mixture model; "lodds" = log odds sampled from two normal distributions

replicates

number of replicate measurements to simulate for binary data

typeI.err

simulated type I error for binary data

typeII.err

simulated type II error for binary data

alpha

parameter for Beta(α,1) distribution: one parameter per S-gene

beta

parameter for Beta(1,β) distribution: one parameter per S-gene

lambda

mixing coefficients for beta-uniform mixture model of the form: λ_1 + λ_2*Beta(α,1) + λ_3*Beta(1,β). There is a vector of 3 mixing coefficients per model and one model per S-gene.

meansH1

normal distribution means of log odds ratios under the hypothesis of expecting an effect: one mean per S-gene

meansH0

normal distribution means of log odds ratios under the null hypothesis: one mean per S-gene

sdsH1

normal distribution standard deviations of log odds values under the hypothesis of expecting an effect: one sd per S-gene

sdsH0

normal distribution standard deviations of log odds values under the null hypothesis: one sd per S-gene

Details

Random networks are generated as follows: For each S-gene S_{k} we randomly choose the number o of outgoing edges between 0 and maxOutDegree. This is either done uniform randomly or, if scale free networks are created, according to a power law distribution specified by gamma. We then select o S-genes having at most maxInDegree ingoing edge and connected S_{k} to them.

The function sampleData samples data from a given network topology as follows: We first attach E-genes to S-genes according to the probabilities prob (default: uniform). We then simulate knock-downs of the individual S-genes. For those E-genes, where no effects are expected, values are sampled from a null distribution, otherwise from an alternative distribution. In the simplest case we only sample binary data, where 1 indicates an effect an 0 no effect. Alternatively, we can sample log "p-value" densities according to a beta-uniform mixture model, where the null distribution is uniform and the alternative a mixture of two beta distributions. A third possibility is to sample log odds ratios, where alternative and null distribution are both normal.

Value

For sampleRndNetwork an adjacency matrix, for sampleData a data matrix, for sampleData.BN a data matrix and a linking of effects to signals.

Author(s)

Holger Froehlich, Cordula Zeller

See Also

getDensityMatrix

Examples

	Phi = sampleRndNetwork(paste("S",1:5,sep=""))
	D = sampleData(Phi, 100, type="density")$D	
  if(require(Rgraphviz)){
	  plot(as(transitive.reduction(Phi),"graphNEL"), main="original graph")
	  x11()
	  plot.nem(nem(D, control=set.default.parameters(unique(colnames(D)), type="CONTmLLBayes")), transitiveReduction=TRUE, SCC=FALSE, main    ="inferred graph")
  }

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(nem)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/nem/generateNetwork.Rd_%03d_medium.png", width=480, height=480)
> ### Name: generateNetwork
> ### Title: Random networks and data sampling
> ### Aliases: sampleRndNetwork sampleData sampleData.BN
> ### Keywords: graphs models
> 
> ### ** Examples
> 
> 	Phi = sampleRndNetwork(paste("S",1:5,sep=""))
> 	D = sampleData(Phi, 100, type="density")$D	
>   if(require(Rgraphviz)){
+ 	  plot(as(transitive.reduction(Phi),"graphNEL"), main="original graph")
+ 	  x11()
+ 	  plot.nem(nem(D, control=set.default.parameters(unique(colnames(D)), type="CONTmLLBayes")), transitiveReduction=TRUE, SCC=FALSE, main    ="inferred graph")
+   }
Loading required package: Rgraphviz
Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: grid
Greedy hillclimber for 5 S-genes (lambda = 0 )...

> 
> 
> 
> 
> 
> dev.off()
png 
  2 
>