View source: R/stat_position.R
stat_position | R Documentation |
It is usually not called directly by user but mainly used by compute_stats function (which is called by ggcyto add method when geom_states layer is added).
stat_position(gate, ...)
## S3 method for class 'filter'
stat_position(
gate,
negated = FALSE,
adjust = 0.5,
location = "gate",
data_range = NULL,
limits = NULL,
...
)
gate |
a flowCore filter |
... |
other arguments |
negated |
logical indicating whether position needs to be moved to negative side of gate |
adjust |
see details |
location |
see details |
data_range |
a two-row data.frame representing the actual data range. Each column is a a range for a specific channel. First row is min, Second row is max. |
limits |
used to fix the gate range |
The adjust
and location
arguments allow for a few different ways to adjust the location of the statistical
annotation for a gate on a ggcyto
plot. The valid values for location
are "gate" (default), "data", "plot", and "fixed".
If location
is not "fixed", the starting position of the annotation will be determined with respect to a rectangular window whose
bounds are determined in the following way:
For location = "gate"
, the window will be set by the range of the data in the gate
For location = "data"
, the window will be set by the range of values in all of the data on the plot (provided by data_range
)
For location = "plot"
, the window will be set by the axis limits of the plot (adjusted by ggcyto_par_set
)
This starting position can then be adjusted by passing values in a vector to the adjust
parameter, where they will be
interpreted as relative proportions of the window dimension, where 0.0 represents the lower bound of the dimension and 1.0 represents
the upper bound. So, for a 2-D plot, adjust=c(0,0)
places the annotation at the lower left corner of this window and adjust=c(1,1)
places
it at the upper right corner.
As another example, for a 2-D gate, if location = "gate"
and adjust=c(0.25, 0.75)
, the statistical annotation will be
placed 1/4 of the way across the x-range of the gate and 3/4 of the way across the y-range of the gate.
The adjust
argument will also accept values less than 0.0 or greater than 1.0. This can be an easy way
to simply move the annotation outside of a gate so it does not obstruct the view of the data within. For example, location == "gate"
and adjust=c(-0.2, 1.2)
will move the annotation outside of the upper left corner of the gate range.
If location = "fixed"
, the numeric vector passed to adjust
will be interpreted as values on the data scales of the plot to provide
an explicit location for the annotation.
For example, if the annotation should be at the location 3000, 5000 on the plot, that could be done with location="fixed"
and
adjust = c(3000,5000)
.
The default behavior if no values are provided to location
or adjust
will be to place the annotation at
the center of the range of the data in the gate.
a data.table of gate centroid coordinates
data(GvHD)
fs <- GvHD[1:4]
rect.g <- rectangleGate(list("FSC-H" = c(300,500), "SSC-H" = c(50,200)))
rect.gates <- sapply(sampleNames(fs), function(sn)rect.g)
stat_position(rect.gates)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.