This document outlines how to set up a flow cytometry dashboard using the flowDashboard Shiny modules.

Where flowDashboard Fits in an Analysis Workflow

flowDashboard enables you to visualize data at both the Sample and Population Level. The package assumes that you either have FCS data in a directory, or have generated a GatingSet for your gating scheme. This gating scheme can either be automated (from a pipeline such as openCyto) or manually (imported from flowJo).

There are multiple modules that will enable you to examine each step of the analysis.

  • Annotation display - displays annotation for all the FCS files in an experiment.
  • QC plots - plots that let you compare the overall state of the data before and after preprocessing.
  • Gating plots - plots that display how the data was gated
  • Dot plots - to visualize populations based on a covariate
  • Violin plots of markers in a population
  • Waterfall plots to examine how population percentage correlates with an outcome.
  • Coexpression plots - a heatmap and a two-way expression explorer.

Preprocessing Data

Once your data is in a gatingSet (preferably in ncdf format), we will need to transform and prep it into the data.table format. This package uses data.table because it is a very fast format for accessing, merging, sorting, and displaying data.

The annotation structure is another data.table that we need for the dashboard. Based on your unit of analysis and what the FCS file represents (which may be patients, cell lines, or conditions within a patient), you will need an annotation table that provides covariate information at the level of analysis you are interested in. You can generate the skeleton of an annotation table with the `` command, or you can use the phenoData slot in your GatingSet.

Please note that the usefulness of flowDashboard is only as good as your annotation. Careful curation of variables in your annotation will allow you to sort, subset, and aggregate on these variables.

library(flowWorkspace)
## Loading required package: flowCore
## Loading required package: ncdfFlow
## Loading required package: RcppArmadillo
## Loading required package: BH
library(flowDashboard)
## Loading required package: tidyr
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:ncdfFlow':
## 
##     filter
## The following object is masked from 'package:flowCore':
## 
##     filter
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## Loading required package: shiny
## Loading required package: data.table
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## Loading required package: dtplyr
## Loading required package: ggvis
## Loading required package: lazyeval
## Loading required package: gplots
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
## Loading required package: ggplot2
## 
## Attaching package: 'ggplot2'
## The following object is masked from 'package:ggvis':
## 
##     resolution
## Loading required package: R6
## Loading required package: forcats
## Loading required package: stringi
gsFile <- system.file("extdata/gvHDgs/", package = "flowDashboard")
gs <- load_gs(gsFile)
## loading R object...
## loading tree object...
## Done
##look at phenoData slot in gs
phenotypes <- pData(gs@data@phenoData)
phenotypes
##       Patient Visit Days Grade  name
## s5a01       5     1   -6     3 s5a01
## s5a02       5     2    0     3 s5a02
## s5a03       5     3    6     3 s5a03
## s5a04       5     4   12     3 s5a04
## s5a05       5     5   19     3 s5a05
## s5a06       5     6   26     3 s5a06
## s5a07       5     7   33     3 s5a07
## s6a01       6     1   -8     3 s6a01
## s6a02       6     2    0     3 s6a02
## s6a03       6     3    5     3 s6a03
## s6a04       6     4   12     3 s6a04
## s6a05       6     5   19     3 s6a05
## s6a06       6     6   27     3 s6a06
## s6a07       6     7   32     3 s6a07
## s7a01       7     1   -4     3 s7a01
## s7a02       7     2    0     3 s7a02
## s7a03       7     3    7     3 s7a03
## s7a04       7     4   14     3 s7a04
## s7a05       7     5   21     3 s7a05
## s7a06       7     6   28     3 s7a06
##look at marker information in gs
markerInfo <- pData(parameters(gs@data[[1]]))
markerInfo
##      name              desc range  minRange     maxRange
## $P1 FSC-H        FSC-Height  1024 0.0000000  1023.000000
## $P2 SSC-H        SSC-Height  1024 0.0000000  1023.000000
## $P3 FL1-H         CD15 FITC  1024 0.8813736     9.903488
## $P4 FL2-H           CD45 PE  1024 0.8813736     9.903488
## $P5 FL3-H        CD14 PerCP  1024 0.8813736     9.903488
## $P6 FL2-A              <NA>  1024 0.0000000     7.623642
## $P7 FL4-H          CD33 APC  1024 1.0000000 10000.000000
## $P8  Time Time (51.20 sec.)  1024 0.0000000  1023.000000
#build a qcFlowObj 
QCO <- QCOFromGatingSet(gs, samplePop = 1000)

#show annotation slot
QCO$annotation
##     Patient Visit Days Grade  name
##  1:       5     1   -6     3 s5a01
##  2:       5     2    0     3 s5a02
##  3:       5     3    6     3 s5a03
##  4:       5     4   12     3 s5a04
##  5:       5     5   19     3 s5a05
##  6:       5     6   26     3 s5a06
##  7:       5     7   33     3 s5a07
##  8:       6     1   -8     3 s6a01
##  9:       6     2    0     3 s6a02
## 10:       6     3    5     3 s6a03
## 11:       6     4   12     3 s6a04
## 12:       6     5   19     3 s6a05
## 13:       6     6   27     3 s6a06
## 14:       6     7   32     3 s6a07
## 15:       7     1   -4     3 s7a01
## 16:       7     2    0     3 s7a02
## 17:       7     3    7     3 s7a03
## 18:       7     4   14     3 s7a04
## 19:       7     5   21     3 s7a05
## 20:       7     6   28     3 s7a06
#show first few lines of qcData
QCO$qcData
##         idVar cellNum          variable value
##      1: s5a01    1560        FSC.Height   812
##      2: s5a01    2999        FSC.Height   164
##      3: s5a01    1825        FSC.Height   256
##      4: s5a01     811        FSC.Height    79
##      5: s5a01    1275        FSC.Height   218
##     ---                                      
## 159996: s7a06   10589 Time..51.20.sec..    79
## 159997: s7a06    3426 Time..51.20.sec..    26
## 159998: s7a06    6128 Time..51.20.sec..    46
## 159999: s7a06    8299 Time..51.20.sec..    61
## 160000: s7a06    5875 Time..51.20.sec..    43

QC Module

The QC Heatmap provides a quick overview of how markers vary across populations. This heatmap is based on the idea of examining a QC panel of markers to compare whether there is a large technical variation between samples.

The QC Violin plots allow you to compare fluoresence distibution of individual functions.

The underlying QC data is sampled using the buildSampledDataList() function. This function generates a data.table that samples from each FCS file for a selected control panel of markers.

Gating Module

The gating module consists of a heatmap visualization and plots for each cell in the heatmap, corresponding to the gating scheme. This module is useful in understanding the impact of automated gating pipelines, such as openCyto, and comparing manual gating schemes across samples.

The plots for each sample must be precomputed using the plotAllPopulations() function. This function takes a GatingSet as input.

The Violin plots

Coexpression Module

Waterfall Module

This module displays population percentages

DotPlot Module