geom_gate: Add a gate layer to a ggcyto plot.

Description Usage Arguments Details Value Examples

View source: R/geom_gate.R

Description

When 'data' is a gate (or flowCore filter) or a list of gates or a filterList object. When it is used directly with 'ggplot', pdata of the flow data must be supplied through 'pd' argument explicitly in order for the gates to be dispatched to each panel. However It is not necessary when used with 'ggcyto' wrapper since the latter will attach pData automatically.

Usage

1
2
3
4
5
6
7
geom_gate(data, ...)

## S3 method for class 'filterList'
geom_gate(data, pd, nPoints = 100, ...)

## S3 method for class 'filter'
geom_gate(data, mapping = NULL, fill = NA, colour = "red", nPoints = 100, ...)

Arguments

data

a filter (Currently only rectangleGate (1d or 2d), polygonGate, ellipsoidGate are supported.) or a list of these gates or filterList or character specifying a gated cell population in the GatingSet

...

other arguments

pd

pData (data.frame) that has rownames represents the sample names used as key to be merged with filterList

nPoints

used for interpolating polygonGates to prevent them from losing shape when truncated by axis limits

mapping

The aesthetic mapping

fill

fill color for the gate. Not filled by default.

colour

default is red

Details

When 'data' is a character, it construct an abstract geom layer for a character that represents nodes in a Gating tree and will be instanatiated later as a specific geom_gate layer or layers based on the gates extracted from the given GatingSet object.

Value

a geom_gate layer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(GvHD)
fs <- GvHD[subset(pData(GvHD), Patient %in%5:7 & Visit %in% c(5:6))[["name"]]]
p <- ggcyto(fs, aes(x = `FSC-H`, y =  `SSC-H`))
p <- p + geom_hex(bins = 128)
rect.g <- rectangleGate(list("FSC-H" =  c(300,500), "SSC-H" = c(50,200)))
#constuctor for a list of filters
rect.gates <- sapply(sampleNames(fs), function(sn)rect.g)
p + geom_gate(rect.gates)

dataDir <- system.file("extdata",package="flowWorkspaceData")
gs <- load_gs(list.files(dataDir, pattern = "gs_manual",full = TRUE))
p <- ggcyto(gs, aes(x = CD4, y = CD8), subset = "CD3+") + geom_hex(bins = 64)
# add gate layer by gate name
p + geom_gate("CD4")

Example output

Loading required package: ggplot2
Loading required package: flowCore
Loading required package: ncdfFlow
Loading required package: RcppArmadillo
Loading required package: BH
Loading required package: flowWorkspace
As part of improvements to flowWorkspace, some behavior of
GatingSet objects has changed. For details, please read the section
titled "The cytoframe and cytoset classes" in the package vignette:

  vignette("flowWorkspace-Introduction", "flowWorkspace")

ggcyto documentation built on Nov. 8, 2020, 5:30 p.m.