|
12 | 12 | },
|
13 | 13 | {
|
14 | 14 | "cell_type": "markdown",
|
15 |
| - "metadata": { |
16 |
| - "lines_to_next_cell": 0 |
17 |
| - }, |
| 15 | + "metadata": {}, |
| 16 | + "source": [ |
| 17 | + "# Introduction\n", |
| 18 | + "\n", |
| 19 | + "ALtered Partitions Across Community Architectures (ALPACA)<sup>1</sup> is a method that allows to compare a case and a control network by finding differences in their community structure. In this vignette, we will explore the structure of the input data to ALPACA and the interpretation of the output." |
| 20 | + ] |
| 21 | + }, |
| 22 | + { |
| 23 | + "cell_type": "markdown", |
| 24 | + "metadata": {}, |
18 | 25 | "source": [
|
19 |
| - "Install and load netZooR package" |
| 26 | + "You need to set the `runserver` parameter to 1, if you're running this vignette on the server. Otherwise, if the vignette is ran locally this parameter has to be set to 0." |
20 | 27 | ]
|
21 | 28 | },
|
22 | 29 | {
|
23 | 30 | "cell_type": "code",
|
24 | 31 | "execution_count": null,
|
25 |
| - "metadata": { |
26 |
| - "eval": false |
27 |
| - }, |
| 32 | + "metadata": {}, |
28 | 33 | "outputs": [],
|
29 | 34 | "source": [
|
30 |
| - "# install.packages(\"devtools\") \n", |
31 |
| - "#library(devtools)\n", |
32 |
| - "# install netZooR pkg with vignettes, otherwise remove the \"build_vignettes = TRUE\" argument.\n", |
33 |
| - "#devtools::install_github(\"netZoo/netZooR\", build_vignettes = TRUE)" |
| 35 | + "runserver=1" |
| 36 | + ] |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "markdown", |
| 40 | + "metadata": {}, |
| 41 | + "source": [ |
| 42 | + "if you're running this vignette locally, you need to install ALPACA through the netZooR package by running the following lines." |
34 | 43 | ]
|
35 | 44 | },
|
36 | 45 | {
|
37 | 46 | "cell_type": "code",
|
38 | 47 | "execution_count": null,
|
39 |
| - "metadata": { |
40 |
| - "message": false, |
41 |
| - "warning": false |
42 |
| - }, |
| 48 | + "metadata": {}, |
43 | 49 | "outputs": [],
|
44 | 50 | "source": [
|
45 |
| - "library(netZooR)" |
| 51 | + "if (runserver==0){\n", |
| 52 | + " is_netZooR_available <- require(\"netZooR\")\n", |
| 53 | + " if (is_netZooR_available==0){\n", |
| 54 | + " install.packages(\"remotes\") \n", |
| 55 | + " library(remotes)\n", |
| 56 | + " remotes::install_github(\"netZoo/netZooR\", build_vignettes = TRUE)\n", |
| 57 | + " }\n", |
| 58 | + " ppath=''\n", |
| 59 | + "}else{\n", |
| 60 | + " ppath='/opt/data/'\n", |
| 61 | + "}" |
46 | 62 | ]
|
47 | 63 | },
|
48 | 64 | {
|
49 | 65 | "cell_type": "markdown",
|
50 |
| - "metadata": { |
51 |
| - "lines_to_next_cell": 0 |
52 |
| - }, |
| 66 | + "metadata": {}, |
53 | 67 | "source": [
|
54 |
| - "This vignettes can be accessed in R by using below line. when netZoooR was installed with arguments *\"build_vignettes = TRUE\"*." |
| 68 | + "Then, we need to load the `netZooR` package to use ALPACA." |
55 | 69 | ]
|
56 | 70 | },
|
57 | 71 | {
|
58 | 72 | "cell_type": "code",
|
59 | 73 | "execution_count": null,
|
60 |
| - "metadata": { |
61 |
| - "eval": false |
62 |
| - }, |
| 74 | + "metadata": {}, |
63 | 75 | "outputs": [],
|
64 | 76 | "source": [
|
65 |
| - "#vignette(\"ALPACA\",package=\"netZooR\")" |
| 77 | + "library(netZooR)" |
66 | 78 | ]
|
67 | 79 | },
|
68 | 80 | {
|
|
74 | 86 | "## A simple example with two node groups\n",
|
75 | 87 | "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.\n",
|
76 | 88 | "\n",
|
77 |
| - "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." |
| 89 | + "These simulated networks are available in netbooks public AWS S3 bucket (s3://netzoo). Change the preferred working directory to store the Example_2comm.txt file, otherwise the store directory is current working directory.\n", |
| 90 | + "\n", |
| 91 | + "If you are running the netbook locally, please run the following command line to download the file from AWS." |
| 92 | + ] |
| 93 | + }, |
| 94 | + { |
| 95 | + "cell_type": "code", |
| 96 | + "execution_count": null, |
| 97 | + "metadata": {}, |
| 98 | + "outputs": [], |
| 99 | + "source": [ |
| 100 | + "if (runserver==0){\n", |
| 101 | + " system(\"curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooR/tutorial_datasets/Example_2comm.txt\")\n", |
| 102 | + "}" |
| 103 | + ] |
| 104 | + }, |
| 105 | + { |
| 106 | + "cell_type": "markdown", |
| 107 | + "metadata": {}, |
| 108 | + "source": [ |
| 109 | + "On the server, the file can be loaded as follows:" |
78 | 110 | ]
|
79 | 111 | },
|
80 | 112 | {
|
|
85 | 117 | },
|
86 | 118 | "outputs": [],
|
87 | 119 | "source": [
|
88 |
| - "#system(\"curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooR/tutorial_datasets/Example_2comm.txt\")\n", |
89 |
| - "simp.mat <- read.table(\"/opt/data/Example_2comm.txt\",header=T) " |
| 120 | + "simp.mat <- read.table(paste0(ppath,\"Example_2comm.txt\"),header=T) \n", |
| 121 | + "simp.mat" |
| 122 | + ] |
| 123 | + }, |
| 124 | + { |
| 125 | + "cell_type": "markdown", |
| 126 | + "metadata": {}, |
| 127 | + "source": [ |
| 128 | + "The input to ALPACA `simp.mat` in this case is a 4-column dataframe that include:\n", |
| 129 | + "- Source nodes in column 1 (TFs)\n", |
| 130 | + "- Target nodes in column 2 (Genes)\n", |
| 131 | + "- Edge weight in control network (network 1)\n", |
| 132 | + "- Edge weight in case network (network 2)\n", |
| 133 | + "\n", |
| 134 | + "Now, we can run ALPACA on these 2 networks" |
| 135 | + ] |
| 136 | + }, |
| 137 | + { |
| 138 | + "cell_type": "code", |
| 139 | + "execution_count": null, |
| 140 | + "metadata": {}, |
| 141 | + "outputs": [], |
| 142 | + "source": [ |
| 143 | + "simp.alp <- alpaca(simp.mat,NULL,verbose=F)\n", |
| 144 | + "simp.alp" |
| 145 | + ] |
| 146 | + }, |
| 147 | + { |
| 148 | + "cell_type": "markdown", |
| 149 | + "metadata": {}, |
| 150 | + "source": [ |
| 151 | + "The result list `simp.alp` contains 2 slots. The first one is a community assignement for each node and the second one is a modularity score for each node, which indicates the contribution of each node to the modularity of the community that it belongs to. \n", |
| 152 | + "In the first slot, the node are not labeled, therefore, we need to label them as follows" |
90 | 153 | ]
|
91 | 154 | },
|
92 | 155 | {
|
|
99 | 162 | },
|
100 | 163 | "outputs": [],
|
101 | 164 | "source": [
|
102 |
| - "simp.alp <- alpaca(simp.mat,NULL,verbose=F)\n", |
103 | 165 | "simp.alp2 <- simp.alp[[1]]\n",
|
104 | 166 | "simp.memb <- as.vector(simp.alp2)\n",
|
105 | 167 | "names(simp.memb) <- names(simp.alp2)\n",
|
106 |
| - "\n", |
107 | 168 | "simp.memb"
|
108 | 169 | ]
|
| 170 | + }, |
| 171 | + { |
| 172 | + "cell_type": "markdown", |
| 173 | + "metadata": {}, |
| 174 | + "source": [ |
| 175 | + "`simp.memb` has the labeled node memberships, for example `A1` belongs to community 1 and `A19` belongs to community 2." |
| 176 | + ] |
| 177 | + }, |
| 178 | + { |
| 179 | + "cell_type": "markdown", |
| 180 | + "metadata": {}, |
| 181 | + "source": [ |
| 182 | + "# References\n", |
| 183 | + "\n", |
| 184 | + "1- Padi, Megha, and John Quackenbush. \"Detecting phenotype-driven transitions in regulatory network structure.\" NPJ systems biology and applications 4.1 (2018): 1-12." |
| 185 | + ] |
109 | 186 | }
|
110 | 187 | ],
|
111 | 188 | "metadata": {
|
|
125 | 202 | "mimetype": "text/x-r-source",
|
126 | 203 | "name": "R",
|
127 | 204 | "pygments_lexer": "r",
|
128 |
| - "version": "3.6.2" |
| 205 | + "version": "4.1.1" |
129 | 206 | }
|
130 | 207 | },
|
131 | 208 | "nbformat": 4,
|
|
0 commit comments