Skip to contents

Plot the cell counts normalized by volume for a given channel

Usage

plot_normalized_counts(
  e,
  channels = c("cfos", "eyfp", "colabel"),
  by = c("sex", "group"),
  values = list(c("female", "non"), c("female", "agg"), c("female", "control"), c("male",
    "agg"), c("male", "control")),
  colors = c("white", "lightblue", "black", "red", "green"),
  ontology = "allen",
  title = NULL,
  unit_label = bquote(`Cell counts `("cells/mm"^3)),
  anatomical.order = c("Isocortex", "OLF", "HPF", "CTXsp", "CNU", "TH", "HY", "MB", "HB",
    "CB"),
  height = 7,
  width = 20,
  print_plot = TRUE,
  save_plot = TRUE,
  flip_axis = FALSE,
  reverse_colors = FALSE,
  limits = c(0, 1e+05),
  facet_background_color = NULL,
  strip_background_colors = "lightblue",
  plot_theme = ggplot2::theme(plot.background = element_blank(), panel.grid.major =
    element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(),
    axis.line = element_line(color = "black"), legend.justification = c(0, 0),
    legend.position = "inside", legend.position.inside = c(0.05, 0.6), legend.direction =
    "vertical", axis.text.y = element_text(angle = 50, hjust = 1, size = 8, color =
    "black"), axis.text.x = element_text(color = "black"), strip.text.y =
    element_text(angle = 0, margin = ggplot2::margin(t = 5, 
     r = 5, b = 5, l = 5,
    unit = "pt")), strip.placement = "outside", strip.switch.pad.grid = unit(0.1, "in")),
  image_ext = ".pdf"
)

Arguments

e

experiment object

channels

(str, default = c("cfos", "eyfp", "colabel"))

by

(str) Attribute names to group by, e.g. c("sex", "group")

values

(list) A list with a length the number of groups desired for plotting. Each element of the list is a vector in the order of the the respective values for the attributes entered for the by parameter to generate a specific analysis group. Each vector should be unique to generate a uniquely colored bar. e.g.values = c("female", "AD").

colors

(str, default = c("white", "lightblue")) Hexadecimal codes corresponding to the groups (respectively) to plot. The length of this vector should be the length of the list.

ontology

(str, default = "allen") Region ontology to use. options = "allen" or "unified"

title

(str, default = NULL) An optional title for the plot

unit_label

(str, default = bquote('Cell counts '('cells/mm'^3))) Default unit label for the graphs

anatomical.order

(default = c("Isocortex", "OLF", "HPF", "CTXsp", "CNU","TH", "HY", "MB", "HB", "CB")) Default way to group subregions into super regions order

height

height of the plot in inches.

width

width of the plot in inches.

print_plot

(bool, default = TRUE) Whether to display the plot (in addition to saving the plot)

save_plot

(bool, default = TRUE) Save into the figures subdirectory of the experiment object output folder.

flip_axis

plot cell counts on x-axis rather than y-axis.

reverse_colors

(bool, default = FALSE) Whether to reverse the color order. This may depend on the order in which you entered the colors parameter

limits

(c(0,100000)) Range of the normalized cell counts.

facet_background_color

(default = NULL) Set to a hexadecimal string, e.g."#FFFFFF", when you want to shade the background of the graph. Defaults to no background when NULL.

strip_background_colors

(default = "lightblue) Enter custom codes to control the strip background colors, e.g. c(Isocortex = "#5571a9", OLF = "#64bdc4", HPF = "#d2875b", CTXsp = "#87a3db", CNU = "#466496", TH = "#7e72af", HY = "#8e7960", MB = "#d796c8", HB = "#646464"). If more than one color is used, you must install the package ggh4x.

plot_theme

(ggplot2 theme object) This allows for fine tuning the aesthetics of the figure. Default parameters shown: ggplot2::theme(plot.background = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), axis.line = element_line(color = 'black'), legend.justification = c(0, 0), legend.position = "inside", legend.position.inside = c(0.05, 0.6), legend.direction = "vertical", axis.text.y = element_text(angle = 50, hjust = 1, size = 8, color = "black"), axis.text.x = element_text(color = "black"), strip.text.y = element_text(angle = 0, margin = ggplot2::margin(t = 5, r = 5, b = 5, l = 5, unit = "pt")), strip.placement = "outside", strip.switch.pad.grid = unit(0.1, "in"))

image_ext

(default = ".png") image extension to the plot as.

Value

p_list A list the same length as the number of channels, with each element containing a plot handle for that channel.

Examples

p_list <- plot_normalized_counts(e, channels = "cfos", by = c("sex", "group"), values = list(c("female", "non"), c("female", "agg")), colors = c("white", "lightblue"))
#> Error in dplyr::ungroup(.): object 'e' not found