ticks_breaks_labels: Support for ggplot-style axis labeling

View source: R/vis_gg.R

ticks_breaks_labelsR Documentation

Support for ggplot-style axis labeling

Description

Placing tick marks and labels appropriate for several popular transformations.

This function provides support for ggplot style axis generation. It is used in ggflow(), but sometimes you want to make custom plots that respect the transformation you've used on your data.

Usage

ticks_breaks_labels(
  ff,
  param,
  method = c("biexp", "asinh", "log", "linear"),
  a = 0.002,
  cofactor = 5
)

Arguments

ff

The flowFrame to be plotted

param

The parameter of ff to be plotted

method

The transformation that was applied to the scattering parameters of ff. Currently, one of c("linear", "biexp", "asinh", "log", "linear").

Value

A list comprised of: major = vector of locations of major ticks ticks = vector of locations of minor ticks labels = vector of major tick labels range = vector of length 2, indicating min and max of range. Default values can be overridden if desired.

Examples


# get some example data
filename = system.file("extdata", "example1.fcs", package = "wadeTools")
ff = get_sample(filename)
# Recall that get_sample by default applies linear transformation to scattering
# parameters and biexponential transformation to fluorescence parameters.

a = ticks_breaks_labels(ff, param = "CD3Q605")

# make a plot of a kernel density estimate of a univariate parameter
kde_3 = normalize.kde(bkde(exprs(ff)[,"CD3Q605"], band = 0.1, grid = 1001))

# limit range of kde for plotting
tmp = data.frame(kde_3)
tmp = tmp[tmp$x > a$range[1] & tmp$x < a$range[2], ]
p = ggplot(tmp, aes(x = x, y = y)) +
         geom_path() + xlab("") + ylab("") +
         labs(title = "CD3") +
         theme(plot.title = element_text(size = 30, hjust = 0.5), axis.text = element_text(size = 20))
xax = scale_x_continuous(breaks = a$major, limits = a$range, minor_breaks = a$ticks, labels = a$labels)
p + xax



rogerswt/wadeTools documentation built on Feb. 16, 2023, 7:47 a.m.