plotQuaternary {CytoSimplex} | R Documentation |
Create quaternary simplex plots
Description
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
plotQuaternary(x, ...)
## Default S3 method:
plotQuaternary(
x,
clusterVar,
vertices,
features = NULL,
veloGraph = NULL,
byCluster = NULL,
processed = FALSE,
method = c("euclidean", "cosine", "pearson", "spearman"),
force = FALSE,
sigma = 0.05,
scale = TRUE,
dotColor = "grey60",
returnData = FALSE,
...
)
## S3 method for class 'Seurat'
plotQuaternary(
x,
layer = "counts",
assay = NULL,
clusterVar = NULL,
processed = FALSE,
...
)
## S3 method for class 'SingleCellExperiment'
plotQuaternary(
x,
assay.type = "counts",
clusterVar = NULL,
processed = FALSE,
...
)
## S3 method for class 'simMat'
plotQuaternary(
x,
veloMat = NULL,
nGrid = 10,
radius = 0.2,
dotSize = 0.6,
dotColor = "grey60",
labelColors = c("#3B4992FF", "#EE0000FF", "#008B45FF", "#631879FF"),
arrowLinewidth = 0.6,
arrowAngle = 20,
arrowLen = 0.1,
vertexLabelSize = 1,
edgeLinewidth = 1,
title = NULL,
titleSize = 1,
titleColor = "black",
theta = 20,
phi = 0,
interactive = FALSE,
...
)
Arguments
x |
Input data. Can be a |
... |
Arguments passed to other methods. |
clusterVar |
A vector/factor assigning the cluster variable to each
column of the matrix object. For "Seurat" method, |
vertices |
Vector 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. |
features |
Valid matrix row subsetting index to select features for
similarity calculation. Default |
veloGraph |
Cell x cell |
byCluster |
Default |
processed |
Logical. Whether the input matrix is already processed.
|
method |
Similarity calculation method. Default |
force |
Whether to force calculate the similarity when more then 500
features are detected, which is generally not recommended. Default
|
sigma |
Gaussian kernel parameter that controls the effect of variance.
Only effective when using a distance metric (i.e. |
scale |
Whether to min-max scale the distance matrix by clusters.
Default |
returnData |
Logical. Whether to return similarity and aggregated
velocity data if applicable instead of generating plot. Default |
layer |
For "Seurat" method, which layer of the assay to be used.
Default |
assay |
For "Seurat" method, the specific assay to get data from.
Default |
assay.type |
For "SingleCellExperiment" methods. Which assay to use for
calculating the similarity. Default |
veloMat |
Aggregated velocity matrix. Output of |
nGrid |
Number of grids along the x-axis of the tetrahedron
triangle. Default |
radius |
Arrow length of unit velocity. Lower this when arrows point
outside of the tetrahedron. Default |
dotSize , dotColor |
Dot aesthetics. Default |
labelColors |
Colors of the vertex labels. Default
|
arrowLinewidth |
Arrow aesthetics. Default |
arrowAngle , arrowLen |
Arrow aesthetics passed to
|
vertexLabelSize |
Numeric, size of vertex text label relative to default
size. Default |
edgeLinewidth |
Controls the linewidth of the edges of the tetrahedron.
Default |
title |
Title text of the plot. Default |
titleSize , titleColor |
Setting on the main title text. Default |
theta , phi |
Numeric scalar. The angles defining the viewing direction.
|
interactive |
Logical. Whether to use "rgl" library to create
interactive device. Default |
Value
For "simMat" method, a "plist" (plot3D package product) object. For
other methods, a "plist" object when splitCluster = FALSE
, or a list
of "plist" objects when splitCluster = TRUE
. A "plist" object can be
viewed with print()
, show()
or a direct run of the object
variable name in interactive console.
Examples
gene <- selectTopFeatures(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT"))
plotQuaternary(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT"), gene)
# Seurat example
library(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"))
# SingleCellExperiment example
library(SingleCellExperiment)
sce <- SingleCellExperiment(assays = list(counts = rnaRaw))
colLabels(sce) <- rnaCluster
gene <- selectTopFeatures(sce, vertices = c("OS", "RE", "CH", "ORT"))
plotQuaternary(sce, features = gene,
vertices = c("OS", "RE", "CH", "ORT"))