Package 'CytoSimplex'

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

Help Index


Normalize each column of the input matrix by the column sum

Description

Normalize each column of the input matrix by the column sum

Usage

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", ...)

Arguments

x

Feature by observation matrix. Alternatively, Seurat object or SingleCellExperiment object with raw counts available are also supported.

scaleFactor

Multiplier on normalized data. Default NULL.

log

Logical. Whether to take log1p transformation after scaling. Default FALSE

...

Additional arguments passed to methods

assay

For "Seurat" method, the specific assay to get data from. Default NULL to the default assay.

layer

For "Seurat" method, which layer of the assay to be used. Default "counts".

assay.type

For "SingleCellExperiment" method, the assay type to get data from. Default "counts".

Value

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.

Examples

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

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 matrix or dgCMatrix object with cells as columns, a Seurat or SingleCellExperiment object. "simMat" method takes intermediate values.

...

Arguments passed to other methods.

clusterVar

A vector/factor assigning the cluster variable to each column of the matrix object. For "Seurat" method, NULL (default) for Idents(x), or a variable name in meta.data slot. For "SingleCellExperiment" method, NULL (default) for colLabels(x), or a variable name in colData slot.

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 NULL uses all available features.

byCluster

Default NULL to 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.

processed

Logical. Whether the input matrix is already processed. TRUE will bypass internal preprocessing and input matrix will be directly used for similarity calculation. Default FALSE and raw count input is recommended. If missing in call, using slot = "counts" in "Seurat" method or using assay.type = "counts" in "SingleCellExperiment" method will force this argument to be FALSE and others for TRUE.

method

Similarity calculation method. Default "euclidean". Choose from "euclidean", "cosine", "pearson", "spearman".

force

Whether to force calculate the similarity when more then 500 features are detected, which is generally not recommended. Default FALSE.

sigma

Gaussian kernel parameter that controls the effect of variance. Only effective when using a distance metric (i.e. method is "euclidian" or "cosine"). Larger value tighten the dot spreading on figure. Default 0.08.

scale

Whether to min-max scale the distance matrix by clusters. Default TRUE.

returnData

Logical. Whether to return similarity data instead of generating plot. Default FALSE.

layer

For "Seurat" method, which layer of the assay to be used. Default "counts".

assay

For "Seurat" method, the specific assay to get data from. Default NULL to the default assay.

assay.type

For "SingleCellExperiment" methods. Which assay to use for calculating the similarity. Default "counts".

dotSize, dotColor

Dot aesthetics passed to geom_point. Default 0.6 and "grey60".

densLinewidth

Density plot line aesthetic. Default 0.8.

labelColors

Color of the axis lines and vertex labels. Default c("#3B4992FF", "#EE0000FF") (blue and red).

title

Title text of the plot. Default NULL.

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"))

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 matrix or dgCMatrix object with cells as columns, a Seurat or SingleCellExperiment object. "simMat" method takes intermediate values.

...

Arguments passed to other methods.

clusterVar

A vector/factor assigning the cluster variable to each column of the matrix object. For "Seurat" method, NULL (default) for Idents(x), or a variable name in meta.data slot. For "SingleCellExperiment" method, NULL (default) for colLabels(x), or a variable name in colData slot.

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 NULL uses all available features.

veloGraph

Cell x cell dgCMatrix object containing velocity information. Shows velocity grid-arrow layer when specified. Default NULL does not show velocity.

byCluster

Default NULL to 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.

processed

Logical. Whether the input matrix is already processed. TRUE will bypass internal preprocessing and input matrix will be directly used for similarity calculation. Default FALSE and raw count input is recommended. If missing in call, using slot = "counts" in "Seurat" method or using assay.type = "counts" in "SingleCellExperiment" method will force this argument to be FALSE and others for TRUE.

method

Similarity calculation method. Default "euclidean". Choose from "euclidean", "cosine", "pearson", "spearman".

force

Whether to force calculate the similarity when more then 500 features are detected, which is generally not recommended. Default FALSE.

sigma

Gaussian kernel parameter that controls the effect of variance. Only effective when using a distance metric (i.e. method is "euclidian" or "cosine"). Larger values tighten the dot spreading on figure. Default 0.05.

scale

Whether to min-max scale the distance matrix by clusters. Default TRUE.

returnData

Logical. Whether to return similarity and aggregated velocity data if applicable instead of generating plot. Default FALSE.

layer

For "Seurat" method, which layer of the assay to be used. Default "counts".

assay

For "Seurat" method, the specific assay to get data from. Default NULL to the default assay.

assay.type

For "SingleCellExperiment" methods. Which assay to use for calculating the similarity. Default "counts".

veloMat

Aggregated velocity matrix. Output of aggrVeloGraph.

nGrid

Number of grids along the x-axis of the tetrahedron triangle. Default 10.

radius

Arrow length of unit velocity. Lower this when arrows point outside of the tetrahedron. Default 0.2.

dotSize, dotColor

Dot aesthetics. Default 0.6 and "grey60".

labelColors

Colors of the vertex labels. Default c("#3B4992FF", "#EE0000FF", "#008B45FF", "#631879FF") (blue, red, green and purple).

arrowLinewidth

Arrow aesthetics. Default 0.6.

arrowAngle, arrowLen

Arrow aesthetics passed to grid::arrow. The length of the arrow will be internally converted to unit onject in inches. Default 20 and 0.1.

vertexLabelSize

Numeric, size of vertex text label relative to default size. Default 1.

edgeLinewidth

Controls the linewidth of the edges of the tetrahedron. Default 1.

title

Title text of the plot. Default NULL.

titleSize, titleColor

Setting on the main title text. Default 1, and "black".

theta, phi

Numeric scalar. The angles defining the viewing direction. theta gives the azimuthal direction and phi the colatitude. Default 20 and 0.

interactive

Logical. Whether to use "rgl" library to create interactive device. Default FALSE.

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"))

Create ternary plots

Description

Create ternary plots that show similarity between single cells and selected three terminals in a ternary baricentric coordinate.

Usage

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,
  ...
)

Arguments

x

Input data. Can be a matrix or dgCMatrix object with cells as columns, a Seurat or SingleCellExperiment object. "simMat" method takes intermediate values.

...

Arguments passed to other methods.

clusterVar

A vector/factor assigning the cluster variable to each column of the matrix object. For "Seurat" method, NULL (default) for Idents(x), or a variable name in meta.data slot. For "SingleCellExperiment" method, NULL (default) for colLabels(x), or a variable name in colData slot.

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 NULL uses all available features.

veloGraph

Cell x cell dgCMatrix object containing velocity information. Shows velocity grid-arrow layer when specified. Default NULL does not show velocity.

byCluster

Default NULL to 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.

processed

Logical. Whether the input matrix is already processed. TRUE will bypass internal preprocessing and input matrix will be directly used for similarity calculation. Default FALSE and raw count input is recommended. If missing in call, using slot = "counts" in "Seurat" method or using assay.type = "counts" in "SingleCellExperiment" method will force this argument to be FALSE and others for TRUE.

method

Similarity calculation method. Default "euclidean". Choose from "euclidean", "cosine", "pearson", "spearman".

force

Whether to force calculate the similarity when more then 500 features are detected, which is generally not recommended. Default FALSE.

sigma

Gaussian kernel parameter that controls the effect of variance. Only effective when using a distance metric (i.e. method is "euclidian" or "cosine"). Larger values tighten the dot spreading on figure. Default 0.08.

scale

Whether to min-max scale the distance matrix by clusters. Default TRUE.

returnData

Logical. Whether to return similarity and aggregated velocity data if applicable instead of generating plot. Default FALSE.

layer

For "Seurat" method, which layer of the assay to be used. Default "counts".

assay

For "Seurat" method, the specific assay to get data from. Default NULL to the default assay.

assay.type

For "SingleCellExperiment" methods. Which assay to use for calculating the similarity. Default "counts".

title

Title text of the plot. Default NULL.

veloMat

Aggregated velocity matrix. Output of aggrVeloGraph.

nGrid

Number of grids along the bottom side of the equilateral triangle. Default 10.

radius

Arrow length of unit velocity. Lower this when arrows point outside of the coordinate. Default 0.1.

dotSize, dotColor

Dot aesthetics passed to geom_point. Default 0.6 and "grey60".

labelColors

Colors of the axis lines and vertex labels. Default c("#3B4992FF", "#EE0000FF", "#008B45FF") (blue, red and green)

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 5, drifted distance 0.03.

axisBreak

Number of breaks to be labeled along axis. Default 5.

axisTextShow

Logical, whether to show axis text. Default TRUE.

axisTextSize, axisTextDrift

Similar to the vertex adjustment applied to the text label along the axis breaks. Default size 4, drifted distance 0.02.

gridLineAlpha

Transparency of background grid lines. Default 0.6.

arrowLinewidth, arrowAngle, arrowLen

Arrow aesthetics, see Details.

titleSize

Size of title text. Default 14.

equilateral

Logical, whether to always display the triangle as equilateral. Default TRUE.

margin

Margin allowed around of the triangle plotting region when equilateral = TRUE

Details

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.

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("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

Description

Major cell type annotation of the example mouse bone marrow data

Usage

rnaCluster

Format

factor object

Source

https://www.nature.com/articles/s41467-023-38034-2

References

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

Description

Mouse bone marrow scRNAseq example data

Usage

rnaRaw

Format

dgCMatrix object

Source

https://www.nature.com/articles/s41467-023-38034-2

References

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

Description

Velocity graph of the example mouse bone marrow data

Usage

rnaVelo

Format

dgCMatrix object

Source

https://www.nature.com/articles/s41467-023-38034-2

References

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).


Pick top differentially presented features for similarity calculation

Description

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.

Usage

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,
  ...
)

Arguments

x

Dense or sparse matrix, observation per column. Preferrably a raw count matrix. Alternatively, a Seurat object or a SingleCellExperiment object.

clusterVar

A vector/factor assigning the cluster variable to each column of the matrix object. For "Seurat" method, NULL (default) for Idents(x), or a variable name in meta.data slot. For "SingleCellExperiment" method, NULL (default) for colLabels(x), or a variable name in colData slot.

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 30.

processed

Logical. Whether the input matrix is already processed. TRUE will bypass internal preprocessing and input matrix will be directly used for rank-sum calculation. Default FALSE and raw count input is recommended.

lfcThresh

Threshold on log fold-change to identify up-regulated features. Default 0.1.

returnStats

Logical. Whether to return the full statistics table rather then returning the selected genes. Default FALSE

assay

Assay name of the Seurat object to be used. Default NULL.

layer

For "Seurat" method, which layer of the assay to be used. Default "counts".

assay.type

Assay name of the SingleCellExperiment object to be used. Default "counts".

Value

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.

Examples

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

Description

Show plist object produced with plot3D package

Usage

## S4 method for signature 'plist'
show(object)

## S3 method for class 'plist'
print(x, ...)

Arguments

object, x

plist object

...

Graphic parameters passed to plot. mar is pre-specified.

Value

No return value. It displays the plot described in a 'plist' object returned by plotQuaternary, internally created by package 'plot3D'.

Examples

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

Description

Create GIF image for dynamic rotating view of 3D quaternary simplex plot

Usage

writeQuaternaryGIF(
  x,
  ...,
  cluster = NULL,
  gifPath = "quaternary.gif",
  tmpDir = tempdir(),
  fps = 10,
  degreePerFrame = 10
)

Arguments

x

Input object that plotQuaternary accepts.

...

All other arguments needed for plotQuaternary. Must be specified with exact argument names instead of a positional manner.

cluster

One cluster that exists in clusterVar, if users need to view the plot for specific group. Default NULL plot all cells.

gifPath

Output GIF image file path. Default "quaternary.gif"

tmpDir

A temprorary directory to store all PNG files for all perspectives created. Default tempdir().

fps

Number of frame per second, must be a factor of 100. Default 10.

degreePerFrame

Number of degree that the tetrahedron is rotated per frame. Default 10.

Value

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.

Examples

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"))