Skip to content

Commit bf42ab8

Browse files
committed
doc(spatial): finish documentation for spatial plots
1 parent 740ed18 commit bf42ab8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+844
-311
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
^\.github\/.+$
2222
^Makefile$
2323
^Rplots\.pdf$
24+
^vignettes/articles$

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
any::clustree, any::ggwordcloud, any::ggalluvial, any::ggpubr, any::callr,
5757
any::ggforce, any::ggraph, any::ggridges, any::hexbin, any::igraph,
5858
any::scattermore, any::ggupset, any::iNEXT, any::metap, any::tidyprompt,
59-
any::terra, any::GiottoClass
59+
any::terra, any::GiottoClass, any::GiottoData
6060
6161
- uses: r-lib/actions/check-r-package@v2
6262
env:

DESCRIPTION

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Suggests:
4040
ggwordcloud,
4141
ggVennDiagram (>= 1.5.0),
4242
GiottoClass,
43+
GiottoData,
4344
hexbin,
4445
igraph,
4546
clustree,
@@ -52,12 +53,14 @@ Suggests:
5253
metap (>= 1.11),
5354
knitr,
5455
terra,
55-
rmarkdown
56+
rmarkdown,
57+
learnr
5658
LazyData: true
5759
LazyDataCompression: xz
5860
Remotes:
5961
pwwang/plotthis,
60-
drieslab/GiottoClass
62+
drieslab/GiottoClass,
63+
drieslab/GiottoData
6164
URL: https://github.com/pwwang/scplotter
6265
https://pwwang.github.io/scplotter/
6366
BugReports:

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ install:
1212
test:
1313
Rscript <(echo "devtools::test()")
1414

15+
# make notebooks EXECUTE=true to run the notebooks
1516
notebooks:
16-
jupyter nbconvert -y --to html notebooks/spatial/*.ipynb --output-dir=pkgdown/assets
17+
jupyter nbconvert $(if $(DEBUG),--execute) -y \
18+
--to html notebooks/spatial/*.ipynb \
19+
--output-dir=pkgdown/assets $(if $(EXECUTE),--execute) \
20+
--template lab
1721

1822
notebook: notebooks
1923
nb: notebooks

R/celldimplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' DimPlot
1+
#' CellDimPlot
22
#'
33
#' @description Dimension reduction plot
44
#' @param object A seurat object

R/clonalpositionalplot.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ ClonalPositionalPlot <- function (
232232
#' @importFrom scRepertoire percentKmer
233233
#' @importFrom plotthis BarPlot Heatmap
234234
#' @examples
235+
#' \donttest{
235236
#' set.seed(8525)
236237
#' data(contig_list, package = "scRepertoire")
237238
#' data <- scRepertoire::combineTCR(contig_list,
@@ -249,6 +250,7 @@ ClonalPositionalPlot <- function (
249250
#' ClonalKmerPlot(data, group_by = "Type")
250251
#' ClonalKmerPlot(data, group_by = "Type", plot_type = "line")
251252
#' ClonalKmerPlot(data, group_by = "Type", plot_type = "heatmap")
253+
#' }
252254
ClonalKmerPlot <- function (
253255
data, chain = "TRB", clone_call = "aa", k = 3, top = 25, group_by = "Sample",
254256
group_by_sep = "_", facet_by = NULL, split_by = NULL,

R/spatialplot.R

Lines changed: 78 additions & 33 deletions
Large diffs are not rendered by default.

R/spatialutils.R

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
#' When TRUE, the default graph will be used.
6363
#' When given as a character, it should be the name of the graph to use.
6464
#' If there is ":" in the name, the first part will be used as spat_unit, and the second part as the graph name.
65+
#' @param shape The shape of the points, alias of `points_shape`.
66+
#' See \url{https://ggplot2.tidyverse.org/reference/aes_linetype_size_shape.html} for more details.
6567
#' @param legend.position The position of the legend. Defaults to "right".
6668
#' @param legend.direction The direction of the legend. Defaults to "vertical".
6769
#' @param theme The theme to use for the plot. Defaults to `"theme_box"`.
@@ -119,7 +121,11 @@ NULL
119121
#' @param ... Additional arguments that will be parsed.
120122
#' @return A list of points arguments.
121123
.points_args <- function(args, ...) {
122-
args <- c(args, rlang::dots_list(...))
124+
args <- c(args, rlang::dots_list(..., .named = TRUE))
125+
if (length(args) == 0) {
126+
return(list())
127+
}
128+
123129
# The arguments without prefices are assumed to be the points arguments
124130
points_args <- args[
125131
!startsWith(names(args), "image_") & !startsWith(names(args), "masks_") &
@@ -131,13 +137,19 @@ NULL
131137
names(points_args2) <- sub("^points_", "", names(points_args2))
132138
conflicts <- intersect(names(points_args), names(points_args2))
133139
if (length(conflicts) > 0) {
134-
warning(paste(
135-
"[SpatPlot] The following arguments are defined as points_* arguments:",
140+
warning(paste0(
141+
"[SpatPlot] The following arguments are defined as points_* arguments: ",
136142
paste(conflicts, collapse = ", "),
137143
", and also passed directly (without 'points_' prefix). The points_* arguments will be used."
138144
))
139145
}
140-
c(points_args2, points_args)
146+
out <- c(points_args2, points_args)
147+
dup_names <- duplicated(names(out))
148+
if (any(dup_names)) {
149+
out[-which(dup_names)]
150+
} else {
151+
out
152+
}
141153
}
142154

143155
#' Process points layer for Seurat spatial plots
@@ -149,11 +161,16 @@ NULL
149161
#' @return A list containing the ggplot2 layer object and the facet_by variable if applicable.
150162
.seurat_points_layer <- function(
151163
object, fov = NULL, boundaries = NULL, x = "x", y = "y", swap_xy = TRUE,
152-
image, args, crop, points_data, ext_unscaled, scale_factor, group_by,
164+
image, args, crop, points_data, ext_unscaled, scale_factor, group_by, shape,
153165
features, layer, legend.position, legend.direction, flip_y, ext
154166
) {
155167
# The arguments passed as points_* are collected in args
156-
points_args <- .points_args(args, x = x, y = y)
168+
if (shape != 16) {
169+
points_args <- .points_args(args, x = x, y = y, shape = shape)
170+
} else {
171+
# allow shape to be overridden by points_shape without warning
172+
points_args <- .points_args(args, x = x, y = y)
173+
}
157174
get_cells <- if (is.null(fov)) rownames else function(x) x$cell
158175

159176
if (crop) {
@@ -237,11 +254,11 @@ NULL
237254
#' @return A list containing the ggplot2 layer object and the facet_by variable if applicable.
238255
.seurat_points_layer_molecules <- function(
239256
object, fov, boundaries, x = "x", y = "y", swap_xy = TRUE,
240-
image, args, nmols, crop, points_data, ext_unscaled, scale_factor, group_by,
257+
image, args, nmols, crop, points_data, ext_unscaled, scale_factor, group_by, shape,
241258
features, layer, legend.position, legend.direction, flip_y, ext
242259
) {
243260

244-
points_args <- .points_args(args, x = x, y = y)
261+
points_args <- .points_args(args, x = x, y = y, shape = shape)
245262

246263
points_args$data <- Seurat::FetchData(object[[fov]], vars = features, nmols = nmols)
247264
if (swap_xy) {

_pkgdown.yml

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
11
url: https://pwwang.github.io/scplotter/
22
template:
33
bootstrap: 5
4-
bootswatch: lumen
4+
light-switch: true
5+
bslib:
6+
bootswatch: litera
7+
pkgdown-nav-height: 80px
58
navbar:
69
structure:
7-
left: [intro, reference, articles, spatial, tutorials, news]
810
right: [search, github]
11+
left: [intro, reference, articles, spatial-examples]
912
components:
10-
spatial:
11-
text: Spatial
13+
articles:
14+
text: "Articles"
1215
menu:
13-
- text: "Visualizing 10x Visum data prepared with Seurat"
14-
href: Seurat.10x_Visium.html
15-
- text: "Visualizing Visium HD data prepared with Seurat"
16-
href: Seurat.10x_VisiumHD.html
17-
- text: "Visualizing SlideSeq data prepared with Seurat"
18-
href: Seurat.SlideSeq.html
19-
- text: "Visualizing Xenium data prepared with Seurat"
20-
href: Seurat.Xenium.html
21-
- text: "Visualizing Nanostring CosMx data prepared with Seurat"
22-
href: Seurat.Nanostring_CosMx.html
23-
- text: "Visualizing Visium data prepared with Giotto"
24-
href: Giotto.Visium.html
25-
- text: "Visualizing VisiumHD data prepared with Giotto"
26-
href: Giotto.VisiumHD.html
27-
- text: "Visualizing Xenium data prepared with Giotto"
28-
href: Giotto.Xenium.html
29-
- text: "Visualizing SlideSeq data prepared with Giotto"
30-
href: Giotto.SlideSeq.html
31-
- text: "Visualizing Spatial CITE-Seq data prepared with Giotto"
32-
href: Giotto.Spatial_CITE-Seq.html
33-
- text: "Visualizing Nanostirng CosMx data prepared with Giotto"
34-
href: Giotto.Nanostring_CosMx.html
16+
- text: "Visualizing data with LLMs"
17+
href: articles/Visualizing_data_with_LLMs.html
18+
- text: "Knowing your spatial data and visualization"
19+
href: articles/Knowing_your_spatial_data_and_visualization.html
20+
spatial-examples:
21+
text: "Spatial Examples"
22+
menu:
23+
- text: "Visualizing 10x Visium data prepared with Seurat"
24+
href: articles/Seurat_10x_Visium.html
25+
- text: "Visualizing 10x VisiumHD data prepared with Seurat"
26+
href: articles/Seurat_10x_VisiumHD.html
27+
- text: "Visualizing SlideSeq data prepared with Seurat"
28+
href: articles/Seurat_SlideSeq.html
29+
- text: "Visualizing Xenium data prepared with Seurat"
30+
href: articles/Seurat_Xenium.html
31+
- text: "Visualizing Nanostring CosMx data prepared with Seurat"
32+
href: articles/Seurat_Nanostring_CosMx.html
33+
- text: "Visualizing Visium data prepared with Giotto"
34+
href: articles/Giotto_Visium.html
35+
- text: "Visualizing VisiumHD data prepared with Giotto"
36+
href: articles/Giotto_VisiumHD.html
37+
- text: "Visualizing Xenium data prepared with Giotto"
38+
href: articles/Giotto_Xenium.html
39+
- text: "Visualizing SlideSeq data prepared with Giotto"
40+
href: articles/Giotto_SlideSeq.html
41+
- text: "Visualizing Spatial CITE-Seq data prepared with Giotto"
42+
href: articles/Giotto_Spatial_CITE-Seq.html
43+
- text: "Visualizing Nanostirng CosMx data prepared with Giotto"
44+
href: articles/Giotto_Nanostring_CosMx.html
45+
3546
reference:
3647
- title: scRNA-seq
3748
desc: Functions for plotting single cell RNA-seq data

man/CellDimPlot.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.

0 commit comments

Comments
 (0)