The shiny-iatlas repository is being migrated into two new repositories:
- iatlas-app (this repository) - for all the shiny-app R code
- iatlas-data - for all the iatlas-related data, DB-creation and DB-populating code
The iAtlas app is an interactive web portal that provides multiple analysis modules to visualize and explore immune response characterizations across cancer types. The app is hosted on shinyapps.io at https://isb-cgc.shinyapps.io/shiny-iatlas/ and can also be accessed via the main CRI iAtlas page at http://www.cri-iatlas.org/.
The portal is built entirely in R and Shiny using the RStudio development environment. Layout and interactivity within the portal are achieved by heavy use of the following packages:
R: https://www.r-project.org/ - v3.6.2
Ensure that the location of the repository is shared via docker:
For installation on the various platforms, please see this git-lfs wiki
Some feather files are very large.
git-lfsis used to store these files.
git lfs installmust be executed within the repository directory immediately after cloning the repo.
libpq (postgres): https://www.postgresql.org/download/
lib cairo: https://www.cairographics.org/ (only required for iAtlas client)
gfortran (libgfortran): usually installed with gcc
MacOS Install instructions
- xcode-select --install
- brew install R
- brew install cairo
- brew install git-lfs
- brew install postgres
- download and install RStudio: https://rstudio.com/products/rstudio/download
- download and install Docker: https://www.docker.com/products/docker-desktop
Initialize R Packages, Database and run App
To run the app locally:
Clone this repository
Install packages. In the RStudio console, run:
This may take some time to complete - get something nice to drink :)
Build the database locally with the following:
Make the database function available by executing the following in the R console:
Build the database by executing the following in the R console:
build_iatlas_db(reset = "reset")
Start the app by running:
Installing and Upgrading Packages
This project uses renv to manage packages. The definitive list of required packages and versions is stored in the
When adding any new dependencies to the application, they may be added using (where "useful_package" is the name of the package to add):
# install a package renv::install("useful_package") # update the renv.lock file renv::snapshot()
Git works will with renv. Once you validate the package should be kept,
git add renv.lock to the repo and everyone else will automatically install it when they git-pull and re-open their R session or run renv::restore.
If you decide you don't want to include the package, just
git checkout renv.lock to reset your dependencies to the point before you made changes.
To remove an installed package, run (where "useful_package" is the name of the package to remove):
And git-commit it once you are sure you want to keep the changes.
You can use renv::upgrade("package-name") to upgrade a package, but it'll always update to the very latest uniless you manually tell it otherwise.
- IMPORTANT: A few of the packages we currently use don't work with the latest versions, so don't use renv::update to update all packages.
- Known upgrade-problems:
- don't upgrade shinycssloaders to v0.3.0
- don't upgrade plotly to v4.9.2
Installing Packages and RsConnect
This application is deployed using rsconnect::deployApp(). As of the current version (0.8.16-9000), rsconnect does not support using the renv.lock file to determin which packages to deploy. Instead, it uses its own till (rsconnect::appDependencies) to detect your app's dependencies from the R source files and the DESCRIPTION file. The good news is it will generally get the correct version, since it'll use the current version you have installed and renv manages that tightly. The bad news is sometimes it won't detect you need a package. Here's how you solve that problem:
- If a package is missing after you push to the staging branch and check the staging server, add that the package name to the
Imports:section of the DESCRIPTION file.
The first time you deploy, go through the Deployment-Setup instructions. Afterwards, you can deploy with one line.
Deployment Setup (First-Time-Only)
You'll need to set up your credentials for shinyapps.io. You can get your codes from:
Paste and evaluate your tokens in the RStudio console. They look like this:
# shinyapps.io example credentials rsconnect::setAccountInfo( name='shiny-iatlas', token='xxx', secret='yyy' )
Deploy with RsConnect
Once your account info is set up, you can deploy with:
Input data for the Shiny-iAtlas portal were accessed from multiple remote sources, including Synapse, the ISB Cancer Genomics Cloud, and Google Drive. For convenience, we have created locally cached versions of dataframe objects as
feather files in the
Configuration and Environment Variables
The database connection is configured in the
config.yml file. We use the config package to load the correct config. See init.R for exactly how this is done. You can also override the config by setting these environment variables:
DB_NAME=XYZ DB_HOST=XYZ DB_PORT=123 DB_USER=XYZ DB_PW=XYZ
config.yml is part of the public git repository. Do NOT put sensitive passwords or keys in
config.yml. Use environment variables for any passwords or keys you do not wish to share publicly.
While many of the results presented in tables and plots are taken directly from IRWG data (including the main feature matrix and various feature and group annotations), we compute some values internally. Unless otherwise noted, the following methods/tools were used to compute summary statistics:
Correlation — Spearman's rank-order correlation
stats::cor(x, y, method = "spearman", use = "pairwise.complete.obs")
Concordance Index (CI)
Concordance indexes for survival endpoints with respect to different immune readouts were computed using a custom package developed by Tai-Hsien Ou Yang at Columbia University. The concordanceIndex package includes a single synonymous function that can be used as follows:
observations are numerical vectors of the same length.
To check if 'startup::startup()' ran successfully, type in
DB_HOST and see if it is set to a non-blank value. For example:
> DB_HOST  "localhost"
Note: You can also check your Global Environment under the "Environment" tab in the upper-right corner of the RStudio session.
The following should all be set:
DB_USER. If none of them are set, startup probably didn't succeed. The first thing to check what
.REnviron.d folder startup is finding. Run:
Skip the first half of the output until you see this line:
x.xxxs: startup::startup()-specific processing...
Just below you should see it loading the
./.Renviron.d and later
./.Rprofile.d. If yours says anything different than dot-slash-dot-Renviron-dot-d, startup is loading the wrong files.
If you ran
startup::installat some point, startup may have created these folders in your user directory. They are probably empty or simply the default values. If so, you can trash them. Then re-run startup with debug=TRUE and see if it works.
Otherwise, you may need to check your R startup path and see why startup is finding the wrong files. Read more about it here: https://cran.r-project.org/web/packages/startup/vignettes/startup-intro.html
The tail end of your output should look like this:
0.005s: startup::startup()-specific processing ... 0.006s: Found startup directory ‘./.Renviron.d’. 0.010s: Processing 1 Renviron files ... 0.012s: - ‘./.Renviron.d/rstudio=TRUE/.Renviron’ (1 lines; 8 bytes) setting 1 environment variables (‘ENV’) 0.013s: Processing 1 Renviron files ... done 0.016s: Found startup directory ‘./.Rprofile.d’. 0.019s: Processing 1 Rprofile files ... 0.020s: - ‘./.Rprofile.d/ENV=dev.R’ (5 code lines; 264 bytes) 0.021s: Processing 1 Rprofile files ... done 0.022s: - unloading the ‘startup’ package 0.023s: - Search path: ‘.GlobalEnv’, ‘tools:rstudio’, ‘package:stats’, ‘package:graphics’, ‘package:grDevices’, ‘package:datasets’, ‘renv:shims’, ‘package:utils’, ‘package:methods’, ‘Autoloads’, ‘package:base’ 0.023s: - Loaded namespaces: ‘compiler’, ‘graphics’, ‘tools’, ‘utils’, ‘grDevices’, ‘stats’, ‘datasets’, ‘methods’, ‘renv’, ‘base’ 0.023s: startup::startup()-specific processing ... done 0.023s: The following will be processed next by R: 0.023s: - R_HISTFILE: ‘’ 0.024s: - ‘./.Rhistory’ (0 lines; 0 bytes) 0.039s: - .First(): no such function on search() 0.039s: - Remaining packages per R_DEFAULT_PACKAGES to be attached by base::.First.sys() (in order):
- If you are initializing the database with
build_iatlas_dband having a problem where it fails to connect after creating the tables, check that you are not running Postgress locally, outside of docker.