plotProportionBox: Box plot of cluster proportion in each dataset, grouped by...

View source: R/visualization.R

plotProportionBoxR Documentation

Box plot of cluster proportion in each dataset, grouped by condition

Description

This function calculate the proportion of each category (e.g. cluster, cell type) within each dataset, and then make box plot grouped by condition. The proportion of all categories within one dataset sums up to 1. The condition variable must be a variable of dataset, i.e. each dataset must belong to only one condition.

Usage

plotProportionBox(
  object,
  useCluster = NULL,
  conditionBy = NULL,
  sampleBy = "dataset",
  splitByCluster = FALSE,
  dot = FALSE,
  dotSize = getOption("ligerDotSize", 1),
  dotJitter = FALSE,
  ...
)

Arguments

object

A liger object.

useCluster

Name of variable in cellMeta(object). Default NULL uses default cluster.

conditionBy

Name of the variable in cellMeta(object) that represents the condition. Must be a high level variable of the sampleBy variable, i.e. each sample must belong to only one condition. Default NULL does not group samples by condition.

sampleBy

Name of the variable in cellMeta(object) that represents individual samples. Default "dataset".

splitByCluster

Logical, whether to split the wide grouped box plot by cluster, into a list of boxplots for each cluster. Default FALSE.

dot

Logical, whether to add dot plot on top of the box plot. Default FALSE.

dotSize

Size of the dot. Default uses user option "ligerDotSize", or 1 if not set.

dotJitter

Logical, whether to jitter the dot to avoid overlapping within a box when many dots are presented. Default FALSE.

...

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.

showLegend

Whether to show the legend. Default TRUE.

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.

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.

colorPalette

For continuous coloring, an index or a palette name to select from available options from ggplot scale_brewer or viridis. Default "magma".

colorDirection

Choose 1 or -1. Applied when colorPalette is from Viridis options. Default -1 use darker color for higher value, while 1 reverses this direction.

colorLow,colorMid,colorHigh,colorMidPoint

All four of these must be specified to customize palette with

naColor

The color code for NA values. Default "#DEDEDE". scale_colour_gradient2. Default NULL.

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 or a list of ggplot objects if splitByCluster = TRUE.

Examples

# "boxes" are expected to appear as horizontal lines, because there's no
# "condition" variable that groups the datasets in the example object, and
# thus only one value exists for each "box".
plotProportionBox(pbmcPlot, conditionBy = "dataset")

rliger documentation built on Oct. 30, 2024, 1:07 a.m.