do_LoadingsPlot: Compute a heatmap summary of the top and bottom genes in the...

View source: R/do_LoadingsPlot.R

do_LoadingsPlotR Documentation

Compute a heatmap summary of the top and bottom genes in the PCA loadings for the desired PCs in a Seurat object.

Description

Compute a heatmap summary of the top and bottom genes in the PCA loadings for the desired PCs in a Seurat object.

Usage

do_LoadingsPlot(
  sample,
  group.by = NULL,
  subsample = NA,
  dims = 1:10,
  top_loadings = 5,
  assay = "SCT",
  slot = "data",
  grid.color = "white",
  border.color = "black",
  number.breaks = 5,
  na.value = "grey75",
  legend.position = "bottom",
  legend.title = "Expression",
  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",
  axis.text.x.angle = 45,
  use_viridis = FALSE,
  sequential.direction = 1,
  sequential.palette = "YlGnBu",
  viridis.palette = "G",
  viridis.direction = -1,
  diverging.palette = "RdBu",
  diverging.direction = -1,
  flip = FALSE,
  min.cutoff.loadings = NA,
  max.cutoff.loadings = NA,
  min.cutoff.expression = NA,
  max.cutoff.expression = NA,
  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.

group.by

character | Metadata variable to group the output by. Has to be a character of factor column.

subsample

numeric | Number of cells to subsample the Seurat object to increase computational speed. Use NA to include the Seurat object as is.

dims

numeric | PCs to include in the analysis.

top_loadings

numeric | Number of top and bottom scored genes in the PCA Loadings for each PC.

assay

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

slot

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

grid.color

character | Color of the grid in the plot. In heatmaps, color of the border of the cells.

border.color

character | Color for the border of the heatmap body.

number.breaks

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

na.value

character | Color value for NA.

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

axis.text.x.angle

numeric | Degree to rotate the X labels. One of: 0, 45, 90.

use_viridis

logical | Whether to use viridis color scales.

sequential.direction

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

sequential.palette

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

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.

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.

flip

logical | Whether to invert the axis of the displayed plot.

min.cutoff.loadings, max.cutoff.loadings

numeric | Cutoff to subset the scale of the Loading score heatmap. NA will use quantiles 0.05 and 0.95.

min.cutoff.expression, max.cutoff.expression

numeric | Cutoff to subset the scale of the expression heatmap. NA will use 0 (no quantile) and quantile 0.95.

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.

Examples


  # Check Suggests.
  value <- SCpubr:::check_suggests(function_name = "do_LoadingsPlot", 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"))
    
    p <- SCpubr::do_LoadingsPlot(sample = sample,
                                 dims = 1:2)
    p
    
  } 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()`.")
  }


enblacar/SCpubr documentation built on Aug. 25, 2024, 9:45 p.m.