plotBinary {CytoSimplex} | R Documentation |
Create binary plots
Description
Create binary plots that show similarity between single cells and two selected terminals in a barycentric coordinate. The two vertices are placed at the left and right of a 2D plot where x-axis measures the similarity. Y-axis is jittered for a clear view. A density (histogram) curve is added for indicating the distribution.
See plotTernary
manual for more details.
Usage
plotBinary(x, ...)
## Default S3 method:
plotBinary(
x,
clusterVar,
vertices,
features = NULL,
byCluster = NULL,
processed = FALSE,
method = c("euclidean", "cosine", "pearson", "spearman"),
force = FALSE,
sigma = 0.08,
scale = TRUE,
dotColor = "grey60",
returnData = FALSE,
...
)
## S3 method for class 'Seurat'
plotBinary(
x,
layer = "counts",
assay = NULL,
clusterVar = NULL,
processed = FALSE,
...
)
## S3 method for class 'SingleCellExperiment'
plotBinary(x, assay.type = "counts", clusterVar = NULL, processed = FALSE, ...)
## S3 method for class 'simMat'
plotBinary(
x,
dotSize = 0.6,
dotColor = "grey60",
densLinewidth = 0.8,
labelColors = c("#3B4992FF", "#EE0000FF"),
title = NULL,
...
)
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 |
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 data 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 |
dotSize , dotColor |
Dot aesthetics passed to
|
densLinewidth |
Density plot line aesthetic. Default |
labelColors |
Color of the axis lines and vertex labels. Default
|
title |
Title text of the plot. Default |
Value
For 'simMat' method, a ggplot object. For other methods, a ggplot
object when splitCluster = FALSE
, or a list of ggplot objects when
splitCluster = TRUE
.
Examples
gene <- selectTopFeatures(rnaRaw, rnaCluster, c("RE", "OS"))
plotBinary(rnaRaw, rnaCluster, c("RE", "OS"), gene)
# Seurat example
library(Seurat)
srt <- CreateSeuratObject(rnaRaw)
Idents(srt) <- rnaCluster
gene <- selectTopFeatures(srt, vertices = c("OS", "RE"))
plotBinary(srt, features = gene, vertices = c("OS", "RE"))
# SingleCellExperiment example
library(SingleCellExperiment)
sce <- SingleCellExperiment(assays = list(counts = rnaRaw))
colLabels(sce) <- rnaCluster
gene <- selectTopFeatures(sce, vertices = c("OS", "RE"))
plotBinary(sce, features = gene, vertices = c("OS", "RE"))