Detecting differential modules using ALPACA
Megha Padi
2017-10-19
Source:vignettes/ALPACA.Rmd
ALPACA.Rmd
Install and load netZooR package
# install.packages("devtools")
library(devtools)
# install netZooR pkg with vignettes, otherwise remove the "build_vignettes = TRUE" argument.
devtools::install_github("netZoo/netZooR", build_vignettes = TRUE)
This vignettes can be accessed in R by using below line. when netZoooR was installed with arguments “build_vignettes = TRUE”.
vignette("ALPACA",package="netZooR")
We will show how ALPACA can find changes in modular structure between two simulated networks. The networks both have 20 regulator nodes and 80 target nodes. The baseline network consists of two groups that are strongly connected to each other, whereas the perturbed network has weaker connections between the two groups. The two groups consist of nodes {A1-A10,B1-B40} and {A11-A20,B41-B80}. Contrasting the two networks using ALPACA identifies these two groups as being the modules that best characterize the perturbation.
These simulated networks is available in our public AWS S3 bucket. Change the preferred working directory to store the Example_2comm.txt file, otherwise the store directory is current working directory.
system("curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooR/tutorial_datasets/Example_2comm.txt")
simp.mat <- read.table("./Example_2comm.txt",header=TRUE)
simp.alp <- alpaca(simp.mat,NULL,verbose=FALSE)
## [1] "Detecting communities in control network..."
## [1] "modularity of projected graph 0.0236842105263163"
## [1] "Q = 0.0263157894736842"
## [1] "Q = 0.0263157894736842"
## [1] "Computing differential modularity matrix..."
## [1] "Computing differential modules..."
## [1] "Merging 100 communities"
## [1] 1
## [1] 2
## [1] 3
## [1] "Merging 2 communities"
## [1] 1
## [1] "Computing node scores..."
## [1] 1
## [1] 2
simp.alp2 <- simp.alp[[1]]
simp.memb <- as.vector(simp.alp2)
names(simp.memb) <- names(simp.alp2)
simp.memb
## A1_A A2_A A3_A A4_A A5_A A6_A A7_A A8_A A9_A A10_A A11_A A12_A A13_A
## 1 1 1 1 1 1 1 1 1 1 2 2 2
## A14_A A15_A A16_A A17_A A18_A A19_A A20_A B1_B B2_B B3_B B4_B B5_B B6_B
## 2 2 2 2 2 2 2 1 1 1 1 1 1
## B7_B B8_B B9_B B10_B B11_B B12_B B13_B B14_B B15_B B16_B B17_B B18_B B19_B
## 1 1 1 1 1 1 1 1 1 1 1 1 1
## B20_B B21_B B22_B B23_B B24_B B25_B B26_B B27_B B28_B B29_B B30_B B31_B B32_B
## 1 1 1 1 1 1 1 1 1 1 1 1 1
## B33_B B34_B B35_B B36_B B37_B B38_B B39_B B40_B B41_B B42_B B43_B B44_B B45_B
## 1 1 1 1 1 1 1 1 2 2 2 2 2
## B46_B B47_B B48_B B49_B B50_B B51_B B52_B B53_B B54_B B55_B B56_B B57_B B58_B
## 2 2 2 2 2 2 2 2 2 2 2 2 2
## B59_B B60_B B61_B B62_B B63_B B64_B B65_B B66_B B67_B B68_B B69_B B70_B B71_B
## 2 2 2 2 2 2 2 2 2 2 2 2 2
## B72_B B73_B B74_B B75_B B76_B B77_B B78_B B79_B B80_B
## 2 2 2 2 2 2 2 2 2