|
179 | 179 | "source": [
|
180 | 180 | "## 1.2. Data Sources\n",
|
181 | 181 | "\n",
|
182 |
| - "PANDA<sup>1</sup> builds a gene regulatory network by integrating three sources of data: 1) TF motif data, 2) TF PPI network , and 3) gene expression data.\n", |
| 182 | + "PANDA<sup>1</sup> builds a gene regulatory network by integrating three sources of data: 1) TF motif data, 2) TF PPI network , and 3) gene expression data. \n", |
183 | 183 | "\n",
|
184 | 184 | "### Motif data\n",
|
185 |
| - "An example specie-sepcific PANDA-ready transcription factor binding motif data is included in the netZooR package, which are derived from motif scan and motif info files located on https://sites.google.com/a/channing.harvard.edu/kimberlyglass/tools/resourcesby.\n", |
| 185 | + "An example specie-sepcific PANDA-ready transcription factor binding motif data is included in the netZooR package, which are derived from motif scan and motif info files located on https://sites.google.com/a/channing.harvard.edu/kimberlyglass/tools/resourcesby. Motif data is a data frame that contains three columns: 1) TF (source node), 2) Gene (target node), and 3) weight is binary (0/1) value to indicate the presence of a TF motif in the promoter region of the target egen.\n", |
186 | 186 | "\n",
|
187 | 187 | "### PPI\n",
|
188 | 188 | "This package includes a function `source.PPI` to build a Protein-Protein Interactions (PPI) througt STRING database given a list of proteins of interest. The [STRINGdb](http://www.bioconductor.org/packages/release/bioc/html/STRINGdb.html) is already loaded while loading netZooR."
|
|
201 | 201 | "motif <- read.table(motif_file_path, sep=\"\\t\")\n",
|
202 | 202 | "# create a data frame with the TF column\n",
|
203 | 203 | "TF <- data.frame(motif[,1])\n",
|
204 |
| - "PPI <- source.PPI(TF, STRING.version=\"10\", species.index=83332, score_threshold=0)" |
| 204 | + "PPI <- source.PPI(TF, STRING.version=\"10\", species.index=83332, score_threshold=0)\n", |
| 205 | + "PPI" |
| 206 | + ] |
| 207 | + }, |
| 208 | + { |
| 209 | + "cell_type": "markdown", |
| 210 | + "metadata": {}, |
| 211 | + "source": [ |
| 212 | + "PPI data has three columns: 1) source node (TF), 2) target node (TF), 3) weight which a value between and 0 and 1 that indicates the strength of connection between these 2 TFs." |
205 | 213 | ]
|
206 | 214 | },
|
207 | 215 | {
|
|
218 | 226 | },
|
219 | 227 | "source": [
|
220 | 228 | "We will use TB example datasets that are integrated in netZooR package.\n",
|
221 |
| - "In this application, we will build a case and control network using 2 gene expression dataset, one transcription factor binding motifs dataset, and one protein-protein interaction datasets from the netZooR package or they can be fetched through AWS.\n", |
| 229 | + "In this application, we will build a case and control network using 2 gene expression dataset, one transcription factor binding motifs dataset, and one protein-protein interaction datasets from the netZooR package. This data can also be fetched through AWS.\n", |
222 | 230 | "\n",
|
223 | 231 | "Using the data in the package, we need to specify the file path of these files as follows:"
|
224 | 232 | ]
|
|
233 | 241 | "treated_expression_file_path <- system.file(\"extdata\", \"expr4.txt\", package = \"netZooR\", mustWork = TRUE)\n",
|
234 | 242 | "control_expression_file_path <- system.file(\"extdata\", \"expr10.txt\", package = \"netZooR\", mustWork = TRUE)\n",
|
235 | 243 | "motif_file_path <- system.file(\"extdata\", \"chip.txt\", package = \"netZooR\", mustWork = TRUE)\n",
|
236 |
| - "ppi_file_path <- system.file(\"extdata\", \"ppi.txt\", package = \"netZooR\", mustWork = TRUE)" |
| 244 | + "ppi_file_path <- system.file(\"extdata\", \"ppi.txt\", package = \"netZooR\", mustWork = TRUE)" |
237 | 245 | ]
|
238 | 246 | },
|
239 | 247 | {
|
|
242 | 250 | "lines_to_next_cell": 0
|
243 | 251 | },
|
244 | 252 | "source": [
|
245 |
| - "or, they can be downloaded to working directory from AWS." |
| 253 | + "They can be downloaded to working directory from AWS." |
246 | 254 | ]
|
247 | 255 | },
|
248 | 256 | {
|
|
252 | 260 | "outputs": [],
|
253 | 261 | "source": [
|
254 | 262 | "if (runserver==0){\n",
|
| 263 | + " # case gene expression\n", |
255 | 264 | " system(\"curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooR/example_datasets/expr4.txt\")\n",
|
| 265 | + " # control gene expression\n", |
256 | 266 | " system(\"curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooR/example_datasets/expr10.txt\")\n",
|
| 267 | + " # motif data\n", |
257 | 268 | " system(\"curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooR/example_datasets/chip.txt\")\n",
|
| 269 | + " # PPI data\n", |
258 | 270 | " system(\"curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooR/example_datasets/ppi.txt\")\n",
|
259 | 271 | "}"
|
260 | 272 | ]
|
|
277 | 289 | "treated_expression_file_path <- paste0(ppath,\"expr4.txt\")\n",
|
278 | 290 | "control_expression_file_path <- paste0(ppath,\"expr10.txt\")\n",
|
279 | 291 | "motif_file_path <- paste0(ppath,\"chip.txt\")\n",
|
280 |
| - "ppi_file_path <- paste0(ppath,\"ppi.txt\")" |
| 292 | + "ppi_file_path <- paste0(ppath,\"ppi.txt\")" |
281 | 293 | ]
|
282 | 294 | },
|
283 | 295 | {
|
|
288 | 300 | "source": [
|
289 | 301 | "# 3. PANDA algorithm\n",
|
290 | 302 | "\n",
|
291 |
| - "Then, we assign the file paths defined previously in the PANDA call to \"expression dataset\", \"motif dataset\", and \"PPI\" dataset. Then we set option `rm_missing` to `TRUE` to remove TFs and genes that are not present in all three inputs.\n", |
| 303 | + "Then, we assign the file paths defined previously in the PANDA call to `expr_file`, `motif_file`, and `ppi_file` arguments. Then we set option `rm_missing` to `TRUE` to remove TFs and genes that are not present in all three inputs.\n", |
292 | 304 | "\n",
|
293 |
| - "We do this operation for both case and control networks. " |
| 305 | + "We do this operation for both case and control networks. First with the case network" |
294 | 306 | ]
|
295 | 307 | },
|
296 | 308 | {
|
|
304 | 316 | },
|
305 | 317 | "outputs": [],
|
306 | 318 | "source": [
|
307 |
| - "treated_all_panda_result <- panda.py(expr_file = treated_expression_file_path, motif_file = motif_file_path, ppi_file= ppi_file_path,modeProcess=\"legacy\", remove_missing = TRUE )\n", |
| 319 | + "treated_all_panda_result <- panda.py(expr_file = treated_expression_file_path, motif_file = motif_file_path, ppi_file= ppi_file_path,modeProcess=\"legacy\", remove_missing = TRUE )" |
| 320 | + ] |
| 321 | + }, |
| 322 | + { |
| 323 | + "cell_type": "markdown", |
| 324 | + "metadata": {}, |
| 325 | + "source": [ |
| 326 | + "Then, the control network:" |
| 327 | + ] |
| 328 | + }, |
| 329 | + { |
| 330 | + "cell_type": "code", |
| 331 | + "execution_count": null, |
| 332 | + "metadata": {}, |
| 333 | + "outputs": [], |
| 334 | + "source": [ |
308 | 335 | "control_all_panda_result <- panda.py(expr_file = control_expression_file_path,motif_file = motif_file_path, ppi_file= ppi_file_path,modeProcess=\"legacy\", remove_missing = TRUE )"
|
309 | 336 | ]
|
310 | 337 | },
|
|
314 | 341 | "lines_to_next_cell": 0
|
315 | 342 | },
|
316 | 343 | "source": [
|
317 |
| - "Vector `treated_all_panda_result` and vector `control_all_panda_result` below are large lists with three elements: the entire PANDA network, indegree (\"to\" nodes) nodes and score, outdegree (\"from\" nodes) nodes and score. Use `$panda`,`$indegree` and `$outdegree` to access each list item resepctively.\n", |
| 344 | + "The result vector `treated_all_panda_result` and vector `control_all_panda_result` below are large lists with three elements: the entire PANDA network in the `$panda` slot, the gene targeting scores or node indegree, and the TF targeting scores or node outdegree. Use `$panda`,`$indegree` and `$outdegree` to access each list item resepctively.\n", |
318 | 345 | "\n",
|
319 |
| - "Use `$panda`to access the entire PANDA network." |
| 346 | + "We can use `$panda`to access the entire PANDA network." |
320 | 347 | ]
|
321 | 348 | },
|
322 | 349 | {
|
|
326 | 353 | "outputs": [],
|
327 | 354 | "source": [
|
328 | 355 | "treated_net <- treated_all_panda_result$panda\n",
|
329 |
| - "control_net <- control_all_panda_result$panda" |
| 356 | + "control_net <- control_all_panda_result$panda\n", |
| 357 | + "treated_net" |
| 358 | + ] |
| 359 | + }, |
| 360 | + { |
| 361 | + "cell_type": "markdown", |
| 362 | + "metadata": {}, |
| 363 | + "source": [ |
| 364 | + "The PANDA network is a data frame that has 4 columns. A source column (TFs), a target column (Genes), a binary motif column that is identical to the input motif network, and a force column that has the edge weight in the PANDA network." |
330 | 365 | ]
|
331 | 366 | },
|
332 | 367 | {
|
333 | 368 | "cell_type": "markdown",
|
334 | 369 | "metadata": {},
|
335 | 370 | "source": [
|
336 | 371 | "## PANDA Cytoscape Plotting\n",
|
337 |
| - "Cytoscape is an interactivity network visualization tool highly recommanded to explore the PANDA network. Before using this function `plot.panda.in.cytoscape`, please install and launch Cytoscape (3.6.1 or greater) and keep it running whenever using." |
| 372 | + "Cytoscape is an interactivity network visualization tool highly recommanded to explore the PANDA network. Before using this function `plot.panda.in.cytoscape`, please install and launch Cytoscape (3.6.1 or greater) and keep it running whenever using this function. \n", |
| 373 | + "\n", |
| 374 | + "Before, calling this function, we need to reduce the network size by selecting the top 1000 edges in PANDA network by edge weight." |
338 | 375 | ]
|
339 | 376 | },
|
340 | 377 | {
|
|
345 | 382 | },
|
346 | 383 | "outputs": [],
|
347 | 384 | "source": [
|
348 |
| - "# select top 1000 edges in PANDA network by edge weight.\n", |
349 | 385 | "panda.net <- head(treated_net[order(control_net$Score,decreasing = TRUE),], 1000)"
|
350 | 386 | ]
|
351 | 387 | },
|
|
371 | 407 | "cell_type": "markdown",
|
372 | 408 | "metadata": {},
|
373 | 409 | "source": [
|
374 |
| - "On netbooks, we can use the visNetwork library to plot the largest 100 edges of the graph. We need to prepare the data in the required format." |
| 410 | + "On netbooks server, we can use the visNetwork library to plot the largest 100 edges of the graph. We need to prepare the data in the required format." |
375 | 411 | ]
|
376 | 412 | },
|
377 | 413 | {
|
|
399 | 435 | "cell_type": "markdown",
|
400 | 436 | "metadata": {},
|
401 | 437 | "source": [
|
402 |
| - "Then, we can call visNetwork." |
| 438 | + "Then, we can call visNetwork on the newly contructed data frame. TFs are yellow triangles, genes are blue circles, positive edges are colored in green, and negative edges in red." |
403 | 439 | ]
|
404 | 440 | },
|
405 | 441 | {
|
|
421 | 457 | "metadata": {},
|
422 | 458 | "source": [
|
423 | 459 | "# 4. LIONESS Algorithm \n",
|
424 |
| - "How to run LIONESS is mostly idential with method how to run PANDA in this package, unless the return values of `lioness.py()` is a data frame where first two columns represent TFs (regulators) and Genes (targets) while the rest columns represent each sample. each cell filled with estimated score calculated by LIONESS." |
| 460 | + "LIONESS reconstructs single-sample networks for each gene expression sample from an aggregate network such as PANDA. LIONESS uses the same arguments as PANDA. In this example, we will run LIONESS algorithm for the first two samples. If we don't specify the `start_sample` and `end_sample` arguments, LIONESS will generate networks for all samples." |
425 | 461 | ]
|
426 | 462 | },
|
427 | 463 | {
|
|
435 | 471 | },
|
436 | 472 | "outputs": [],
|
437 | 473 | "source": [
|
438 |
| - "# Run LIONESS algorithm for the first two samples\n", |
439 |
| - "# removing start_sample and end_sample arguments to generate whole LIONESS network with all samples.\n", |
440 |
| - "control_lioness_result <- lioness.py(expr_file = control_expression_file_path,motif_file = motif_file_path, ppi_file= ppi_file_path,modeProcess=\"legacy\", remove_missing = TRUE, start_sample=1, end_sample=2)" |
| 474 | + "control_lioness_result <- lioness.py(expr_file = control_expression_file_path,motif_file = motif_file_path, ppi_file= ppi_file_path,modeProcess=\"legacy\", remove_missing = TRUE, start_sample=1, end_sample=2)\n", |
| 475 | + "control_lioness_result" |
| 476 | + ] |
| 477 | + }, |
| 478 | + { |
| 479 | + "cell_type": "markdown", |
| 480 | + "metadata": {}, |
| 481 | + "source": [ |
| 482 | + "The output values of `lioness.py()` is a data frame where first two columns represent TFs (regulators) and Genes (targets) while the rest columns represent each sample. Each cell has the estimated edge weights calculated by LIONESS." |
441 | 483 | ]
|
442 | 484 | },
|
443 | 485 | {
|
444 | 486 | "cell_type": "markdown",
|
445 | 487 | "metadata": {},
|
446 | 488 | "source": [
|
447 | 489 | "# 5. CONDOR Algorithm and plotting\n",
|
448 |
| - "PANDA network can simply be converted into condor.object by `panda.to.condor.object(panda.net, threshold)`\n", |
449 |
| - "Defaults option `threshold` is the average of [median weight of non-prior edges] and [median weight of prior edges], all weights mentioned previous are transformationed with formula `w'=ln(e^w+1)` before calculating the median and average. But all the edges selected will remain the orginal weights calculated by PANDA." |
| 490 | + "CONDOR allows to detect communities in gene regulatory networks, like those built by PANDA. However, there a few processing steps to make the network complient with CONDOR format.\n", |
| 491 | + "PANDA networks can simply be converted into condor.object by `panda.to.condor.object(panda.net, threshold)`\n", |
| 492 | + "Defaults option `threshold` is the average of [median weight of non-prior edges] and [median weight of prior edges], all weights mentioned previously are transformationed with formula `w'=ln(e^w+1)` before calculating the median and average which makes all edge weights positive for CONDOR. All the edges selected will remain the orginal weights calculated by PANDA." |
450 | 493 | ]
|
451 | 494 | },
|
452 | 495 | {
|
|
458 | 501 | "treated_condor_object <- panda.to.condor.object(treated_net, threshold = 0)"
|
459 | 502 | ]
|
460 | 503 | },
|
| 504 | + { |
| 505 | + "cell_type": "markdown", |
| 506 | + "metadata": {}, |
| 507 | + "source": [ |
| 508 | + "Then, CONDOR can be called on the PANDA object" |
| 509 | + ] |
| 510 | + }, |
| 511 | + { |
| 512 | + "cell_type": "code", |
| 513 | + "execution_count": null, |
| 514 | + "metadata": {}, |
| 515 | + "outputs": [], |
| 516 | + "source": [ |
| 517 | + "treated_condor_object <-condor.cluster(treated_condor_object,project = FALSE)" |
| 518 | + ] |
| 519 | + }, |
461 | 520 | {
|
462 | 521 | "cell_type": "markdown",
|
463 | 522 | "metadata": {
|
464 | 523 | "lines_to_next_cell": 0
|
465 | 524 | },
|
466 | 525 | "source": [
|
467 |
| - "The communities structure can be plotted by igraph." |
| 526 | + "The result of CONDOR is community assignment for each node of the network. The communities structure can be plotted by igraph." |
468 | 527 | ]
|
469 | 528 | },
|
470 | 529 | {
|
|
473 | 532 | "metadata": {},
|
474 | 533 | "outputs": [],
|
475 | 534 | "source": [
|
476 |
| - "treated_condor_object <-condor.cluster(treated_condor_object,project = FALSE)\n", |
477 | 535 | "treated_color_num <- max(treated_condor_object$red.memb$com)\n",
|
478 |
| - "treated_color <- viridis(treated_color_num, alpha = 1, begin = 0, end = 1, direction = 1, option = \"D\")\n", |
| 536 | + "treated_color <- viridis(treated_color_num, alpha = 1, begin = 0, end = 1, direction = 1, option = \"D\")\n", |
479 | 537 | "condor.plot.communities(treated_condor_object, color_list=treated_color, point.size=0.04, xlab=\"Genes\", ylab=\"TFs\")"
|
480 | 538 | ]
|
481 | 539 | },
|
| 540 | + { |
| 541 | + "cell_type": "markdown", |
| 542 | + "metadata": {}, |
| 543 | + "source": [ |
| 544 | + "This plot shows that CONDOR estimates the TB network to have three distinct communities." |
| 545 | + ] |
| 546 | + }, |
482 | 547 | {
|
483 | 548 | "cell_type": "markdown",
|
484 | 549 | "metadata": {},
|
485 | 550 | "source": [
|
486 | 551 | "# 6. ALPACA Algorithm\n",
|
487 | 552 | "\n",
|
488 |
| - "ALPACA community structure can also be generated from two PANDA network by `panda.to.alpaca`" |
| 553 | + "ALPACA compares 2 networks by detecting differences in their community structure. ALPACA can be called on 2 PANDA network for example. The function `panda.to.alpaca` allows to link both methods" |
489 | 554 | ]
|
490 | 555 | },
|
491 | 556 | {
|
|
501 | 566 | "cell_type": "markdown",
|
502 | 567 | "metadata": {},
|
503 | 568 | "source": [
|
504 |
| - "## More tutorials\n", |
| 569 | + "The result list `alpaca` 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. " |
| 570 | + ] |
| 571 | + }, |
| 572 | + { |
| 573 | + "cell_type": "markdown", |
| 574 | + "metadata": {}, |
| 575 | + "source": [ |
| 576 | + "# More tutorials\n", |
505 | 577 | "\n",
|
506 |
| - "Browse with `browseVignettes(\"netZooR\")` locally or check this link for [cloud notebooks](http://netbooks.networkmedicine.org/).\n", |
| 578 | + "Browse with `browseVignettes(\"netZooR\")` locally or check [this link for cloud notebooks](http://netbooks.networkmedicine.org/).\n", |
507 | 579 | "\n",
|
508 | 580 | "## Note\n",
|
509 | 581 | "If there is an error like `Error in fetch(key) : lazy-load database.rdb' is corrupt` when accessing the help pages of functions in this package after being loaded. It's [a limitation of base R](https://github.com/r-lib/devtools/issues/1660) and has not been solved yet. Restart R session and re-load this package will help.\n"
|
|
523 | 595 | "\n",
|
524 | 596 | "4- Padi, Megha, and John Quackenbush. \"Detecting phenotype-driven transitions in regulatory network structure.\" NPJ systems biology and applications 4.1 (2018): 1-12.\n",
|
525 | 597 | "\n",
|
526 |
| - "5- Kuijjer, Marieke Lydia, et al. \"Cancer subtype identification using somatic mutation data.\" British journal of cancer 118.11 (2018): 1492-1501.\n", |
527 |
| - "\n", |
528 |
| - "6- Schlauch, Daniel, et al. \"Estimating drivers of cell state transitions using gene regulatory network models.\" BMC systems biology 11.1 (2017): 1-10." |
| 598 | + "5- Kuijjer, Marieke Lydia, et al. \"Cancer subtype identification using somatic mutation data.\" British journal of cancer 118.11 (2018): 1492-1501." |
529 | 599 | ]
|
530 | 600 | }
|
531 | 601 | ],
|
|
0 commit comments