Shiny PCA Maker

December 21, 2023 ยท View on GitHub

This Shiny application takes a CSV file of count/expression data and a CSV of metadata, allows you to select a few parameters to compute a Principal Components Analysis, returning several diagnostic plots and tables. The plots include a scree plot and a biplot of Principal Components.

You can chose which columns to include in the PCA, and which column to use as a grouping variable for coloring. You can choose to center, scale, or normalize (via rlog or vst). You can choose which PCs to include on the biplot.

The biplot of PCs is interactive, so you can click on points or select points and inspect the details of those points in a table.

How to run or install

There are several ways to run/install this app.

Running from Github

If you have R/RStudio and all of the prerequisites installed (see below for dependency installation), you can run it directly from Github like so:

library(shiny)
runGitHub("shiny-pca-maker", "LJI-Bioinformatics", launch.browser = TRUE)

Running locally

Dependency installation

If running from Github or locally with R/RStudio, you can install the dependencies with the following commands:

install.packages(c('shiny', 'ggplot2', 'DT', 'GGally', 'psych', 'Hmisc', 'MASS', 'tabplot'))

Next, install the DESeq2 package from BioConductor. For R version >= 3.5:

if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install('DESeq2', update=FALSE, ask=FALSE)
BiocManager::install('genefilter', update=FALSE, ask=FALSE)

For R versions < 3.5:

source("https://bioconductor.org/biocLite.R")
biocLite('DESeq2')

There are multiple ways to run locally, including with Docker or directly in R/RStudio. Both require you to clone the git repository to your machine:

git clone https://github.com/LJI-Bioinformatics/Shiny-PCA-Maker.git LOCAL_DIR

Replace LOCAL_DIR with the directory into which you would like to clone. For the rest of this README, we will assume it is in your home directory, at:

~/Shiny-PCA-Maker

Running locally with Docker

If you have Docker installed, you can start a container to run the server. You can either build it from the dockerfile, or use the prebuilt image available on dockerhub.

To build the image locally and run:

docker build --platform linux/amd64 --tag shiny_pca_maker .
docker run -d --platform linux/amd64 -p 3838:3838 shiny_pca_maker

Otherwise, to use the pre-built image:

docker run -d --platform linux/amd64 -p 3838:3838 jgbaum/shiny_pca_maker

This will start a server at port 3838, which you can reach from your browser at:

http://localhost:3838

Running locally with R/RStudio

To run this app directly from your R/RStudio installation, first ensure that dependencies are installed (as described below). Open up R/RStudio and type:

setwd("~/Shiny-PCA-Maker")
runApp(launch.browser = TRUE) 

How to use

Start on the first (left-most) tab to upload/validate your count and metadata files, then click on each tab, in order from left to right, to see the results.

Input data

This tool requires two input files:

Count Matrix

This is a matrix of counts/expression values where the rows are genes/features and the columns are samples. The names of the columns are the sample names and they must correspond to the row names of the metadata (described below). The format is similar to what would be accepted for the 'expr' slot of a Bioconductor ExpressionSet. Here is an example count matrix.

Metadata

This file should contain one row per sample and have columns that indicate properties of interest. These will be the variables by which the PCA plots can be colored. The format is similar to what would be accepted for the 'phenoData' slot of a Bioconductor ExpressionSet. Here is an example metadata file.

Feedback, contributing, etc.

Please open an issue if you find something that doesn't work as expected.

License

This code is licensed under the GPL v3.0. Aternative, commercial-friendly licenses available upon request.