jj_plot_stacked_barplot: encirle fraction of points that contain x percent of the...

View source: R/jj_plot_stacked_barplot.R

jj_plot_stacked_barplotR Documentation

encirle fraction of points that contain x percent of the density mass

Description

estimate densities to include density area in tsne/umap

Usage

jj_plot_stacked_barplot(
  df,
  group_column,
  value_column,
  sample_column,
  custom_colors = NULL,
  return_df = FALSE,
  show_error_bars = TRUE,
  show_fraction = TRUE,
  error_bar_color = NULL
)

Arguments

df

data.frame containing group_column, value_column, sample_column

group_column

column containing the grouping variable (i.e. the x-axis)

value_column

column containing the categorical data to summarize per group. Within each group, the relative count of observations for each level in the value_column is summarized

sample_column

column containing annotation for the sample from which the observations are derived. Used to calculate the SEM

custom_colors

optional named vector with custom colours

return_df

return the summarized data as data.frame instead of a ggplot

show_error_bars

if TRUE, plot the SEM error bars

show_fraction

if TRUE, add the fraction of observations as a number to each bar

error_bar_color

if not NULL, overwrite the standard colour of the error bars

Value

Returns a stacked barplot with error bars indicating the SEM

Examples

pbmc_small$sample = sample(1:3, ncol(pbmc_small), replace = T)
jj_plot_stacked_barplot(df = pbmc_small[[]], group_column = 'groups', 
                        value_column = 'RNA_snn_res.1', sample_column = 'sample', 
                        show_error_bars = T, show_fraction = T, return_df = F, 
                        error_bar_color = 'black')
jj_plot_stacked_barplot(df = pbmc_small[[]], group_column = 'groups',
                        value_column = 'RNA_snn_res.1', sample_column = 'sample',
                        show_error_bars = T, show_fraction = F, return_df = F,
                        custom_colors = jj_get_jj_colours(levels(pbmc_small$RNA_snn_res.1)))

mathosi/jj documentation built on Feb. 25, 2024, 2:29 p.m.