Description Usage Arguments Details Value See Also Examples
View source: R/main_function.R
Simulate data in two different conditions with a common structure of dependences. The two different conditions are characterized by different strengths of the links between nodes (dysregulation).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
graph |
A graphNEL object. |
path |
A list of edges in edgesList format (see gRbase). |
S |
The sample covariance matrix. |
min, max |
Vectors of length 1 or of the same length as |
prob |
A vector of size 1 or of the same length as path, giving the probability to change the sign of the correlation coefficient for each edge.
|
n1, n2 |
Number of observations to generate from the two conditions. |
digits |
Integer indicating the number of decimal places to be used. |
mu1, mu2 |
A vector of size 1 or of the length equal to the number of nodes in the graph. Means of the multivariate normal distributions from which observations are generated. If |
muRandom |
Logical. If |
If the matrix S does not reflect conditional independence constraints imposed by the graph simPATHy uses the maximum likelihood estimation of covariance matrices for graphical models via internal function fitSgraph.
When the dysregulation of the initial (reference condition) covariance matrix leads to a matrix that is no longer positive definite, the resulting matrix is corrected via internal function makePositiveDefinite.
To avoid excessively strong dysregulations, the upper limit for the absolute value of the dysregulated correlation coefficient is set to:
min( 0.9, 1.25*max(abs(C[upper.tri(C)])) )
where C is the correlation matrix of the reference condition.
It returns a list containing:
data random samples generated from multivariate normal distributions with covariance matrices S1 (reference condition) and S2 (dysregulated condition);
S1,S2 two covariance matrices;
path the dysregulated path;
strength the dysregulation strength for each edge in the path;
mu1,mu2 two mean vectors;
correction correction details.
easyLookDys, easyLookShiny, plotCorGraph, plotGraphNELD3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | if(require(gRbase) & require(graph)){
## Directed graph
## sub-graph Acute Myel... Leukemia
graph<-gRbase::dag(~867:25+867:613+5295:867+5294:867+
+ 207:5295+207:5294+4193:207+3551:207+
+ 4792:3551+7157:4193+3265:6654+
+ 3845:6654+6654:2885+2885:25+2885:613)
genes<-graph::nodes(graph)
# covariance matrix of the reference condition
data<-t(chimera[genes,colnames(chimera)==1])
S<-cov(data)
S<-fitSgraph(graph,S)
# select path to dysregulate
path<-list(c("613","867"),c("867","5295"),c("5295","207"),
c("207","4193"),c("4193","7157"))
## ..or select the path in an interactive plot
# path<-getPathShiny(graph)
# select parameters of the dysregulation
min<-c(2,8,2,0.1,0.5)
max<-c(2,10,2,4,0.5)
prob<-c(1,0,0,0.5,1)
# activation, switch, switch, random, deactivation
dys<-cbind(min,max,prob)
rownames(dys)<-sapply(path,paste,collapse = "~")
dys
set.seed(123)
# main function
Result<-simPATHy(graph,path,S,min,max,prob)
class(Result)
names(Result)
# simulated data from two conditions
round(Result$dataset[c(1:3,501:503),1:5],3)
# Summary
easyLookDys(Result)
# ..or interactive summary
# easyLookShiny(resObj=Result,graph=graph)
# Visualization
plotCorGraph(S1=Result$S1,S2 = Result$S2,graph = graph,path = path,colLim = c(-0.3,0.3))
plotGraphNELD3(S1=Result$S1,S2 = Result$S2,graph = graph,colLim = c(-0.3,0.3))
## Undirected graph
graph <- gRbase::ug(~a:b, ~a:c, ~c:d, ~b:d, ~b:c)
# when reference condition covariance matrix is not supplied simPATHy generate a random one
Result_ug<-simPATHy(graph)
easyLookDys(Result_ug)
plotGraphNELD3(S1=Result_ug$S1,S2 = Result_ug$S2,graph = graph,colLim = c(-0.5,0.5))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.