Modified and optimized version of plotFactors function from LIGER package.

plotFactors_scCustom(
  liger_object,
  num_genes = 8,
  colors_use_factors = NULL,
  colors_use_dimreduc = c("lemonchiffon", "red"),
  pt.size_factors = 1,
  pt.size_dimreduc = 1,
  reduction_label = "UMAP",
  plot_legend = TRUE,
  raster = TRUE,
  raster.dpi = c(512, 512),
  order = FALSE,
  plot_dimreduc = TRUE,
  save_plots = TRUE,
  file_path = NULL,
  file_name = NULL,
  return_plots = FALSE,
  cells.highlight = NULL,
  reorder_datasets = NULL,
  ggplot_default_colors = FALSE,
  color_seed = 123
)

Arguments

liger_object

liger liger_object. Need to perform clustering and factorization before calling this function

num_genes

Number of genes to display for each factor (Default 8).

colors_use_factors

colors to use for plotting factor loadings By default datasets will be plotted using "varibow" with shuffle = TRUE from both from DiscretePalette_scCustomize.

colors_use_dimreduc

colors to use for plotting factor loadings on dimensionality reduction coordinates (tSNE/UMAP). Default is c('lemonchiffon', 'red'),

pt.size_factors

Adjust point size for plotting in the factor plots.

pt.size_dimreduc

Adjust point size for plotting in dimensionality reduction plots.

reduction_label

What to label the x and y axes of resulting plots. LIGER does not store name of technique and therefore needs to be set manually. Default is "UMAP".

plot_legend

logical, whether to plot the legend on factor loading plots, default is TRUE. Helpful if number of datasets is large to avoid crowding the plot with legend.

raster

Convert points to raster format. Default is NULL which will rasterize by default if greater than 200,000 cells.

raster.dpi

Pixel resolution for rasterized plots, passed to geom_scattermore(). Default is c(512, 512).

order

logical. Whether to plot higher loading cells on top of cells with lower loading values in the dimensionality reduction plots (Default = FALSE).

plot_dimreduc

logical. Whether to plot factor loadings on dimensionality reduction coordinates. Default is TRUE.

save_plots

logical. Whether to save plots. Default is TRUE

file_path

directory file path and/or file name prefix. Defaults to current wd.

file_name

name suffix to append after sample name.

return_plots

logical. Whether or not to return plots to the environment. (Default is FALSE)

cells.highlight

Names of specific cells to highlight in plot (black) (default NULL).

reorder_datasets

New order to plot datasets in for the factor plots if different from current factor level order in cell.data slot.

ggplot_default_colors

logical. If colors_use_factors = NULL, Whether or not to return plot using default ggplot2 "hue" palette instead of default "varibow" palette.

color_seed

random seed for the palette shuffle if colors_use_factors = NULL. Default = 123.

Value

A list of ggplot/patchwork objects and/or PDF file.

References

Based on plotFactors functionality from original LIGER package.

Author

Velina Kozareva (Original code for modified function), Sam Marsh (Added/modified functionality)

Examples

if (FALSE) {
plotFactors_scCustom(liger_object = liger_obj, return_plots = FALSE, plot_dimreduc = TRUE,
raster = FALSE, save_plots = TRUE)
}