upset: upset

View source: R/plot2.R

upsetR Documentation

upset

Description

Add an upset panel to an existing plot.

Usage

upset(
  x,
  xat = NULL,
  yat = NULL,
  col = c("black", "white"),
  labels.x = NULL,
  labels.y = rownames(x),
  col.na = "grey75",
  col.rect = c("grey95", "transparent"),
  fullrange = FALSE
)

Arguments

x

a numeric or integer matrix, coerced to binary with 0s and NAs treated as false/missing, i.e., only non-zero and non-missing values are used

xat, yat

the x- and y-coordinates for the columns and rows of x, respectively

col

the colors for x > 0 and 0s/NAs, respectively; note that 0s/NAs only appear if fullrange = TRUE

labels.x, labels.y

(optional) labels for the columns and rows

col.na, col.rect

colors for background placeholder points and bars for each row of x; default is alternating grey and white

fullrange

logical; if TRUE, open circles will be shown for any 0s or NAs in x

Examples

x <- t(mtcars[, c('cyl', 'vs', 'am', 'gear')])
y <- t(!!mtcars[, c('cyl', 'vs', 'am')])

op <- par(mar = c(9, 5, 4, 1), las = 1L)

bp <- barplot(x, col = 2:5, axisnames = FALSE)
text(bp, -4, colnames(x), srt = 45, xpd = NA, adj = 1)
box(bty = 'u')

yat <- seq(1, 3, length.out = nrow(y))
upset(y, xat = bp, yat = -yat, col.na = NA, fullrange = TRUE)
upset(y, xat = bp, yat = par('usr')[4L] + yat, col.rect = adjustcolor(2:4, 0.5))

par(op)


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.