do_NebulosaPlot: Wrapper for Nebulosa::plot_density in Seurat.

View source: R/do_NebulosaPlot.R

do_NebulosaPlotR Documentation

Wrapper for Nebulosa::plot_density in Seurat.

Description

Wrapper for Nebulosa::plot_density in Seurat.

Usage

do_NebulosaPlot(
  sample,
  features,
  slot = NULL,
  dims = c(1, 2),
  pt.size = 1,
  reduction = NULL,
  combine = TRUE,
  method = c("ks", "wkde"),
  joint = FALSE,
  return_only_joint = FALSE,
  plot.title = NULL,
  plot.subtitle = NULL,
  plot.caption = NULL,
  legend.type = "colorbar",
  legend.framewidth = 0.5,
  legend.tickwidth = 0.5,
  legend.length = 20,
  legend.width = 1,
  legend.framecolor = "grey50",
  legend.tickcolor = "white",
  font.size = 14,
  font.type = "sans",
  legend.position = "bottom",
  plot_cell_borders = TRUE,
  border.size = 2,
  border.color = "black",
  viridis.palette = "G",
  viridis.direction = 1,
  verbose = TRUE,
  na.value = "grey75",
  plot.axes = FALSE,
  number.breaks = 5,
  use_viridis = FALSE,
  sequential.palette = "YlGnBu",
  sequential.direction = 1,
  plot.title.face = "bold",
  plot.subtitle.face = "plain",
  plot.caption.face = "italic",
  axis.title.face = "bold",
  axis.text.face = "plain",
  legend.title.face = "bold",
  legend.text.face = "plain"
)

Arguments

sample

Seurat | A Seurat object, generated by CreateSeuratObject.

features

character | Features to represent.

slot

character | Data slot to use. Only one of: counts, data, scale.data. Defaults to "data".

dims

numeric | Vector of 2 numerics indicating the dimensions to plot out of the selected reduction. Defaults to c(1, 2) if not specified.

pt.size

numeric | Size of the dots.

reduction

character | Reduction to use. Can be the canonical ones such as "umap", "pca", or any custom ones, such as "diffusion". If you are unsure about which reductions you have, use Seurat::Reductions(sample). Defaults to "umap" if present or to the last computed reduction if the argument is not provided.

combine

logical | Whether to create a single plot out of multiple features.

method

Kernel density estimation method:

  • ks: Computes density using the kde function from the ks package.

  • wkde: Computes density using a modified version of the kde2d function from the MASS package to allow weights. Bandwidth selection from the ks package is used instead.

joint

logical | Whether to plot different features as joint density.

return_only_joint

logical | Whether to only return the joint density panel.

plot.title, plot.subtitle, plot.caption

character | Title, subtitle or caption to use in the plot.

legend.type

character | Type of legend to display. One of:

  • normal: Default legend displayed by ggplot2.

  • colorbar: Redefined colorbar legend, using guide_colorbar.

legend.framewidth, legend.tickwidth

numeric | Width of the lines of the box in the legend.

legend.length, legend.width

numeric | Length and width of the legend. Will adjust automatically depending on legend side.

legend.framecolor

character | Color of the lines of the box in the legend.

legend.tickcolor

character | Color of the ticks of the box in the legend.

font.size

numeric | Overall font size of the plot. All plot elements will have a size relationship with this font size.

font.type

character | Base font family for the plot. One of:

  • mono: Mono spaced font.

  • serif: Serif font family.

  • sans: Default font family.

legend.position

character | Position of the legend in the plot. One of:

  • top: Top of the figure.

  • bottom: Bottom of the figure.

  • left: Left of the figure.

  • right: Right of the figure.

  • none: No legend is displayed.

plot_cell_borders

logical | Whether to plot border around cells.

border.size

numeric | Width of the border of the cells.

border.color

character | Color for the border of the heatmap body.

viridis.palette

character | A capital letter from A to H or the scale name as in scale_fill_viridis.

viridis.direction

numeric | Either 1 or -1. Controls how the gradient of viridis scale is formed.

verbose

logical | Whether to show extra comments, warnings,etc.

na.value

character | Color value for NA.

plot.axes

logical | Whether to plot axes or not.

number.breaks

numeric | Controls the number of breaks in continuous color scales of ggplot2-based plots.

use_viridis

logical | Whether to use viridis color scales.

sequential.palette

character | Type of sequential color palette to use. Out of the sequential palettes defined in brewer.pal.

sequential.direction

numeric | Direction of the sequential color scale. Either 1 or -1.

plot.title.face, plot.subtitle.face, plot.caption.face, axis.title.face, axis.text.face, legend.title.face, legend.text.face

character | Controls the style of the font for the corresponding theme element. One of:

  • plain: For normal text.

  • italic: For text in itallic.

  • bold: For text in bold.

  • bold.italic: For text both in itallic and bold.

Value

A ggplot2 object containing a Nebulosa plot.

Examples


  # Check Suggests.
  value <- SCpubr:::check_suggests(function_name = "do_NebulosaPlot", passive = TRUE)

  if (isTRUE(value)){
    # Consult the full documentation in https://enblacar.github.io/SCpubr-book/

    # Define your Seurat object.
    sample <- readRDS(system.file("extdata/seurat_dataset_example.rds", package = "SCpubr"))

    # Basic Nebulosa plot.
    p <- SCpubr::do_NebulosaPlot(sample = sample,
                                 features = "EPC1")

    # Compute joint density.
    p <- SCpubr::do_NebulosaPlot(sample = sample,
                                 features = c("EPC1", "TOX2"),
                                 joint = TRUE)

  } else if (base::isFALSE(value)){
    message("This function can not be used without its suggested packages.")
    message("Check out which ones are needed using `SCpubr::state_dependencies()`.")
  }


SCpubr documentation built on Oct. 11, 2023, 5:15 p.m.