plot_partitioned_pc: Plot partitioned principal component

View source: R/rnaseq_workflow_qc.R

plot_partitioned_pcR Documentation

Plot partitioned principal component

Description

Create a histogram and boxplot with per sample principal component values partitioned by a categorical variable.

Usage

plot_partitioned_pc(
  data,
  pc = 1,
  group_var,
  center = T,
  scale = T,
  feature_ids = NULL,
  sample_ids = NULL,
  invert_rows = F,
  invert_cols = F,
  return_data = F,
  binsize = NULL,
  colors = NULL,
  hist_alpha = 0.75,
  box_fill = "gray50",
  box_alpha = 0.5,
  box_lwd = 1,
  jitter_alpha = 0.5,
  jitter_size = 1.75,
  x_title = NULL,
  y_title = "Sample count"
)

Arguments

data

A SummarizedExperiment-like object. Must be compatible with assay() and colData().

pc

An integer for the principal component (ranked from highest to lowest variance contribution) to use for plotting.

group_var

A string for the categorical variable to use for partitioning.

center

A logical. Should the data be zero-centered prior to PCA?

scale

A logical. Should the data be scaled to unit variance prior to PCA?

feature_ids

A vector of row names for subsetting data for plotting.

sample_ids

A vector of column names for subsetting data for plotting.

invert_rows

A logical. Should feature_ids be used for excluding rows from plotting instead?

invert_cols

A logical. Should sample_ids be used for excluding columns from plotting instead?

return_data

A logical. Should plot data be returned instead of a ggplot object?

binsize

A numeric value for the histogram bin widths.

colors

A string vector. The histogram bar colors and jitter colors for each categorical variable value.

hist_alpha

A numeric value for the alpha level for histogram bars.

box_fill

A string. The fill color for the boxplot.

box_alpha

A numeric value for the alpha level for the boxplot.

box_lwd

A numeric value for the boxplot line width.

jitter_alpha

A numeric for the alpha level for jittered data points.

jitter_size

A numeric for the point size for jittered data points.

x_title

A string denoting the x-axis title. Only added to the boxplot.

y_title

A string denoting the y-axis title. Only added to the histogram.

Details

Runs PCA using a user-specified set of expression features (e.g., genes) and plots a user-specified PC as a histogram and boxplot. The two plots are intended to be used as a single column, two row figure panel. Data points in the plots are partitioned by a categorical variable.

Value

A list with two ggplot objects hist and boxplot corresponding to a histogram and jittered boxplot respectively. If return_data is TRUE, then a data frame with the plot data values and grouping variable.

See Also

hist_boxplot2 prcomp


bryancquach/omixjutsu documentation built on Jan. 29, 2023, 3:47 p.m.