plot_density: Plot gene-weighted 2D kernel density

plot_densityR Documentation

Plot gene-weighted 2D kernel density

Description

Plot gene-weighted 2D kernel density

Usage

plot_density(
  object,
  features,
  slot = NULL,
  joint = FALSE,
  reduction = NULL,
  dims = c(1, 2),
  method = c("ks", "wkde"),
  adjust = 1,
  size = 1,
  shape = 16,
  combine = TRUE,
  pal = "viridis",
  raster = TRUE,
  ...
)

## S4 method for signature 'Seurat'
plot_density(
  object,
  features,
  slot = NULL,
  joint = FALSE,
  reduction = NULL,
  dims = c(1, 2),
  method = c("ks", "wkde"),
  adjust = 1,
  size = 1,
  shape = 16,
  combine = TRUE,
  pal = "viridis",
  raster = TRUE,
  ...
)

## S4 method for signature 'SingleCellExperiment'
plot_density(
  object,
  features,
  slot = NULL,
  joint = FALSE,
  reduction = NULL,
  dims = c(1, 2),
  method = c("ks", "wkde"),
  adjust = 1,
  size = 1,
  shape = 16,
  combine = TRUE,
  pal = "viridis",
  raster = TRUE,
  ...
)

Arguments

object

Seurat or SingleCellExperiment object

features

Features (e.g. genes) to visualize

slot

Type of data: counts ordata for Seurat objects and counts, logcounts, or normcounts for SingleCellExperiment objects

joint

Return joint density plot? By default FALSE

reduction

Name of the reduction to visualize. If not provided, last computed reduction is visualized

dims

Vector of length 2 specifying the dimensions to be plotted. By default, the first two dimensions are considered.

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.

adjust

Numeric value to adjust to bandwidth. Default: 1. Not available for ks method

size

Size of the geom to be plotted (e.g. point size)

shape

Shape of the geom to be plotted

combine

Create a single plot? If FALSE, a list with ggplot objects is returned

pal

String specifying the viridis color palette to use.

raster

Rasterise plot

...

Further scale arguments passed to scale_color_viridis_c Options:

  • viridis

  • magma

  • cividis

  • inferno

  • plasma

Value

A scatterplot from a given reduction showing the gene-weighted density

Methods (by class)

  • plot_density(Seurat): Plot gene-weighted 2D kernel density

  • plot_density(SingleCellExperiment): Plot gene-weighted 2D kernel density

Author(s)

Jose Alquicira-Hernandez

Examples


data <- SeuratObject::pbmc_small
plot_density(data, "CD3E")

powellgenomicslab/Nebulosa documentation built on March 3, 2024, 8:23 p.m.