title: "How to parse gatingML into a GatingSet" author: "Mike Jiang" output: html_document


knitr::opts_chunk$set(echo = TRUE, results = "markup", message = FALSE, warning = FALSE)

This vignette demonstrates how the gatingML files exported from Cytobank can be imported into R as a GatingSet object.

library(flowWorkspace)
fcsFiles <- list.files(pattern = "CytoTrol", system.file("extdata", package = "flowWorkspaceData"), full.names = TRUE)
xmlfile <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "flowWorkspace")

Use parse.gatingML

The entire parsing work can be done with single convevient function parse.gatingML:

gs <- parse.gatingML(xmlfile, fcsFiles)

Load GatingML and FCS separately

Or you can divide the parse into several steps to have more controls.

Load the gatingML file as a graphGML object

g <- read.gatingML.cytobank(xmlfile)
class(g)
g

graphGML stores the gating hierarchy, which can be inspected by various accessors.

getNodes(g)
getParent(g, "GateSet_722318")
getChildren(g, "GateSet_722318")

And the population tree can be plotted

plot(g)

The node with dotted border means the tailored gates(or sample-specific gates) are defined for that population.

Read raw FCS files

fs <- read.ncdfFlowSet(fcsFiles)

Construct the GatingSet

gs <- GatingSet(fs)

Compensate the GatingSet

gs <- compensate(gs, g)

Extract the transformation

trans <- getTransformations(g)
trans

Transform the GatingSet

gs <- transform(gs, trans)

Visualize the outcome of compensation and transformation

require(ggcyto)
ggcyto(gs, aes(x = CD4), subset = "root") + geom_density()
ggcyto(gs, aes(x = CD4, y = CD8), subset = "root") + geom_hex()

Apply the gates to GatingSet

gating(g, gs)

Plot the gates

autoplot(gs[[1]])

Extract the population statistics

getPopStats(gs, statType = "count")


RGLab/boost2protobuf documentation built on May 8, 2019, 5:53 a.m.