do_BarPlot {SCpubr} | R Documentation |
Create Bar Plots.
Description
Create Bar Plots.
Usage
do_BarPlot(
sample,
group.by,
order = FALSE,
add.n = FALSE,
add.n.face = "bold",
add.n.expand = c(0, 1.15),
add.n.size = 4,
order.by = NULL,
split.by = NULL,
facet.by = NULL,
position = "stack",
font.size = 14,
font.type = "sans",
legend.position = "bottom",
legend.title = NULL,
legend.ncol = NULL,
legend.nrow = NULL,
legend.byrow = FALSE,
axis.text.x.angle = 45,
xlab = NULL,
ylab = NULL,
colors.use = NULL,
flip = FALSE,
plot.title = NULL,
plot.subtitle = NULL,
plot.caption = NULL,
plot.grid = FALSE,
grid.color = "grey75",
grid.type = "dashed",
plot.title.face = "bold",
plot.subtitle.face = "plain",
plot.caption.face = "italic",
axis.title.face = "bold",
axis.text.face = "plain",
legend.title.face = "bold",
legend.text.face = "plain",
strip.text.face = "bold",
return_data = FALSE
)
Arguments
sample |
|
group.by |
|
order |
|
add.n |
|
add.n.face |
|
add.n.expand |
|
add.n.size |
|
order.by |
|
split.by |
|
facet.by |
|
position |
|
font.size |
|
font.type |
|
legend.position |
|
legend.title |
|
legend.ncol |
|
legend.nrow |
|
legend.byrow |
|
axis.text.x.angle |
|
xlab , ylab |
|
colors.use |
|
flip |
|
plot.title , plot.subtitle , plot.caption |
|
plot.grid |
|
grid.color |
|
grid.type |
|
plot.title.face , plot.subtitle.face , plot.caption.face , axis.title.face , axis.text.face , legend.title.face , legend.text.face |
|
strip.text.face |
|
return_data |
|
Value
A ggplot2 object containing a Bar plot.
Examples
# Check Suggests.
value <- SCpubr:::check_suggests(function_name = "do_BarPlot", passive = TRUE)
if (isTRUE(value)){
# Consult the full documentation in https://enblacar.github.io/SCpubr-book/
# Define your Seurat object.
sample <- readRDS(system.file("extdata/seurat_dataset_example.rds", package = "SCpubr"))
# Basic bar plot, horizontal.
p1 <- SCpubr::do_BarPlot(sample = sample,
group.by = "seurat_clusters",
legend.position = "none",
plot.title = "Number of cells per cluster")
# Split by a second variable.
sample$modified_orig.ident <- sample(x = c("Sample_A", "Sample_B", "Sample_C"),
size = ncol(sample),
replace = TRUE,
prob = c(0.2, 0.7, 0.1))
p <- SCpubr::do_BarPlot(sample,
group.by = "seurat_clusters",
split.by = "modified_orig.ident",
plot.title = "Number of cells per cluster in each sample",
position = "stack")
} else if (base::isFALSE(value)){
message("This function can not be used without its suggested packages.")
message("Check out which ones are needed using `SCpubr::state_dependencies()`.")
}