flowDashboard
In order to enable comparison of flow cytometry data across samples, we have developed three R6 objects that enable different portions of the analysis in our Shiny Dashboard.
qcFlowObj
- used to visualize qc analysisgatingObj
- used to visualize gating and population percentagespopulationExpressionObj
- used to compare expression across conditions.Why R6 objects? We wanted to make the data easily comparable and reusable. Putting data into these objects allows for rapid deployment of a comparative flow analysis dashboard. Once the objects are built, they can be loaded into a Shiny dashboard with relatively little work.
All three data objects have an annotation
slot, which holds a data.table
. This annotation
slot allows for subsetting the data according to covariates in the data. There is a constraint on these objects that forces the annotation
and associated data
slot (qcData
, popTable
, and expressionData
) to have sample ids that reconcile with each other. The mapping variable between these two data.table
s must be specified as a named vector (for example: c("idVar"="FCSFiles")
) in the mapVar
slot.
qcData
can be generated from both flowSets
and gatingSets
. popTable
and expressionData
can only be generated from gatingSets
.
flowDashboard
ObjectsEach object type has display options associated with the object. Setting these options on the objects greatly simplifies deployment of a modular dashboard. For example, you can control what variables in your annotation to sort on and subset on using the subsetModule
. For the GatingObj
, you can control which populations are visible in your dashboard using the setPopulations
method.
Common display options across all of the classes are:
setSubsetAndSortOptions()
- Setting columns for subsetting in the annotation slot setAnnotationDisplayOptions()
- Setting the columns in the annotation slot to display subsetAnnotation()
- subset the annotation and data slots to be restricted to a set of ids (this is a destructive operation)
qcFlowObj
, gatingObj
and populationExpressionObj
from a GatingSet
Here we build a qcFlowObj
from a subset of GvHD
dataset. Before we do, we look at the phenotypes available in the phenoData
slot in the GatingSet
.
library(flowWorkspace)
## Loading required package: flowCore
## Loading required package: ncdfFlow
## Loading required package: RcppArmadillo
## Loading required package: BH
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))
markerInfo
#build a qcFlowObj
QCO <- QCOFromGatingSet(gs, samplePop = 1000)
#show annotation slot
QCO$annotation
#show first few lines of qcData
QCO$qcData
Here we build a gatingObj
from our GatingSet
. If you want to show the gating for each sample, you will also need to set plotGraphs=TRUE
and provide an imageDir
as arguments to gatingObjFromGatingSet
.
objId <- "GOgvhd"
#GO <- GOFromGatingSet(gs, objId = objId)