Title: | Simplex Visualization of Cell Fate Similarity in Single-Cell Data |
---|---|
Description: | Create simplex plots to visualize the similarity between single-cells and selected clusters in a 1-/2-/3-simplex space. Velocity information can be added as an additional layer. See Liu J, Wang Y et al (2023) <doi:10.1101/2023.12.07.570655> for more details. |
Authors: | Yichen Wang [aut, cre] , Jialin Liu [aut] , Joshua Welch [cph] |
Maintainer: | Yichen Wang <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2024-11-10 06:20:43 UTC |
Source: | CRAN |
Normalize each column of the input matrix by the column sum
colNormalize(x, scaleFactor = NULL, log = FALSE, ...) ## Default S3 method: colNormalize(x, scaleFactor = NULL, log = FALSE, ...) ## S3 method for class 'dgCMatrix' colNormalize(x, scaleFactor = NULL, log = FALSE, ...) ## S3 method for class 'Seurat' colNormalize( x, scaleFactor = NULL, log = FALSE, assay = NULL, layer = "counts", ... ) ## S3 method for class 'SingleCellExperiment' colNormalize(x, scaleFactor = NULL, log = FALSE, assay.type = "counts", ...)
colNormalize(x, scaleFactor = NULL, log = FALSE, ...) ## Default S3 method: colNormalize(x, scaleFactor = NULL, log = FALSE, ...) ## S3 method for class 'dgCMatrix' colNormalize(x, scaleFactor = NULL, log = FALSE, ...) ## S3 method for class 'Seurat' colNormalize( x, scaleFactor = NULL, log = FALSE, assay = NULL, layer = "counts", ... ) ## S3 method for class 'SingleCellExperiment' colNormalize(x, scaleFactor = NULL, log = FALSE, assay.type = "counts", ...)
x |
Feature by observation matrix. Alternatively, |
scaleFactor |
Multiplier on normalized data. Default |
log |
Logical. Whether to take log1p transformation after scaling.
Default |
... |
Additional arguments passed to methods |
assay |
For "Seurat" method, the specific assay to get data from.
Default |
layer |
For "Seurat" method, which layer of the assay to be used.
Default |
assay.type |
For "SingleCellExperiment" method, the assay type to get
data from. Default |
Normalized matrix of the same size
A Seurat object with normalized data in the specified slot of the specified assay.
A SingleCellExperiment object with normalized data in the specified
assay. "normcounts"
if log = FALSE
and "logcounts"
if
log = TRUE
.
rnaNorm <- colNormalize(rnaRaw) # Seurat example library(Seurat) srt <- CreateSeuratObject(rnaRaw) srt <- colNormalize(srt) # SingleCellExperiment example library(SingleCellExperiment) sce <- SingleCellExperiment(assays = list(counts = rnaRaw)) sce <- colNormalize(sce)
rnaNorm <- colNormalize(rnaRaw) # Seurat example library(Seurat) srt <- CreateSeuratObject(rnaRaw) srt <- colNormalize(srt) # SingleCellExperiment example library(SingleCellExperiment) sce <- SingleCellExperiment(assays = list(counts = rnaRaw)) sce <- colNormalize(sce)
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.
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, ... )
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, ... )
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 |
For 'simMat' method, a ggplot object. For other methods, a ggplot
object when splitCluster = FALSE
, or a list of ggplot objects when
splitCluster = TRUE
.
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"))
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"))
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.
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, ... )
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, ... )
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 |
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.
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"))
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"))
Create ternary plots that show similarity between single cells and selected three terminals in a ternary baricentric coordinate.
plotTernary(x, ...) ## Default S3 method: plotTernary( x, clusterVar, vertices, features = NULL, veloGraph = 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' plotTernary( x, layer = "counts", assay = NULL, clusterVar = NULL, processed = FALSE, ... ) ## S3 method for class 'SingleCellExperiment' plotTernary( x, assay.type = "counts", clusterVar = NULL, processed = FALSE, ... ) ## S3 method for class 'simMat' plotTernary( x, title = NULL, veloMat = NULL, nGrid = 10, radius = 0.1, dotSize = 0.6, dotColor = "grey60", labelColors = c("#3B4992FF", "#EE0000FF", "#008B45FF"), vertexLabelSize = 5, vertexLabelDrift = 0.03, axisBreak = 5, axisTextShow = TRUE, axisTextSize = 4, axisTextDrift = 0.02, gridLineAlpha = 0.6, arrowLinewidth = 0.25, arrowAngle = 20, arrowLen = 0.2, titleSize = 14, equilateral = TRUE, margin = 0.1, ... )
plotTernary(x, ...) ## Default S3 method: plotTernary( x, clusterVar, vertices, features = NULL, veloGraph = 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' plotTernary( x, layer = "counts", assay = NULL, clusterVar = NULL, processed = FALSE, ... ) ## S3 method for class 'SingleCellExperiment' plotTernary( x, assay.type = "counts", clusterVar = NULL, processed = FALSE, ... ) ## S3 method for class 'simMat' plotTernary( x, title = NULL, veloMat = NULL, nGrid = 10, radius = 0.1, dotSize = 0.6, dotColor = "grey60", labelColors = c("#3B4992FF", "#EE0000FF", "#008B45FF"), vertexLabelSize = 5, vertexLabelDrift = 0.03, axisBreak = 5, axisTextShow = TRUE, axisTextSize = 4, axisTextDrift = 0.02, gridLineAlpha = 0.6, arrowLinewidth = 0.25, arrowAngle = 20, arrowLen = 0.2, titleSize = 14, equilateral = TRUE, margin = 0.1, ... )
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 |
title |
Title text of the plot. Default |
veloMat |
Aggregated velocity matrix. Output of |
nGrid |
Number of grids along the bottom side of the equilateral
triangle. Default |
radius |
Arrow length of unit velocity. Lower this when arrows point
outside of the coordinate. Default |
dotSize , dotColor
|
Dot aesthetics passed to
|
labelColors |
Colors of the axis lines and vertex labels.
Default |
vertexLabelSize , vertexLabelDrift
|
Adjustment on the three vertex text
labels. Drift means the distance that the labels should be moved against the
center of the plot. Default size |
axisBreak |
Number of breaks to be labeled along axis. Default
|
axisTextShow |
Logical, whether to show axis text. Default |
axisTextSize , axisTextDrift
|
Similar to the vertex adjustment applied
to the text label along the axis breaks. Default size |
gridLineAlpha |
Transparency of background grid lines. Default
|
arrowLinewidth , arrowAngle , arrowLen
|
Arrow aesthetics, see Details. |
titleSize |
Size of title text. Default |
equilateral |
Logical, whether to always display the triangle as
equilateral. Default |
margin |
Margin allowed around of the triangle plotting region when
|
Argument inheritance - For matrix/dgCMatrix ("default" method), we first calculate the similarity matrix and obtain a "simMat" object. Then the "simMat" method is internally called. For data container objects (e.g. Seurat), we obtain the correct data matrix first and then call the "default" method. The arguments inherits as the flow described above.
The calculation of similarity matrix - The similarity is calculated either by converting a distance metric ("euclidean" or "cosine") with Gaussian kernel, or directly computed with correlation metrics ("pearson" or "spearman"). The centroid of each terminal is obtained first, and the specified metric from each cell to each terminal is calculated. The similarity matrix (n cells by v terminals) is lastly normalized to sum to 1 for each cell, so it becomes a baricentric coordinate.
Arrow aesthetics parameters - The shape of arrows is controlled by 3
arguments. Considering an arrow as the combination of a line segment and a
triangle, arrowLinewidth
controls the width of the line as well as
the edge line of the triangle; arrowAngle
equals to angle of the
arrow-tip vertex of the triangle devided by 2 (e.g. the triangle is
equilateral when arrowAngle = 20
); arrowLen
controls the
absolute length from the arrow-tip vertex to its opposite edge.
For "simMat" method, a ggplot object. For other methods, a ggplot
object when splitCluster = FALSE
, or a list of ggplot objects when
splitCluster = TRUE
.
gene <- selectTopFeatures(rnaRaw, rnaCluster, c("OS", "RE", "CH")) plotTernary(rnaRaw, rnaCluster, c("OS", "RE", "CH"), gene) # Seurat example library(Seurat) srt <- CreateSeuratObject(rnaRaw) Idents(srt) <- rnaCluster gene <- selectTopFeatures(srt, vertices = c("OS", "RE", "CH")) plotTernary(srt, features = gene, vertices = c("OS", "RE", "CH")) # SingleCellExperiment example library(SingleCellExperiment) sce <- SingleCellExperiment(assays = list(counts = rnaRaw)) colLabels(sce) <- rnaCluster gene <- selectTopFeatures(sce, vertices = c("OS", "RE", "CH")) plotTernary(sce, features = gene, vertices = c("OS", "RE", "CH"))
gene <- selectTopFeatures(rnaRaw, rnaCluster, c("OS", "RE", "CH")) plotTernary(rnaRaw, rnaCluster, c("OS", "RE", "CH"), gene) # Seurat example library(Seurat) srt <- CreateSeuratObject(rnaRaw) Idents(srt) <- rnaCluster gene <- selectTopFeatures(srt, vertices = c("OS", "RE", "CH")) plotTernary(srt, features = gene, vertices = c("OS", "RE", "CH")) # SingleCellExperiment example library(SingleCellExperiment) sce <- SingleCellExperiment(assays = list(counts = rnaRaw)) colLabels(sce) <- rnaCluster gene <- selectTopFeatures(sce, vertices = c("OS", "RE", "CH")) plotTernary(sce, features = gene, vertices = c("OS", "RE", "CH"))
Major cell type annotation of the example mouse bone marrow data
rnaCluster
rnaCluster
factor
object
https://www.nature.com/articles/s41467-023-38034-2
Matsushita, Y., Liu, J., Chu, A.K.Y. et al. Bone marrow endosteal stem cells dictate active osteogenesis and aggressive tumorigenesis. Nat Commun 14, 2383 (2023).
Mouse bone marrow scRNAseq example data
rnaRaw
rnaRaw
dgCMatrix object
https://www.nature.com/articles/s41467-023-38034-2
Matsushita, Y., Liu, J., Chu, A.K.Y. et al. Bone marrow endosteal stem cells dictate active osteogenesis and aggressive tumorigenesis. Nat Commun 14, 2383 (2023).
Velocity graph of the example mouse bone marrow data
rnaVelo
rnaVelo
dgCMatrix object
https://www.nature.com/articles/s41467-023-38034-2
Matsushita, Y., Liu, J., Chu, A.K.Y. et al. Bone marrow endosteal stem cells dictate active osteogenesis and aggressive tumorigenesis. Nat Commun 14, 2383 (2023).
Performs wilcoxon rank-sum test on input matrix. While clusterVar
and
vertices
together defines the groups of cells to be set as terminals
of the simplex, this function will test each of these groups against the rest
of the cells. The U-Statistics (statistic
), p-value (pval
) and
adjusted p-value (padj
), together with average presence in group
(avgExpr
), log fold-change (logFC
), AUC (auc
),
percentage in group (pct_in
) and percentage out of group
(pct_out
) will be calculated. Set returnStats = TRUE
to return
the full statistics table.
Top features are selected by sorting primarily on adjusted p-value, and secondarily on log fold-change, after filtering for up-regulated features.
selectTopFeatures(x, clusterVar, vertices, ...) ## Default S3 method: selectTopFeatures( x, clusterVar, vertices, nTop = 30, processed = FALSE, lfcThresh = 0.1, returnStats = FALSE, ... ) ## S3 method for class 'Seurat' selectTopFeatures( x, clusterVar = NULL, vertices, assay = NULL, layer = "counts", processed = FALSE, ... ) ## S3 method for class 'SingleCellExperiment' selectTopFeatures( x, clusterVar = NULL, vertices, assay.type = "counts", processed = FALSE, ... )
selectTopFeatures(x, clusterVar, vertices, ...) ## Default S3 method: selectTopFeatures( x, clusterVar, vertices, nTop = 30, processed = FALSE, lfcThresh = 0.1, returnStats = FALSE, ... ) ## S3 method for class 'Seurat' selectTopFeatures( x, clusterVar = NULL, vertices, assay = NULL, layer = "counts", processed = FALSE, ... ) ## S3 method for class 'SingleCellExperiment' selectTopFeatures( x, clusterVar = NULL, vertices, assay.type = "counts", processed = FALSE, ... )
x |
Dense or sparse matrix, observation per column. Preferrably a raw
count matrix. Alternatively, a |
clusterVar |
A vector/factor assigning the cluster variable to each
column of the matrix object. For "Seurat" method, |
vertices |
Vector of cluster names that will be used for plotting. Or a named list that groups clusters as a terminal vertex. There must not be any overlap between groups. |
... |
Arguments passed to methods. |
nTop |
Number of top differentially presented features per terminal.
Default |
processed |
Logical. Whether the input matrix is already processed.
|
lfcThresh |
Threshold on log fold-change to identify up-regulated
features. Default |
returnStats |
Logical. Whether to return the full statistics table
rather then returning the selected genes. Default |
assay |
Assay name of the Seurat object to be used. Default |
layer |
For "Seurat" method, which layer of the assay to be used.
Default |
assay.type |
Assay name of the SingleCellExperiment object to be used.
Default |
When returnStats = FALSE
(default), a character vector of at
most length(unique(vertices))*nTop
feature names. When
returnStats = TRUE
, a data.frame of wilcoxon rank sum test statistics.
selectTopFeatures(rnaRaw, rnaCluster, c("OS", "RE")) # Seurat example library(Seurat) srt <- CreateSeuratObject(rnaRaw) Idents(srt) <- rnaCluster gene <- selectTopFeatures(srt, vertices = c("OS", "RE")) # SingleCellExperiment example library(SingleCellExperiment) sce <- SingleCellExperiment(assays = list(counts = rnaRaw)) colLabels(sce) <- rnaCluster gene <- selectTopFeatures(sce, vertices = c("OS", "RE"))
selectTopFeatures(rnaRaw, rnaCluster, c("OS", "RE")) # Seurat example library(Seurat) srt <- CreateSeuratObject(rnaRaw) Idents(srt) <- rnaCluster gene <- selectTopFeatures(srt, vertices = c("OS", "RE")) # SingleCellExperiment example library(SingleCellExperiment) sce <- SingleCellExperiment(assays = list(counts = rnaRaw)) colLabels(sce) <- rnaCluster gene <- selectTopFeatures(sce, vertices = c("OS", "RE"))
Show plist object produced with plot3D package
## S4 method for signature 'plist' show(object) ## S3 method for class 'plist' print(x, ...)
## S4 method for signature 'plist' show(object) ## S3 method for class 'plist' print(x, ...)
object , x
|
plist object |
... |
Graphic parameters passed to |
No return value. It displays the plot described in a 'plist' object
returned by plotQuaternary
, internally created by package
'plot3D'.
gene <- selectTopFeatures(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT")) plistObj <- plotQuaternary(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT"), gene) print(plistObj) # equivalent to show(plistObj)
gene <- selectTopFeatures(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT")) plistObj <- plotQuaternary(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT"), gene) print(plistObj) # equivalent to show(plistObj)
Create GIF image for dynamic rotating view of 3D quaternary simplex plot
writeQuaternaryGIF( x, ..., cluster = NULL, gifPath = "quaternary.gif", tmpDir = tempdir(), fps = 10, degreePerFrame = 10 )
writeQuaternaryGIF( x, ..., cluster = NULL, gifPath = "quaternary.gif", tmpDir = tempdir(), fps = 10, degreePerFrame = 10 )
x |
Input object that |
... |
All other arguments needed for |
cluster |
One cluster that exists in |
gifPath |
Output GIF image file path. Default |
tmpDir |
A temprorary directory to store all PNG files for all
perspectives created. Default |
fps |
Number of frame per second, must be a factor of 100. Default
|
degreePerFrame |
Number of degree that the tetrahedron is rotated per
frame. Default |
No object is returned. The tmpDir
folder will be created with
360 / degreePerFrame
PNG image files in it. A GIF image file will be
created at gifPath
.
gene <- selectTopFeatures(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT")) writeQuaternaryGIF(rnaRaw, clusterVar = rnaCluster, features = gene, vertices = c("RE", "OS", "CH", "ORT"), gifPath = paste0(tempfile(), ".gif"))
gene <- selectTopFeatures(rnaRaw, rnaCluster, c("RE", "OS", "CH", "ORT")) writeQuaternaryGIF(rnaRaw, clusterVar = rnaCluster, features = gene, vertices = c("RE", "OS", "CH", "ORT"), gifPath = paste0(tempfile(), ".gif"))