Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create TIGER.ipynb #11

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions netbooks/netZooR/TIGER.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# TIGER\n",
"\n",
"## Introduction\n",
"The goal of TIGER is to estimate gene regulatory network and transcription factor \n",
"activities using Bayesian matrix factorization. \n",
"![](TIGER.png)<!-- --> \n",
"Please read and cite the following article when you use TIGER: \n",
"[Joint inference of transcription factor activity and context-specific regulatory networks, Chen&Padi 2022](https://www.biorxiv.org/content/10.1101/2022.12.12.520141v1)\n",
"\n",
"## Installation\n",
"\n",
"TIGER relies on [cmdstanr](https://mc-stan.org/cmdstanr/) for Beyesian Inference. \n",
"You can install the latest beta release of the cmdstanr R package with\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"install.packages(\"cmdstanr\", repos = c(\"https://mc-stan.org/r-packages/\", getOption(\"repos\")))\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Then, you can use cmdstanr to install [CmdStan](https://mc-stan.org/users/interfaces/cmdstan.html), the shell interface to [Stan](https://mc-stan.org/) with\n"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"install_cmdstan()\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These two steps are usually enough if your C++ toolchain is set up properly. For example, use RTools 4.0 toolchain which contains a g++ 8 compiler and mingw32-make on Windows platform. If you see problems with installation, you can go to cmdstanr [installation](https://mc-stan.org/cmdstanr/articles/cmdstanr.html) for more information. \n",
"\n",
"After cmdstan is correctly installed, you can install the development version of TIGER with:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"devtools::install_github(\"cchen22/TIGER\")\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Quick start\n",
"\n",
"This is a simple example of TIGER on a small dataset. TIGER requires two inputs - \n",
"1. a normalized expression matrix with rows as genes and column as samples; \n",
"2. a prior network with rows as TFs and column as genes. The network is signed and binarized (e.g., -1,0,1). \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"library(TIGER)\n",
"\n",
"##1. load data\n",
"expr = TIGER::expr\n",
"prior = TIGER::prior\n",
"\n",
"##2. run TIGER with default parameters\n",
"ss = TIGER(expr,prior)\n",
"\n",
"##3. print the TFA score in first three samples\n",
"tgres = ss$Z\n",
"tgres[,1:3]\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Wokring with DoRothEA prior\n",
"TIGER provides some convenient functions to work with DoRothEA prior database. Firstly, install DoRothEA R package from [Bioconductor](https://bioconductor.org/packages/release/data/experiment/html/dorothea.html)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"BiocManager::install(\"dorothea\")\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"DoRothEA provides regulons for two species - human and mouse. For example,if we have a human cancer expression matrix and want to estimate the TFA in each cancer sample, then we can use the following code to prepare the prior network.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## load dorothea pancancer database\n",
"df = dorothea::dorothea_hs_pancancer\n",
"\n",
"## convert it to TIGER prior format (e.g., adjacency matrix) \n",
"prior = el2adj(df[,-2])\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "\n"
}
],
"metadata": {
"anaconda-cloud": "",
"kernelspec": {
"display_name": "R",
"langauge": "R",
"name": "ir"
},
"language_info": {
"codemirror_mode": "r",
"file_extension": ".r",
"mimetype": "text/x-r-source",
"name": "R",
"pygments_lexer": "r",
"version": "3.4.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}