do_FeaturePlot: Wrapper for FeaturePlot.

View source: R/do_FeaturePlot.R

do_FeaturePlotR Documentation

Wrapper for FeaturePlot.

Description

Wrapper for FeaturePlot.

Usage

do_FeaturePlot(
  sample,
  features,
  assay = NULL,
  reduction = NULL,
  slot = NULL,
  order = FALSE,
  group.by = NULL,
  group.by.colors.use = NULL,
  group.by.legend = NULL,
  group.by.show.dots = TRUE,
  group.by.dot.size = 8,
  group.by.cell_borders = FALSE,
  group.by.cell_borders.alpha = 0.1,
  split.by = NULL,
  idents.keep = NULL,
  cells.highlight = NULL,
  idents.highlight = NULL,
  dims = c(1, 2),
  enforce_symmetry = FALSE,
  symmetry.type = "absolute",
  symmetry.center = NA,
  pt.size = 1,
  font.size = 14,
  font.type = "sans",
  legend.title = NULL,
  legend.type = "colorbar",
  legend.position = "bottom",
  legend.framewidth = 0.5,
  legend.tickwidth = 0.5,
  legend.length = 20,
  legend.width = 1,
  legend.framecolor = "grey50",
  legend.tickcolor = "white",
  legend.ncol = NULL,
  legend.nrow = NULL,
  legend.byrow = FALSE,
  plot.title = NULL,
  plot.subtitle = NULL,
  plot.caption = NULL,
  individual.titles = NULL,
  individual.subtitles = NULL,
  individual.captions = NULL,
  ncol = NULL,
  use_viridis = FALSE,
  viridis.palette = "G",
  viridis.direction = 1,
  raster = FALSE,
  raster.dpi = 1024,
  plot_cell_borders = TRUE,
  border.size = 2,
  border.color = "black",
  border.density = 1,
  na.value = "grey75",
  verbose = TRUE,
  plot.axes = FALSE,
  min.cutoff = rep(NA, length(features)),
  max.cutoff = rep(NA, length(features)),
  plot_density_contour = FALSE,
  contour.position = "bottom",
  contour.color = "grey90",
  contour.lineend = "butt",
  contour.linejoin = "round",
  contour_expand_axes = 0.25,
  label = FALSE,
  label.color = "black",
  label.size = 4,
  number.breaks = 5,
  diverging.palette = "RdBu",
  diverging.direction = -1,
  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.

assay

character | Assay to use. Defaults to the current assay.

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.

slot

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

order

logical | Whether to order the cells based on expression.

group.by

character | Metadata variable based on which cells are grouped. This will effectively introduce a big dot in the center of each cluster, colored using a categorical color scale or with the values provided by the user in group.by.colors.use. It will also displays a legend.

group.by.colors.use

character | Colors to use for the group dots.

group.by.legend

character | Title for the legend when group.by is used. Use NA to disable it and NULL to use the default column title provided in group.by.

group.by.show.dots

logical | Controls whether to place in the middle of the groups.

group.by.dot.size

numeric | Size of the dots placed in the middle of the groups.

group.by.cell_borders

logical | Plots another border around the cells displaying the same color code of the dots displayed with group.by. Legend is shown always with alpha = 1 regardless of the alpha settings.

group.by.cell_borders.alpha

numeric | Controls the transparency of the new borders drawn by group.by.cell_borders.

split.by

character | Secondary metadata variable to further group (split) the output by. Has to be a character of factor column.

idents.keep

character | Vector of identities to plot. The gradient scale will also be subset to only the values of such identities.

cells.highlight, idents.highlight

character | Vector of cells/identities to focus into. The identities have to much those in Seurat::Idents(sample) The rest of the cells will be grayed out. Both parameters can be used at the same time.

dims

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

enforce_symmetry

logical | Return a symmetrical plot axes-wise or continuous color scale-wise, when applicable.

symmetry.type

character | Type of symmetry to be enforced. One of:

  • absolute: The highest absolute value will be taken into a account to generate the color scale. Works after min.cutoff and max.cutoff.

  • centered: Centers the scale around the provided value in symmetry.center. Works after min.cutoff and max.cutoff.

symmetry.center

numeric | Value upon which the scale will be centered.

pt.size

numeric | Size of the dots.

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.title

character | Title for the legend.

legend.type

character | Type of legend to display. One of:

  • normal: Default legend displayed by ggplot2.

  • colorbar: Redefined colorbar legend, using guide_colorbar.

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.

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.

legend.ncol

numeric | Number of columns in the legend.

legend.nrow

numeric | Number of rows in the legend.

legend.byrow

logical | Whether the legend is filled by row or not.

plot.title, plot.subtitle, plot.caption

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

individual.titles, individual.subtitles, individual.captions

character | Titles or subtitles. for each feature if needed. Either NULL or a vector of equal length of features.

ncol

numeric | Number of columns used in the arrangement of the output plot using "split.by" parameter.

use_viridis

logical | Whether to use viridis color scales.

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.

raster

logical | Whether to raster the resulting plot. This is recommendable if plotting a lot of cells.

raster.dpi

numeric | Pixel resolution for rasterized plots. Defaults to 1024. Only activates on Seurat versions higher or equal than 4.1.0.

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.

border.density

numeric | Controls the number of cells used when plot_cell_borders = TRUE. Value between 0 and 1. It computes a 2D kernel density and based on this cells that have a density below the specified quantile will be used to generate the cluster contour. The lower this number, the less cells will be selected, thus reducing the overall size of the plot but also potentially preventing all the contours to be properly drawn.

na.value

character | Color value for NA.

verbose

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

plot.axes

logical | Whether to plot axes or not.

min.cutoff, max.cutoff

numeric | Set the min/max ends of the color scale. Any cell/group with a value lower than min.cutoff will turn into min.cutoff and any cell with a value higher than max.cutoff will turn into max.cutoff. In FeaturePlots, provide as many values as features. Use NAs to skip a feature.

plot_density_contour

logical | Whether to plot density contours in the UMAP.

contour.position

character | Whether to plot density contours on top or at the bottom of the visualization layers, thus overlapping the clusters/cells or not.

contour.color

character | Color of the density lines.

contour.lineend

character | Line end style (round, butt, square).

contour.linejoin

character | Line join style (round, mitre, bevel).

contour_expand_axes

numeric | To make the contours fit the plot, the limits of the X and Y axis are expanding a given percentage from the min and max values for each axis. This controls such percentage.

label

logical | Whether to plot the cluster labels in the UMAP. The cluster labels will have the same color as the cluster colors.

label.color

character | Color of the labels in the plot.

label.size

numeric | Size of the labels in the plot.

number.breaks

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

diverging.palette

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

diverging.direction

numeric | Either 1 or -1. Direction of the divering palette. This basically flips the two ends.

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 Feature Plot.

Examples


  # Check Suggests.
  value <- SCpubr:::check_suggests(function_name = "do_FeaturePlot", 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"))

    # Regular FeaturePlot.
    p <- SCpubr::do_FeaturePlot(sample = sample,
                                features = "nCount_RNA")

    # FeaturePlot with a subset of identities
    # (in Seurat::Idents(sample)) maintaining the original UMAP shape.
    idents.use <- levels(sample)[!(levels(sample) %in% c("2", "5", "8"))]
    p <- SCpubr::do_FeaturePlot(sample = sample,
                                idents.highlight = idents.use,
                                features = c("EPC1"))

    # Splitting the FeaturePlot by a variable and
    # maintaining the color scale and the UMAP shape.
    p <- SCpubr::do_FeaturePlot(sample = sample,
                                features = "EPC1",
                                split.by = "seurat_clusters")

  } 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.