--- title: "3. TG-Score" author: "Zhesi Zhang, Xin Lai" date: "`r Sys.Date()`" package: miREA output: BiocStyle::html_document: toc: true toc_float: true vignette: > %\VignetteIndexEntry{3. TG-Score} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ``` # Overview `TG_Score()` performs target gene enrichment analysis by testing whether a pathway's genes are located unexpectedly toward one end of a ranked gene list. The ranked list is restricted to the target genes of differentially expressed miRNAs, mapped through `background_MGI`, and ranked by each gene's own differential expression statistic. This is a GSEA style test, built on `r BiocStyle::Biocpkg("clusterProfiler")`'s `GSEA()`. 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 two column data frame with columns `pathway` 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`. * `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`). * `pvalueType` for `TG_Score()` itself, one of `"pos"`, `"neg"`, or `"std"`, selecting a one sided or two sided test. ```{r load-data} library(miREA) data(toy_pathway) data(toy_mir_DEdata) data(toy_gene_DEdata) data(background_MGI) ``` # Run TG-Score ```{r prepare-input} input_data <- getAllInputData( methods = "TG_Score", pathway = toy_pathway, mir_DEdata = toy_mir_DEdata, gene_DEdata = toy_gene_DEdata, background_MGI = background_MGI ) ``` `input_data$data$TG_Score` holds the ranked gene list, restricted to the target genes of differentially expressed miRNAs and ranked by each gene's own differential expression statistic. `input_data$pathway$TG` holds the pathway gene sets, unchanged from the `toy_pathway` input. ```{r run-tg-score} res <- TG_Score( geneList = input_data$data$TG_Score, pathway = input_data$pathway$TG, pvalueType = "std", pvalueCutoff = 1 ) head(res) ``` # Run through miREA() `TG_Score()` 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). `TG_Score()` itself has no `background` argument, but `miREA()` still requires one for the `TG` target, since `TG_ORA()` shares that target and does use it. For a single target, `background` can be a plain character vector instead of a named list. ```{r run-through-miREA} result <- miREA( methods = "TG_Score", input_data = input_data, background = unique(toy_pathway$gene), pvalueCutoff = 1 ) head(result$result$TG_Score) ``` # Supplying your own ranked gene list `TG_Score()`'s real input is a ranked list of genes targeted by miRNAs of interest, not an arbitrary ranked gene list. If you already have a miRNA list from an external analysis instead of letting `getAllInputData()` derive one from `mir_DEdata`, map that miRNA list to its target genes through `background_MGI`, the same step `getAllInputData()` performs internally, then rank those genes by their own differential expression statistic from `gene_DEdata`. ```{r custom-list, eval=FALSE} # replace with your own miRNA list my_miRs <- c("hsa-miR-21-5p", "hsa-miR-155-5p") my_TG <- unique(background_MGI$gene[background_MGI$miRNA %in% my_miRs]) my_geneList <- toy_gene_DEdata$stat[match(my_TG, toy_gene_DEdata$gene)] names(my_geneList) <- my_TG my_geneList <- sort(my_geneList[!is.na(my_geneList)], decreasing = TRUE) res_custom <- TG_Score( geneList = my_geneList, pathway = toy_pathway, pvalueType = "std", pvalueCutoff = 1 ) ``` # Session info ```{r session-info} sessionInfo() ```