Create quaternary plots that show similarity between single cells and selected four terminals in a baricentric coordinate.
See plotTernary for more details on methodologies.
A dynamic rotating view in a GIF image file can be created with
writeQuaternaryGIF. Package magick must be installed in
advance. Linux users may refer to this
installation guide.
Usage
# S3 method for class 'Seurat'
plotQuaternary(
x,
layer = "counts",
assay = NULL,
clusterVar = NULL,
processed = FALSE,
dotColorBy = NULL,
legendTitle = NULL,
...
)Arguments
- x
A Seurat object
- layer
Layer in the specified assay to use. Default
"counts".- assay
The assay to get data from. Default
NULLuses the default assay.- clusterVar
A variable name in meta.data (
x[[]]). DefaultNULLusesIdents(x).- processed
Logical. Whether the input matrix is already processed.
TRUEwill bypass internal preprocessing and input matrix will be directly used for similarity calculation. DefaultFALSEand raw count input is recommended. If missing in call, usingslot = "counts"in "Seurat" method or usingassay.type = "counts"in "SingleCellExperiment" method will force this argument to beFALSEand others forTRUE.- dotColorBy
A vector/factor for coloring dots, can be either categorical (must be character or factor) or continuous. Default
NULL.- legendTitle
Title on the legend/colorbar. Default
NULLuses"cluster"ifdotColorByis missing (default); user-end variable expression ifdotColorByis directly specified from plotQuaternary.default method; variable name ifdotColorByis specified from Seurat or SingleCellExperiment method.- ...
Arguments passed on to
plotQuaternary.default,plotQuaternary.simMatverticesVector of three unique cluster names that will be used for plotting. Or a named list that groups clusters as three terminal vertices. There must not be any overlap between groups.
featuresValid matrix row subsetting index to select features for similarity calculation. Default
NULLuses all available features.byClusterDefault
NULLto generate one plot with all cells. Set"all"to split cells in plot by cluster and returns a list of subplots for each cluster as well as the plot including all cells. Otherwise, a vector of cluster names to generate a list of subplots for the specified clusters.veloGraphCell x cell
dgCMatrixobject containing velocity information. Shows velocity grid-arrow layer when specified. DefaultNULLdoes not show velocity.methodSimilarity calculation method. Default
"euclidean". Choose from"euclidean","cosine","pearson","spearman".forceWhether to force calculate the similarity when more then 500 features are detected, which is generally not recommended. Default
FALSE.sigmaGaussian kernel parameter that controls the effect of variance. Only effective when using a distance metric (i.e.
methodis"euclidian"or"cosine"). Larger values tighten the dot spreading on figure. Default0.05.scaleWhether to min-max scale the distance matrix by clusters. Default
TRUE.dotColorCharacter vector of color codes. When
dotColorByisNULL, use one or as many colors as the number of cells. IfdotColorByis categorical, specify as many colors as the number of categories indotColorByor ggplot2 categorical color palette is used by default. IfdotColorByis continuous, specify together withbreaksargument.paletteColor palette to use when
dotColorByis given. Default"D"(viridis) for continuous value and ggplot2 default for categorical value. See detail for alternatives.directionSets the order of colors in the scale. Default
1orders as palette default. If-1, the order of colors is reversed.breaksNumber of breaks for continuous color scale passed to non-interactive "plot3D::scatter3D" call. Default
NULL.returnDataLogical. Whether to return similarity and aggregated velocity data if applicable instead of generating plot. Default
FALSE.nGridNumber of grids along the x-axis of the tetrahedron. Default
10.radiusArrow length of unit velocity. Lower this when arrows point outside of the tetrahedron. Default
0.2.dotSizeSize of each dot. Default
0.6for static figure, and4for interactive view.labelColorsColors of the vertex labels. Default
c("#3B4992FF", "#EE0000FF", "#008B45FF", "#631879FF")(blue, red, green and purple).arrowLinewidthArrow aesthetics. Default
1.6for interactive view,0.6for static figure.arrowAngle,arrowLenArrow aesthetics passed to TODOOOO
grid::arrow. The length of the arrow will be internally converted to unit onject in inches. Default20and0.1.edgeLinewidthControls the linewidth of the edges of the tetrahedron. Default
1.vertexLabelSizeNumeric, size of vertex text label relative to default size. Default
1.titleTitle text of the plot. Default
NULL.titleSize,titleColorSetting on the main title text. Default
1, and"black".theta,phiNumeric scalar. The angles defining the viewing direction.
thetagives the azimuthal direction andphithe colatitude. Default20and0.interactiveLogical. Whether to display plotly interactive view. Default
TRUE.
Value
By default, a "plotly" object. When interactive = FALSE, a
"quatPlot" object when byCluster is not specified, or a "list" of
"quatPlot" objects when byCluster is specified. When
returnData = TRUE, a list of similarity matrix and aggregated velocity
matrix is returned.
See also
Other plotQuaternary:
plotQuaternary(),
plotQuaternary.SingleCellExperiment()
Examples
# \donttest{
# Seurat example
if (requireNamespace("Seurat", quietly = TRUE)) {
require(Seurat)
srt <- CreateSeuratObject(rnaRaw)
Idents(srt) <- rnaCluster
gene <- selectTopFeatures(srt, vertices = c("OS", "RE", "CH", "ORT"))
plotQuaternary(srt, features = gene,
vertices = c("OS", "RE", "CH", "ORT"))
}
#> Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')
#> Selected 30 features for "CH".
#> Selected 30 features for "ORT".
#> Selected 30 features for "OS".
#> Selected 30 features for "RE".
# }
