Plot the percentage/absolute cell count of each cluster in each sample

ClusterDistrBar(
  origin,
  cluster,
  rev = F,
  normalize = rev,
  percent = T,
  plot = T,
  flip = T,
  reverse_order = T,
  width = 0.9,
  stack = T,
  cols = "pro_default",
  border = "white"
)

Arguments

origin

factor/vector of sample

cluster

factor/vector of cluster

rev

If TRUE, plot the proportion of sample in each cluster, Default: F

normalize

Normalize sample size to 100, Default: rev

percent

If FALSE, plot absolute cell number instead of percentage, Default: T

plot

Generate plot (TRUE) or matrix (FALSE), Default: T

flip

If plot bars horizontally, Default: T

reverse_order

If TRUE, will reverse the default stacking order. Default: T

width

Width of bars, Default: 0.9

stack

If TRUE, plot stacked bars, Default: T

cols

Colors to use for plotting. Default: "pro_default"

border

Border color, Default: "white"

Value

ggplot object or matrix

Details

See example

Examples

ClusterDistrBar(origin = pbmc$orig.ident, cluster = pbmc$cluster)

# absolute cell count
ClusterDistrBar(origin = pbmc$orig.ident, cluster = pbmc$cluster, percent = F)

# reverse x and y axis, normalized by sample size
ClusterDistrBar(origin = pbmc$orig.ident, cluster = pbmc$cluster, rev = T, normalize = T)

# reverse x and y axis, not normalized by sample size
ClusterDistrBar(origin = pbmc$orig.ident, cluster = pbmc$cluster, rev = T, normalize = F)

# vertical bar plot, and keep the default stacking order
ClusterDistrBar(origin = pbmc$orig.ident, cluster = pbmc$cluster, flip = F, reverse_order = F)

# not stacking bars
ClusterDistrBar(origin = pbmc$orig.ident, cluster = pbmc$cluster, flip = FALSE, stack = FALSE)

# export matrix
ClusterDistrBar(origin = pbmc$orig.ident, cluster = pbmc$cluster, plot = F)