HighlightCellsOnSeuratPlot: HighlightCellsOnSeuratPlot

View source: R/SeuratUtils.R

HighlightCellsOnSeuratPlotR Documentation

HighlightCellsOnSeuratPlot

Description

Can be used to highlight a set of cells from a seurat plot, such as overlaying specific clonotypes. Note: this uses ggnewscale::new_scale_color to enable multiple color scales. The original aesthetics are suffixed with '_new' (i.e. color_new). This has also only been tested thoroughly with DimPlots.

Usage

HighlightCellsOnSeuratPlot(
  seuratObj,
  seuratPlot,
  cellSelectField = "CloneNames",
  colorLegendLabel = "Clone",
  colorField = NA,
  dotColor = NA,
  pt.size = 1,
  shapeField = NA,
  dotShapes = NA,
  horizontalLegend = TRUE,
  resetLegendSize = TRUE,
  maxAllowableShapeValues = 6
)

Arguments

seuratObj

The seurat object

seuratPlot

The plot object, such as the result from DimPlot()

cellSelectField

The name of the field to select which cells to plot

colorLegendLabel

This is passed to labs(color = XXX) to label the legend

colorField

The name of the field to assign colors to the cells. This provides the option to use a different value from cellSelectField. If colorField and dotColor are NA, cellSelectField will be used.

dotColor

An optional string passed to geom_point(color = XX). This will assign all cells the same color. Ignored if colorField is provided.

pt.size

The size, passed to geom_point().

shapeField

If true, provided, these values will be used for shape. Note: if there are more than 6 unique values this will be ignored.

dotShapes

An optional vector of shape values passed to scale_shape_manual(values = XX). If dotShapes is provided, but shapeField is not, all cells will receive the same shape.

horizontalLegend

If true, theme(legend.box = "horizontal") is added to the plot. This can be useful if the original plot also has a legend (such as cluster names)

resetLegendSize

Using ggnewscale::new_scale_color seems to reset the dot size of the legend. If resetLegendSize=TRUE, the function will call "guides(colour_new = guide_legend(override.aes = list(size=3)))" to restore dot size to 3.

maxAllowableShapeValues

If shapes are used and there are more than this many values, all cells will receive the same shape.


bimberlabinternal/CellMembrane documentation built on Oct. 16, 2024, 6:53 a.m.