plot_embedding_sce: Plot selected PCs from an embedding saved in a...

View source: R/plot_embedding.R

plot_embedding_sceR Documentation

Plot selected PCs from an embedding saved in a SingleCellExperiment object

Description

Plot selected PCs from an embedding saved in a SingleCellExperiment object

Usage

plot_embedding_sce(
  sce,
  which_embedding,
  color_attr = NULL,
  color_title = color_attr,
  ellipse_attr = NULL,
  facet_attr = NULL,
  ...
)

Arguments

sce

SingleCellExperiment object; contains the embedding within the reducedDim slot

which_embedding

character; for the embedding to plot

color_attr

character; name of the attribute within colData to use for assigning colors (in lieu of color_vec in the plot_embedding function)

color_title

character; title to use for colors legend, defaults to the same as color_attr

ellipse_attr

character; name of the attribute within colData to use for drawing ellipse(s) (in lieu of ellipse_vec in the plot_embedding function)

facet_attr

character; name of the attribute within colData to use for faceting (in lieu of facet_vec in the plot_embedding function)

...

additional optional arguments - see plot_embedding function for details on other potential arguments: xpc, ypc, plot_title, color_title (if title is different from color_attr), ptsize, saveplot, plotfn, showplot, returngg, color_pal_vec, dimname

Value

default none; options to display plot (showplot), save plot (saveplot), and/or return ggplot2 object (returngg)

Examples

library(DuoClustering2018)
library(SingleCellExperiment)
sce <- sce_full_Zhengmix4eq()[1:100,sample(1:3500,100,replace = FALSE)]
colData(sce)$Method <- matrix(sample(c('Method1','Method2'),100,replace = TRUE))
sce <- corralm(sce, splitby = 'Method')

# to plot and show only
plot_embedding_sce(sce = sce, 
                   which_embedding = 'corralm', 
                   xpc = 1, 
                   plot_title = 'corralm: PC1 by PC2',
                   color_attr = "Method", 
                   ellipse_attr = 'phenoid',
                   saveplot = FALSE)

# to return ggplot2 object and display, but not save
corralm_ggplot <- plot_embedding_sce(sce = sce, 
                                     which_embedding = 'corralm', 
                                     xpc = 1, 
                                     plot_title = 'corralm: PC1 by PC2',
                                     color_attr = 'Method', 
                                     ellipse_attr = 'phenoid', 
                                     returngg = TRUE, 
                                     saveplot = FALSE)



laurenhsu1/corral documentation built on Feb. 19, 2023, 10:37 p.m.