--- title: "10. Edge-Network" author: "Zhesi Zhang, Xin Lai" date: "`r Sys.Date()`" package: miREA output: BiocStyle::html_document: toc: true toc_float: true vignette: > %\VignetteIndexEntry{10. Edge-Network} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ``` # Overview `Edge_Network()` performs miRNA gene interaction (MGI) enrichment analysis through network propagation. It builds a combined MGI and GGI network, converts it to its line graph so that edges become nodes, and runs a random walk with restart seeded from the differentially expressed MGIs. Each pathway is scored by how much of the propagated signal lands on its own MGIs, with significance assessed against permuted restart sets, controlled by `iter`. It needs a gene-gene interaction (GGI) network in addition to `background_MGI`. Because the line graph scales with the combined size of the background MGI and GGI networks, this method can be memory and time intensive on real sized data. Consider increasing `ncores` for large analyses. This vignette uses the same toy BLCA example data as the package's main Quick Start vignette. See `vignette("miREA")` for a description of that data and for running all nine methods together through `miREA()`. # Required inputs * `pathway`, a three column data frame with columns `pathway`, `miRNA`, and `gene`. * `mir_DEdata`, a four column data frame with columns `miRNA`, `log2FoldChange`, `stat`, and `padj`. * `gene_DEdata`, a four column data frame with columns `gene`, `log2FoldChange`, `stat`, and `padj`. * `mir_mat` and `gene_mat`, raw expression matrices with samples as columns. * `background_MGI`, a two column data frame with columns `miRNA` and `gene`, or `NULL` to use the bundled default (see `vignette("miREA")`, Step 1, for details on `background_MGI`). * `GGI_source` or `background_GGI`, selecting the gene to gene interaction network (see `vignette("miREA")`, Step 1, for details on `background_GGI` and `GGI_source`). * `iter`, the number of permuted restart sets. The function default is 1000. This vignette uses `iter = 10` to keep build time short on the small toy dataset. * `seed`, an optional integer for reproducible permutation draws. ```{r load-data} library(miREA) data(toy_pathway) data(toy_mir_DEdata) data(toy_gene_DEdata) data(toy_gene_mat) data(toy_mir_mat) data(background_MGI) ``` # Run Edge-Network ```{r prepare-input} input_data <- getAllInputData( methods = "Edge_Network", pathway = toy_pathway, mir_DEdata = toy_mir_DEdata, gene_DEdata = toy_gene_DEdata, background_MGI = background_MGI, GGI_source = "Reactome", gene_mat = toy_gene_mat, mir_mat = toy_mir_mat ) ``` `input_data$data$Edge_Network` holds the differentially expressed MGIs. `input_data$pathway$TG`, `input_data$pathway$Edge`, and `input_data$pathway_GGI` hold the pathway gene, MGI, and GGI sets. `input_data$MGI` and `input_data$GGI` hold the background MGI and GGI networks restricted to the genes and miRNAs relevant to `toy_pathway` and `toy_mir_DEdata`/`toy_gene_DEdata`. ```{r run-edge-network} res <- Edge_Network( DEMGI = input_data$data$Edge_Network, pathway_gene = input_data$pathway$TG, pathway_MGI = input_data$pathway$Edge, pathway_GGI = input_data$pathway_GGI, MGI = input_data$MGI, GGI = input_data$GGI, minSize = 2, maxSize = 5000, iter = 10, ncores = 1, pvalueCutoff = 1, seed = 42 ) res_display <- head(res) res_display$contribute_edge <- NULL res_display ``` `contribute_edge` is omitted from the display above because it lists every contributing edge for a pathway as a single string, which can be very long on the toy network and is better inspected directly on `res` than printed in full here. `n_contribute_edge` reports how many edges that string holds. # Run through miREA() `Edge_Network()` can also be run through the `miREA()` wrapper, which is useful when you want its result alongside other methods' results in a single `miREAResult` object (see `vignette("miREA")`, Step 2, for the multi-method case). `Edge_Network()` itself has no `background` argument, it uses `input_data$MGI`/`input_data$GGI` directly instead, but `miREA()` still requires a `background` for the `Edge` target, since `Edge_ORA()`/`Edge_Score2D()`/`Edge_Topology()` share that target and do use it. For a single target, `background` can be a plain character vector instead of a named list. ```{r run-through-miREA} background <- unique(paste0(background_MGI$miRNA, ":", background_MGI$gene)) result <- miREA( methods = "Edge_Network", input_data = input_data, background = background, minSize = 2, maxSize = 5000, iter = 10, ncores = 1, pvalueCutoff = 1, seed = 42 ) result_display <- head(result$result$Edge_Network) result_display$contribute_edge <- NULL result_display ``` # Session info ```{r session-info} sessionInfo() ```