Skip to contents

Generate barplot of identity group composition Thanks to the SCOPfunctions package https://github.com/CBMR-Single-Cell-Omics-Platform/SCOPfunctions/blob/main/R/plot.R Generate a percentage barplot that shows the composition of each identity (e.g. sample)in terms of groups (e.g. positive and negative cells for scPagwas)

Usage

plot_bar_positie_nagtive(
  seurat_obj,
  var_ident,
  var_group,
  vec_group_colors = NULL,
  f_color = grDevices::colorRampPalette(RColorBrewer::brewer.pal(n = 11, name =
    "RdYlBu")),
  do_plot = FALSE,
  title = NULL,
  p_thre = 0.05,
  fontsize_title = 24,
  fontsize_axistitle_x = 18,
  fontsize_axistitle_y = 18,
  fontsize_axistext_x = 12,
  fontsize_axistext_y = 12,
  fontsize_legendtitle = 12,
  fontsize_legendtext = 10,
  aspect.ratio = 1.2,
  output.prefix = "Test",
  output.dirs = NULL,
  width = 7,
  height = 7
)

Arguments

seurat_obj

Seurat object (Seurat ^3.0).

var_ident

the identify variable, character.

var_group

the group variable, character.

vec_group_colors

a vector of colors, named by corresponding group. Length must match number of groups. Character.

f_color

if vec_group_colors is not provided, the user may instead provide a function f_color() that takes as its only argument the number of colors to generate.

do_plot

Whether to plot, logical.

title

NULL to leave out.

p_thre

threshold for p value.

fontsize_title

NULL to leave out.

fontsize_axistitle_x

NULL to leave out.

fontsize_axistitle_y

NULL to leave out.

fontsize_axistext_x

NULL to leave out.

fontsize_axistext_y

NULL to leave out.

fontsize_legendtitle

NULL to leave out.

fontsize_legendtext

NULL to leave out.

aspect.ratio

default is 1.2.

output.prefix

prefix for output files.

output.dirs

directory for files.

width

figure width.

height

figure height.

Value

a ggplot2 object

Examples

load(system.file("extdata", "Pagwas_data.RData", package = "scPagwas"))
plot_bar_positie_nagtive(
  seurat_obj = Pagwas_data,
  var_ident = "anno",
  var_group = "positiveCells",
  vec_group_colors = c("#E8D0B3", "#7EB5A6"),
  do_plot = FALSE
)
#> Error in x[[i, drop = TRUE]]: ‘Random_Correct_BG_adjp’ not found in this Seurat object
#>