Skip to contents

Make violin plots for each given gene grouped by cluster variable and stack along y axis.

Usage

plotClusterGeneViolin(
  object,
  gene,
  groupBy = NULL,
  colorBy = NULL,
  box = FALSE,
  boxAlpha = 0.1,
  yFunc = function(x) log1p(x * 10000),
  showLegend = !is.null(colorBy),
  xlabAngle = 40,
  ...
)

Arguments

object

A liger object.

gene

Character vector of gene names.

groupBy

The name of an available categorical variable in cellMeta slot. This forms the main x-axis columns. Use FALSE for no grouping. Default NULL looks clustering result but will not group if no clustering is found.

colorBy

The name of another categorical variable in cellMeta slot. This split the main grouping columns and color the violins. Default NULL will not split and color the violins.

box

Logical, whether to add boxplot. Default FALSE.

boxAlpha

Numeric, transparency of boxplot. Default 0.1.

yFunc

Function to transform the y-axis. Default is log1p(x*1e4). Set to NULL for no transformation.

showLegend

Whether to show the legend. Default FALSE.

xlabAngle

Numeric, counter-clockwise rotation angle in degrees of X axis label text. Default 40.

...

Arguments passed on to .ggplotLigerTheme

title,subtitle,xlab,ylab

Main title, subtitle or X/Y axis title text. By default, no main title or subtitle will be set, and X/Y axis title will be the names of variables used for plotting. Use NULL to hide elements. TRUE for xlab or ylab shows default values.

legendFillTitle

Legend title text for fill aesthetics, often used for violin, box, bar plots. Default NULL shows the original variable name.

legendPosition

Text indicating where to place the legend. Choose from "top", "bottom", "left" or "right". Default "right".

baseSize

One-parameter control of all text sizes. Individual text element sizes can be controlled by other size arguments. "Title" sizes are 2 points larger than "text" sizes when being controlled by this.

titleSize,xTitleSize,yTitleSize,legendTitleSize

Size of main title, axis titles and legend title. Default NULL controls by baseSize + 2.

subtitleSize,xTextSize,yTextSize,legendTextSize

Size of subtitle text, axis texts and legend text. Default NULL controls by baseSize.

yFacetSize

Size of facet strip label text on y-axis. Default NULL controls by baseSize - 2.

panelBorder

Whether to show rectangle border of the panel instead of using ggplot classic bottom and left axis lines. Default FALSE.

colorLabels

Character vector for modifying category names in a color legend. Passed to ggplot2::scale_color_manual(labels). Default NULL uses original levels of the factor.

colorValues

Character vector of colors for modifying category colors in a color legend. Passed to ggplot2::scale_color_manual(values). Default NULL uses internal selected palette when <= 26 categories are presented, otherwise ggplot hues.

legendNRow,legendNCol

Integer, when too many categories in one variable, arranges number of rows or columns. Default NULL, automatically split to ceiling(levels(variable)/15) columns.

plotly

Whether to use plotly to enable web based interactive browsing for the plot. Requires installation of package "plotly". Default FALSE.

Value

A ggplot object.

Details

If xlab need to be set, set xlabAngle at the same time. This is due to that the argument parsing mechanism will partially match it to main function arguments before matching the ... arguments.

Examples

plotClusterGeneViolin(pbmcPlot, varFeatures(pbmcPlot)[1:10])
#>  Subsetting dataset: "ctrl"
#>  Subsetting dataset: "stim"
#>  Subsetting dataset: "stim" ... done
#> 
#>  Subsetting dataset: "ctrl"

#>  Subsetting dataset: "ctrl" ... done
#>