Skip to content

Commit d87e5da

Browse files
committed
Merge branch 'main' into gh-pages
2 parents d15ab5a + 33e60de commit d87e5da

9 files changed

Lines changed: 37 additions & 18 deletions

File tree

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ S3method(plotBinary,simMat)
1212
S3method(plotQuaternary,Seurat)
1313
S3method(plotQuaternary,SingleCellExperiment)
1414
S3method(plotQuaternary,default)
15+
S3method(plotQuaternary,simMat)
1516
S3method(plotTernary,Seurat)
1617
S3method(plotTernary,SingleCellExperiment)
1718
S3method(plotTernary,default)
19+
S3method(plotTernary,simMat)
1820
S3method(print,quatPlot)
1921
S3method(selectTopFeatures,Seurat)
2022
S3method(selectTopFeatures,SingleCellExperiment)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
## CytoSimplex 0.1.99
1+
## CytoSimplex 0.2.0
22

33
- Added support for coloring dots by categorical or continuous variable, with options to use customized or built-in color palettes.
44
- Changed interactive 3D support of quaternary simplex plot from *rgl* to *plotly*. Now the default is `interactive = TRUE` for `plotQuaternary()` and it returns a `plotly` object.
55
- Added interactive support for ternary simplex plot, using plotly, triggered with `interactive = TRUE`
66
- Fixed wilcoxon bug
77
- Added `readH5ADObsNames()`, `readH5ADObsVar()`, `readH5ADUnsSpMat()`, `readVelocytoLoom()` for loading commonly seen necessary information from H5AD and LOOM files of RNA velocity analysis
88
- Added example tutorial for HSPC analysis in the manuscript
9+
- Fixed error in `plotQuaternary()`
910

1011
## CytoSimplex 0.1.1
1112

R/data.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#' Mouse bone marrow scRNAseq example data
2-
#' @format \linkS4class{dgCMatrix} object
2+
#' @format \link[Matrix]{dgCMatrix-class} object
33
#' @source https://www.nature.com/articles/s41467-023-38034-2
44
#' @references Matsushita, Y., Liu, J., Chu, A.K.Y. et al. Bone marrow endosteal
55
#' stem cells dictate active osteogenesis and aggressive tumorigenesis. Nat
@@ -15,7 +15,7 @@
1515
"rnaCluster"
1616

1717
#' Velocity graph of the example mouse bone marrow data
18-
#' @format \linkS4class{dgCMatrix} object
18+
#' @format \link[Matrix]{dgCMatrix-class} object
1919
#' @source https://www.nature.com/articles/s41467-023-38034-2
2020
#' @references Matsushita, Y., Liu, J., Chu, A.K.Y. et al. Bone marrow endosteal
2121
#' stem cells dictate active osteogenesis and aggressive tumorigenesis. Nat

R/quaternary.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ plotQuaternary.SingleCellExperiment <- function(
368368
#' @param ... Not used
369369
#' @method plotQuaternary simMat
370370
#' @return A "quatPlot" object, can be displayed by printing.
371+
#' @export
371372
plotQuaternary.simMat <- function(
372373
x,
373374
veloMat = NULL,

R/ternary.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ plotTernary.SingleCellExperiment <- function(
380380
#' Default \code{FALSE}.
381381
#' @param ... Not used
382382
#' @method plotTernary simMat
383+
#' @export
383384
plotTernary.simMat <- function(
384385
x,
385386
title = NULL,
@@ -655,13 +656,14 @@ plotTernary.simMat <- function(
655656
dotSize <- dotSize %||% 4
656657
arrowLinewidth <- arrowLinewidth %||% 2
657658
df <- as.data.frame(as.matrix(x[,1:3]))
659+
hoverDF <- cbind(ID = rownames(x), df)
658660
legendTitle <- colorArg$palette$legendTitle
659661
if (colorArg$type == "categorical") {
660662
df[[legendTitle]] <- colorArg$colorBy
661663
fig <- plotly::plot_ly(
662664
data = df, type = "scatterternary", mode = "markers",
663665
a = I(df[[1]]), b = I(df[[2]]), c = I(df[[3]]),
664-
hovertemplate = .plotly_formatCustomData(df),
666+
hovertemplate = .plotly_formatCustomData(hoverDF),
665667
color = stats::formula(paste0("~", legendTitle)),
666668
colors = colorArg$palette$colors,
667669
marker = list(
@@ -674,7 +676,7 @@ plotTernary.simMat <- function(
674676
fig <- plotly::plot_ly(
675677
data = df, type = "scatterternary", mode = "markers",
676678
a = I(df[[1]]), b = I(df[[2]]), c = I(df[[3]]),
677-
hovertemplate = .plotly_formatCustomData(df),
679+
hovertemplate = .plotly_formatCustomData(hoverDF),
678680
marker = list(
679681
color = stats::formula(paste0("~", legendTitle)),
680682
autocolorscale = FALSE,
@@ -696,7 +698,7 @@ plotTernary.simMat <- function(
696698
fig <- plotly::plot_ly(
697699
data = df, type = "scatterternary", mode = "markers",
698700
a = I(df[[1]]), b = I(df[[2]]), c = I(df[[3]]),
699-
hovertemplate = .plotly_formatCustomData(df),
701+
hovertemplate = .plotly_formatCustomData(hoverDF),
700702
marker = list(
701703
color = colorArg$colors,
702704
size = dotSize

_pkgdown.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ navbar:
1414
- text: API
1515
href: reference/index.html
1616
- text: Changelog
17-
href: NEWS.html
17+
href: news/index.html
1818
right:
19+
- text: Welch Lab
20+
href: https://welch-lab.github.io/
1921
- icon: fab fa-github fa-lg
2022
href: https://github.com/welch-lab/CytoSimplex
23+
- icon: fab fa-twitter fa-lg
24+
href: https://twitter.com/LabWelch

man/rnaRaw.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rnaVelo.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/CytoSimplex.Rmd

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Simplex Visualization of Cell Fate Similarity in Single-Cell Data"
33
author: "Yichen Wang, Jialin Liu"
4-
date: "2023-05-15"
4+
date: "2024-04-22"
55
output: rmarkdown::html_vignette
66
vignette: >
77
%\VignetteIndexEntry{Simplex Visualization of Cell Fate Similarity in Single-Cell Data}
@@ -49,14 +49,25 @@ head(stats)
4949

5050
## Generating ternary plots
5151

52-
`plotTernary()` shows sample similarity in a ternary simplex -- equilateral triangle. The closer a dot, a cell, is to one vertex, the more similar the cell is to the cell cluster(s) the vertex represents. We recommend that users select the top marker genes for each terminal and only use them is the features for calculating the similarity.
52+
`plotTernary()` shows sample similarity in a ternary simplex -- equilateral triangle. The closer a dot, a cell, is to one vertex, the more similar the cell is to the cell cluster(s) the vertex represents. We recommend that users select the top marker genes for each terminal and only use them as the features for calculating the similarity.
5353

5454
```{R plotTernary, fig.height = 4, fig.width = 5}
5555
vt.tern <- c("OS", "RE", "CH")
5656
gene.tern <- selectTopFeatures(rnaRaw, clusterVar = rnaCluster, vertices = vt.tern)
5757
plotTernary(rnaRaw, clusterVar = rnaCluster, vertices = vt.tern, features = gene.tern)
5858
```
5959

60+
>The static figure depends on `ggplot2`, which is widely used for visualization in R. The binary simplex is plotted normally in ggplot 2D coordinates, while for the ternary simplex, the barycentric coordinate is drawn with 2D segments with cartesian coordinate, instead of implementing a ternary barycentric coordinate system. Users wishing to add customized alteration should pay attention to this.
61+
62+
### Interactive ternary plot
63+
64+
The same figure above can be shown in an interactive panel, powered by [plotly](https://plotly.com/r/). The interactive plot allows users to zoom in and out, and hover over the dots to see the cell names and the values of inferred similarity. To enable this feature, users only need to add `interactive = TRUE` in the function call.
65+
66+
```{R plotTernaryInteractive, fig.height = 4, fig.width = 5}
67+
plotTernary(rnaRaw, clusterVar = rnaCluster, vertices = vt.tern, features = gene.tern,
68+
interactive = TRUE)
69+
```
70+
6071
## Adding velocity information to ternary plot
6172

6273
RNA velocity is a quantitative measurement of cellular transitions from single-cell transcriptomics experiments and reveals transient cellular dynamics among a heterogeneous cell population (<a href="https://www.pnas.org/doi/10.1073/pnas.2105859118" target="_blank">Qiao, PNAS 2021</a>). We implemented a velocity visualization strategy that could be applied to ternary and quaternary simplex plot. The velocity information input format must be an N x N graph (sparse matrix, where N denotes number of cells). We have included a graph that matches with the cells in the example dataset in this package. This graph is a subset of the output from <a href="https://github.com/welch-lab/VeloVAE" target="_black">Python module `veloVAE`</a>, as part of the processed data from the publication mentioned at the start.
@@ -69,13 +80,13 @@ print(paste0("Class of `rnaVelo`: ", class(rnaVelo),
6980

7081
We create a number of square grids in the 2D plain of the ternary simplex (or cube grids in 3D space of the quaternary simplex), and aggregate the cells fall into each grid with taking the mean of velocity towards each of the vertices. Finally, we draw an arrow from the grid center pointing to each vertex with the length representing the aggregated mean velocity.
7182

83+
Interactive view with velocity information is also supported. The aggregated potential value can also be shown when hovering above the arrows.
84+
7285
```{R ternVelo, fig.width = 5, fig.height = 4}
7386
plotTernary(rnaRaw, clusterVar = rnaCluster, vertices = vt.tern,
74-
features = gene.tern, veloGraph = rnaVelo)
87+
features = gene.tern, veloGraph = rnaVelo, interactive = TRUE)
7588
```
7689

77-
>The previous two functions mainly depends of `ggplot2`, which is widely used to create figures in R. The binary simplex is plotted normally in ggplot 2D coordinates, while for the ternary simplex, the barycentric coordinate is drawn with 2D segments with cartesian coordinate, instead of implementing a ternary barycentric coordinate system. Users wishing to add customized alteration should pay attention to this.
78-
7990
## Exploration with each cluster
8091

8192
An argument `splitCluster` is supported for all three plotting functions. By setting `splitCluster = TRUE`, A list of plots will be returned, with one containing all cells, and each of the other sub-plots containing only dots (cells) belonging to one cluster in the annotation specified.
@@ -104,9 +115,7 @@ As shown in the subplots, the OCT stem cells has the transitional potential towa
104115

105116
## Create quaternary simplex plot
106117

107-
`plotQuaternary()` shows sample similarity in a quaternary simplex -- tetrahedron. The 3D visualization depends on package `plot3D` for creating static figure, and `rgl` for creating interactive 3D display. (Linux users may refer to [`rgl` documentation](https://dmurdoch.github.io/rgl/#installing-opengl-support) for installation guide)
108-
109-
For a quaternary simplex, we need one more cluster as a vertex. Here, we add the cells annotated as osteoblast-reticular transition cells (`"ORT"`) into the vertex list. We also add the velocity information in this example, as it will not be shown by default.
118+
For a quaternary simplex, we need one more cluster as a vertex. Here, we add the cells annotated as osteoblast-reticular transition cells (`"ORT"`) into the vertex list. We also add the velocity information in this example, as it will not be shown by default. Note that we provide interactive quaternary plot by default.
110119

111120
```{R plotQuaternary, fig.height = 4, fig.width = 6}
112121
vt.quat <- c("OS", "RE", "CH", "ORT")
@@ -115,7 +124,7 @@ plotQuaternary(rnaRaw, clusterVar = rnaCluster, vertices = vt.quat,
115124
features = gene.quat, veloGraph = rnaVelo)
116125
```
117126

118-
The 3D tetrahedron shown is automatically generated with an **interactive** web widget. If a static view is preferred, users can set `interactive = FALSE` in the function call, and adjust the view angle with `theta` and `phi` arguments.
127+
If a static view is preferred, users can set `interactive = FALSE` in the function call, and adjust the view angle with `theta` and `phi` arguments.
119128

120129
We have also implemented of GIF image generator that rotates the tetrahedron rounding the z-axis. Note that package `magick` is required for this feature. (<a href="https://cran.r-project.org/package=magick/vignettes/intro.html#Installing_magick" target="_blank">See here for how to install `magick` in detail</a>)
121130

0 commit comments

Comments
 (0)