Skip to contents

Make grid of violin plots Thanks to the SCOPfunctions package https://github.com/CBMR-Single-Cell-Omics-Platform/SCOPfunctions/blob/main/R/plot.R

produce a n_celltype * n_genes grid of violin plots

Usage

plot_vln_Corgenes(
  seurat_obj,
  assay,
  slot,
  var_group,
  vec_features,
  vec_group_colors = NULL,
  f_color = grDevices::colorRampPalette(RColorBrewer::brewer.pal(n = 11, name =
    "RdYlBu")),
  flip = T,
  do_plot = FALSE,
  pt.size = 0,
  feature_fontface = "bold.italic",
  fontsize_axistext_x = 12,
  fontsize_axistext_y = 12,
  aspect.ratio = NULL,
  figurenames = NULL,
  width = 7,
  height = 7
)

Arguments

seurat_obj

Seurat object (Seurat ^3.0)

assay

seurat_obj assay to use

slot

seurat_obj slot to use

var_group

the group variable, character

vec_features

a vector of features to plot in the violin plot

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

flip

if TRUE (default), groups are rows and features are columns, and vice-verso for FALSE

do_plot

Whether to plot, logical

pt.size

size of jitter in the violin plots. Set to 0 (default) to omit

feature_fontface

"bold.italic"

fontsize_axistext_x

12, font size for x axis

fontsize_axistext_y

12, font size for y axis

aspect.ratio

NULL

figurenames

The filename and address of the output plot,

width

figure width

height

figure height

Value

ggplot2 object

Examples

load(system.file("extdata", "Pagwas_data.RData", package = "scPagwas"))
suppressMessages(library("ggsci"))
suppressMessages(library("Seurat"))
top5genes <- rownames(Pagwas_data@misc$gene_heritability_correlation)[order(
  Pagwas_data@misc$gene_heritability_correlation,
  decreasing = TRUE
)[1:5]]
plot_vln_Corgenes(
  seurat_obj = Pagwas_data,
  assay = "RNA", slot = "data",
  var_group = "anno",
  vec_features = top5genes,
  do_plot = TRUE
)
#> Using aspect ratio 3