/
README.Rmd
601 lines (454 loc) · 23.2 KB
/
README.Rmd
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dpi=300,fig.width=7,
fig.keep="all"
)
```
# Patterns <img src="man/figures/logo.png" align="right" width="200"/>
# A modeling tool dedicated to biological network modeling to decipher Biological Networks with Patterned Heterogeneous (e.g. multiOmics) Measurements
## Frédéric Bertrand and Myriam Maumy-Bertrand
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-green.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![R-CMD-check](https://github.com/fbertran/Patterns/workflows/R-CMD-check/badge.svg)](https://github.com/fbertran/Patterns/actions)
[![Codecov test coverage](https://codecov.io/gh/fbertran/Patterns/branch/master/graph/badge.svg)](https://app.codecov.io/gh/fbertran/Patterns?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/Patterns)](https://cran.r-project.org/package=Patterns)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/Patterns)](https://cran.r-project.org/package=Patterns)
[![GitHub Repo stars](https://img.shields.io/github/stars/fbertran/Patterns?style=social)](https://github.com/fbertran/Patterns)
[![DOI](https://zenodo.org/badge/18441799.svg)](https://zenodo.org/badge/latestdoi/18441799)
<!-- badges: end -->
It is designed to work with **patterned data**. Famous examples of problems related to patterned data are:
* recovering **signals** in networks after a **stimulation** (cascade network reverse engineering),
* analysing **periodic signals**.
It allows for **single** or **joint modeling** of, for instance, genes and proteins.
* It starts with the **selection of the actors** that will be the used in the reverse engineering upcoming step. An actor can be included in that selection based on its **differential effects** (for instance gene expression or protein abundance) or on its **time course profile**.
* Wrappers for **actors clustering** functions and cluster analysis are provided.
* It also allows **reverse engineering** of biological networks taking into account the observed time course patterns of the actors. Interactions between clusters of actors can be set by the user. Any number of clusters can be activated at a single time.
* Many **inference functions** are provided with the `Patterns` package and dedicated to get **specific features** for the inferred network such as **sparsity**, **robust links**, **high confidence links** or **stable through resampling links**.
+ **lasso**, from the `lars` package
+ **lasso**, from the `glmnet` package. An unweighted and a weighted version of the algorithm are available
+ **spls**, from the `spls` package
+ **elasticnet**, from the `elasticnet` package
+ **stability selection**, from the `c060` package implementation of stability selection
+ **weighted stability selection**, a new weighted version of the `c060` package implementation of stability selection that I created for the package
+ **robust**, lasso from the `lars` package with light random Gaussian noise added to the explanatory variables
+ **selectboost**, from the `selectboost` package. The selectboost algorithm looks for the more stable links against resampling that takes into account the correlated structure of the predictors
+ **weighted selectboost**, a new weighted version of the `selectboost`.
* Some **simulation** and **prediction** tools are also available for cascade networks.
* Examples of use with microarray or RNA-Seq data are provided.
The weights are viewed as a penalty factors in the penalized regression model: it is a number that multiplies the lambda value in the minimization problem to allow differential shrinkage, [Friedman et al. 2010](https://github.com/fbertran/Patterns/raw/master/add_data/glmnet.pdf), equation 1 page 3. If equal to 0, it implies no shrinkage, and that variable is always included in the model. Default is 1 for all variables. Infinity means that the variable is excluded from the model. Note that the weights are rescaled to sum to the number of variables.
A word for those that have been using our seminal work, the `Cascade` package that we created several years ago and that was a very efficient network reverse engineering tool for cascade networks
(Jung, N., Bertrand, F., Bahram, S., Vallat, L., and Maumy-Bertrand, M. (2014), <https://doi.org/10.1093/bioinformatics/btt705>, <https://cran.r-project.org/package=Cascade>, <https://github.com/fbertran/Cascade> and <https://fbertran.github.io/Cascade/>).
The `Patterns` package is more than (at least) a threeway major extension of the `Cascade` package :
* **any number of groups** can be used whereas in the `Cascade` package only 1 group for each timepoint could be created, which prevented the users to create homogeneous clusters of genes in datasets that featured more than a few dozens of genes.
* **custom** $F$ matrices shapes whereas in the `Cascade` package only 1 shape was provided:
+ interaction between groups
+ custom design of inner cells of the $F$ matrix
* the custom $F$ matrices allow to deal with **heteregeneous networks** with several kinds of actors such as mixing genes and proteins in a single network to perform **joint inference**.
* about **nine inference algorithms** are provided, whereas 1 (lasso) in `Cascade`.
Hence the `Patterns` package should be viewed more as a completely new modelling tools than as an extension of the `Cascade` package.
This website and these examples were created by F. Bertrand and M. Maumy-Bertrand.
## Installation
You can install the released version of Patterns from [CRAN](https://CRAN.R-project.org) with:
```{r, eval = FALSE}
install.packages("Patterns")
```
You can install the development version of Patterns from [github](https://github.com) with:
```{r, eval = FALSE}
devtools::install_github("fbertran/Patterns")
```
## Examples
### Data management
Import Cascade Data (repeated measurements on several subjects) from the CascadeData package and turn them into a omics array object. The second line makes sure the CascadeData package is installed.
```{r loadpackage, message=FALSE, warning=FALSE, cache=FALSE}
library(Patterns)
```
```{r omicsarrayclass, message=FALSE, warning=FALSE}
if(!require(CascadeData)){install.packages("CascadeData")}
data(micro_US)
micro_US<-as.omics_array(micro_US[1:100,],time=c(60,90,210,390),subject=6)
str(micro_US)
```
Get a summay and plots of the data:
```{r plotomicsarrayclass, fig.keep='all', cache=TRUE}
summary(micro_US)
plot(micro_US)
```
### Gene selection
There are several functions to carry out gene selection before the inference. They are detailed in the vignette of the package.
### Data simulation
Let's simulate some cascade data and then do some reverse engineering.
We first design the F matrix for $T_i=4$ times and $Ngrp=4$ groups. The `Fmat`object is an array of sizes $(T_i,T-i,Ngrp^2)=(4,4,16)$.
```{r createF}
Ti<-4
Ngrp<-4
Fmat=array(0,dim=c(Ti,Ti,Ngrp^2))
for(i in 1:(Ti^2)){
if(((i-1) %% Ti) > (i-1) %/% Ti){
Fmat[,,i][outer(1:Ti,1:Ti,function(x,y){0<(x-y) & (x-y)<2})]<-1
}
}
```
The `Patterns` function `CascadeFinit` is an utility function to easily define such an F matrix.
```{r CascadeInit}
Fbis=Patterns::CascadeFinit(Ti,Ngrp,low.trig=FALSE)
str(Fbis)
```
Check if the two matrices `Fmat` and `Fbis` are identical.
```{r CascadeInitCheck}
print(all(Fmat==Fbis))
```
End of F matrix definition.
```{r CascadeFinalize}
Fmat[,,3]<-Fmat[,,3]*0.2
Fmat[3,1,3]<-1
Fmat[4,2,3]<-1
Fmat[,,4]<-Fmat[,,3]*0.3
Fmat[4,1,4]<-1
Fmat[,,8]<-Fmat[,,3]
```
We set the seed to make the results reproducible and draw a scale free random network.
```{r randomN}
set.seed(1)
Net<-Patterns::network_random(
nb=100,
time_label=rep(1:4,each=25),
exp=1,
init=1,
regul=round(rexp(100,1))+1,
min_expr=0.1,
max_expr=2,
casc.level=0.4
)
Net@F<-Fmat
str(Net)
```
Plot the simulated network.
```{r plotnet1}
Patterns::plot(Net, choice="network")
```
If a gene clustering is known, it can be used as a coloring scheme.
```{r plotnet2}
plot(Net, choice="network", gr=rep(1:4,each=25))
```
Plot the F matrix, for low dimensional F matrices.
```{r plotF}
plot(Net, choice="F")
```
Plot the F matrix using the `pixmap` package, for high dimensional F matrices.
```{r plotFpixmap}
plot(Net, choice="Fpixmap")
```
We simulate gene expression according to the network that was previously drawn
```{r genesimul, message=FALSE, warning=FALSE}
set.seed(1)
M <- Patterns::gene_expr_simulation(
network=Net,
time_label=rep(1:4,each=25),
subject=5,
peak_level=200,
act_time_group=1:4)
str(M)
```
Get a summay and plots of the simulated data:
```{r summarysimuldata, cache=TRUE}
summary(M)
```
```{r plotsimuldata, fig.keep='all', cache=TRUE}
plot(M)
```
### Network inferrence
We infer the new network using subjectwise leave one out cross-validation (default setting): all measurements from the same subject are removed from the dataset). The inference is carried out with a general Fshape.
```{r netinfdefault, cache=TRUE}
Net_inf_P <- Patterns::inference(M, cv.subjects=TRUE)
```
Plot of the inferred F matrix
```{r Fresults}
plot(Net_inf_P, choice="F")
```
Heatmap of the inferred coefficients of the Omega matrix
```{r heatresults}
stats::heatmap(Net_inf_P@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
Default values fot the $F$ matrices. The `Finit` matrix (starting values for the algorithm). In our case, the `Finit`object is an array of sizes $(T_i,T-i,Ngrp^2)=(4,4,16)$.
```{r Finitshow}
Ti<-4;
ngrp<-4
nF<-ngrp^2
Finit<-array(0,c(Ti,Ti,nF))
for(ii in 1:nF){
if((ii%%(ngrp+1))==1){
Finit[,,ii]<-0
} else {
Finit[,,ii]<-cbind(rbind(rep(0,Ti-1),diag(1,Ti-1)),rep(0,Ti))+rbind(cbind(rep(0,Ti-1),diag(1,Ti-1)),rep(0,Ti))
}
}
```
The `Fshape` matrix (default shape for `F` matrix the algorithm). Any interaction between groups and times are permitted except the retro-actions (a group on itself, or an action at the same time for an actor on another one).
```{r Fshapeshow}
Fshape<-array("0",c(Ti,Ti,nF))
for(ii in 1:nF){
if((ii%%(ngrp+1))==1){
Fshape[,,ii]<-"0"
} else {
lchars <- paste("a",1:(2*Ti-1),sep="")
tempFshape<-matrix("0",Ti,Ti)
for(bb in (-Ti+1):(Ti-1)){
tempFshape<-replaceUp(tempFshape,matrix(lchars[bb+Ti],Ti,Ti),-bb)
}
tempFshape <- replaceBand(tempFshape,matrix("0",Ti,Ti),0)
Fshape[,,ii]<-tempFshape
}
}
```
Any other form can be used. A "0" coefficient is missing from the model. It allows testing the best structure of an "F" matrix and even performing some significance tests of hypothses on the structure of the $F$ matrix.
The `IndicFshape` function allows to design custom F matrix for cascade networks with equally spaced measurements by specifying the zero and non zero $F_{ij}$ cells of the $F$ matrix. It is useful for models featuring several clusters of actors that are activated at the time. Let's define the following indicatrix matrix (action of all groups on each other, which is not a possible real modeling setting and is only used as an example):
```{r Fshapeothershow}
TestIndic=matrix(!((1:(Ti^2))%%(ngrp+1)==1),byrow=TRUE,ngrp,ngrp)
TestIndic
```
For that choice, we get those init and shape $F$ matrices.
```{r Fshapeothershow2}
IndicFinit(Ti,ngrp,TestIndic)
IndicFshape(Ti,ngrp,TestIndic)
```
Those $F$ matrices are lower diagonal ones to enforce that an observed value at a given time can only be predicted by a value that was observed in the past only (i.e. neither at the same moment or in the future).
The `plotF` is convenient to display F matrices. Here are the the displays of the three $F$ matrices we have just introduced.
```{r plotfshape1}
plotF(Fshape,choice="Fshape")
```
```{r plotfshape2}
plotF(CascadeFshape(4,4),choice="Fshape")
```
```{r plotfshape3}
plotF(IndicFshape(Ti,ngrp,TestIndic),choice="Fshape")
```
We now fit the model with an $F$ matrix that is designed for cascade networks.
Specific Fshape
```{r netinfLC, cache=TRUE}
Net_inf_P_S <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4))
```
Plot of the inferred F matrix
```{r FresultsLC}
plot(Net_inf_P_S, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network. They reflect the use of a special $F$ matrix. It is an example of an F matrix specifically designed to deal with cascade networks.
```{r heatresultsLC}
stats::heatmap(Net_inf_P_S@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
There are many fitting functions provided with the `Patterns` package in order to search for **specific features** for the inferred network such as **sparsity**, **robust links**, **high confidence links** or **stable through resampling links**. :
* **LASSO**, from the `lars` package
* **LASSO2**, from the `glmnet` package. An unweighted and a weighted version of the algorithm are available
* **SPLS**, from the `spls` package
* **ELASTICNET**, from the `elasticnet` package
* **stability.c060**, from the `c060` package implementation of stability selection
* **stability.c060.weighted**, a new weighted version of the `c060` package implementation of stability selection
* **robust**, lasso from the `lars` package with light random Gaussian noise added to the explanatory variables
* **selectboost.weighted**, a new weighted version of the `selectboost` package implementation of the selectboost algorithm to look for the more stable links against resampling that takes into account the correlated structure of the predictors. If no weights are provided, equal weigths are for all the variables (=non weighted case).
```{r netinflasso2, cache=TRUE}
Net_inf_P_Lasso2 <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="LASSO2")
```
Plot of the inferred F matrix
```{r Fresultslasso2}
plot(Net_inf_P_Lasso2, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultslasso2}
stats::heatmap(Net_inf_P_Lasso2@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
We create a weighting vector to perform weighted lasso inference.
```{r netinfPriors}
Weights_Net=slot(Net,"network")
Weights_Net[Net@network!=0]=.1
Weights_Net[Net@network==0]=1000
```
```{r netinflasso2Weighted, cache=TRUE}
Net_inf_P_Lasso2_Weighted <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="LASSO2", priors=Weights_Net)
```
Plot of the inferred F matrix
```{r Fresultslasso2Weighted}
plot(Net_inf_P_Lasso2_Weighted, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultslasso2Weighted}
stats::heatmap(Net_inf_P_Lasso2_Weighted@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
```{r netinfSPLS, cache=TRUE}
Net_inf_P_SPLS <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="SPLS")
```
Plot of the inferred F matrix
```{r FresultsSPLS}
plot(Net_inf_P_SPLS, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultsSPLS}
stats::heatmap(Net_inf_P_SPLS@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
```{r netinfEN, cache=TRUE}
Net_inf_P_ELASTICNET <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="ELASTICNET")
```
Plot of the inferred F matrix
```{r FresultsEN}
plot(Net_inf_P_ELASTICNET, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultsEN}
stats::heatmap(Net_inf_P_ELASTICNET@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
```{r netinfStab, cache=TRUE}
Net_inf_P_stability <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="stability.c060")
```
Plot of the inferred F matrix
```{r FresultsStab}
plot(Net_inf_P_stability, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultsStab}
stats::heatmap(Net_inf_P_stability@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
```{r netinfStabWeight, cache=TRUE}
Net_inf_P_StabWeight <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="stability.c060.weighted", priors=Weights_Net)
```
Plot of the inferred F matrix
```{r FresultsStabWeight}
plot(Net_inf_P_StabWeight, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultsStabWeight}
stats::heatmap(Net_inf_P_StabWeight@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
```{r netinfRobust, cache=TRUE}
Net_inf_P_Robust <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="robust")
```
Plot of the inferred F matrix
```{r FresultsRobust}
plot(Net_inf_P_Robust, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultsRobust}
stats::heatmap(Net_inf_P_Robust@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
```{r netinfSB, cache=TRUE}
Weights_Net_1 <- Weights_Net
Weights_Net_1[,] <- 1
Net_inf_P_SelectBoost <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="selectboost.weighted",priors=Weights_Net_1)
```
```{r reloadPatternsSB, eval=TRUE, echo=FALSE}
detach("package:Patterns", unload=TRUE)
library(Patterns)
```
Plot of the inferred F matrix
```{r FresultsSB}
plot(Net_inf_P_SelectBoost, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultsSB}
stats::heatmap(Net_inf_P_SelectBoost@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
```{r netinfSBW, cache=TRUE}
Net_inf_P_SelectBoostWeighted <- Patterns::inference(M, Finit=CascadeFinit(4,4), Fshape=CascadeFshape(4,4), fitfun="selectboost.weighted",priors=Weights_Net)
```
```{r reloadPatternsSBW, eval=TRUE, echo=FALSE}
detach("package:Patterns", unload=TRUE)
library(Patterns)
```
Plot of the inferred F matrix
```{r FresultsSBW, message=TRUE, warning=FALSE}
plot(Net_inf_P_SelectBoostWeighted, choice="F")
```
Heatmap of the coefficients of the Omega matrix of the network
```{r heatresultsSBW}
stats::heatmap(Net_inf_P_SelectBoostWeighted@network, Rowv = NA, Colv = NA, scale="none", revC=TRUE)
```
### Post inference network analysis
Such an analysis is only required if the model was not fitted using the stability selection or the selectboost algorithm.
Create an animation of the network with increasing cutoffs with an animated .gif format or a html webpage in the working directory.
```{r evolutation, warning=FALSE, eval=FALSE}
data(network)
sequence<-seq(0,0.2,length.out=20)
evolution(network,sequence,type.ani = "gif", outdir=getwd())
evolution(network,sequence,type.ani = "html", outdir=getwd())
```
```{r evolutationpkgdown, echo=FALSE, warning=FALSE, eval=TRUE, echo=FALSE}
data(network)
sequence<-seq(0,0.2,length.out=20)
#try(if(pkgdown::in_pkgdown()){destdir = "~/Github/Patterns/docs/reference/evolution/"})
destdir = "~/Github/Patterns/docs/reference/evolution/"
evolution(network,sequence,type.ani = "gif",outdir=destdir)
evolution(network,sequence,type.ani = "html",outdir=destdir)
```
![Evolution as .gif.](https://fbertran.github.io/Patterns/reference/evolution/animation.gif)
[Evolution as .html.](https://fbertran.github.io/Patterns/reference/evolution/index.html)
Evolution of some properties of a reverse-engineered network with increasing cut-off values.
![Evolution of some properties of a reverse-engineered network with increasing cut-off values.](https://fbertran.github.io/Patterns/reference/compare-methods-1.png)
We switch to data that were derived from the inferrence of a real biological network and try to detect the optimal cutoff value: the best cutoff value for a network to fit a scale free network. The `cutoff` was validated only single group cascade networks (number of actors groups = number of timepoints) and for genes dataset. Instead of the `cutoff` function, manual curation or the stability selection or the selectboost algorithm should be used.
```{r cutoff, cache=TRUE}
data("networkCascade")
set.seed(1)
cutoff(networkCascade)
```
Analyze the network with a cutoff set to the previouly found 0.133 optimal value.
```{r analyzenet, warning=FALSE, cache=TRUE}
analyze_network(networkCascade,nv=0.133)
```
```{r plotnet, warning=FALSE}
data(Selection)
plot(networkCascade,nv=0.133, gr=Selection@group)
```
### Perform gene selection
Import data.
```{r omicsselection, warning=FALSE}
library(Patterns)
library(CascadeData)
data(micro_S)
micro_S<-as.omics_array(micro_S,time=c(60,90,210,390),subject=6,gene_ID=rownames(micro_S))
data(micro_US)
micro_US<-as.omics_array(micro_US,time=c(60,90,210,390),subject=6,gene_ID=rownames(micro_US))
```
Select early genes (t1 or t2):
```{r omicsselection1, warning=FALSE, cache=TRUE}
Selection1<-geneSelection(x=micro_S,y=micro_US,20,wanted.patterns=rbind(c(0,1,0,0),c(1,0,0,0),c(1,1,0,0)))
```
Section genes with first significant differential expression at t1:
```{r omicsselection2, warning=FALSE, cache=TRUE}
Selection2<-geneSelection(x=micro_S,y=micro_US,20,peak=1)
```
Section genes with first significant differential expression at t2:
```{r omicsselection3, warning=FALSE, cache=TRUE}
Selection3<-geneSelection(x=micro_S,y=micro_US,20,peak=2)
```
Select later genes (t3 or t4)
```{r omicsselection4, warning=FALSE, cache=TRUE}
Selection4<-geneSelection(x=micro_S,y=micro_US,50,
wanted.patterns=rbind(c(0,0,1,0),c(0,0,0,1),c(1,1,0,0)))
```
Merge those selections:
```{r omicsselection5, warning=FALSE}
Selection<-unionOmics(Selection1,Selection2)
Selection<-unionOmics(Selection,Selection3)
Selection<-unionOmics(Selection,Selection4)
head(Selection)
```
Summarize the final selection:
```{r omicsselection6, warning=FALSE}
summary(Selection)
```
Plot the final selection:
```{r omicsselection7, warning=FALSE}
plot(Selection)
```
This process could be improved by retrieve a real gene_ID using the `bitr` function of the `ClusterProfiler` package or by performing independent filtering using `jetset` package to only keep at most only probeset (the best one, if there is one good enough) per gene_ID.
### Examples of outputs
![Infered F matrix of the network (General shape).](https://fbertran.github.io/Patterns/reference/figures/README-Fresults-1.png)
![Infered coefficient matrix of the network (General shape).](https://fbertran.github.io/Patterns/reference/figures/README-heatresults-1.png)
![Infered F matrix of the network (cascade shape).](https://fbertran.github.io/Patterns/reference/figures/README-FresultsLC-1.png)
![Infered coefficient matrix of the network (cascade shape).](https://fbertran.github.io/Patterns/reference/figures/README-heatresultsLC-1.png)
![Reverse-engineered network.](https://fbertran.github.io/Patterns/reference/figures/README-plotnet2-1.png)
![Evolution of a reverse-engineered network with increasing cut-off values.](https://fbertran.github.io/Patterns/reference/evolution/animation.gif)
![Plot of simulated data for cascade networks featuring cluster membership.](https://fbertran.github.io/Patterns/reference/figures/README-plotsimuldata-1.png)
![Plot of simulated data for cascade networks featuring subject membership.](https://fbertran.github.io/Patterns/reference/figures/README-plotsimuldata-2.png)