-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path06-quality_control.Rmd
608 lines (511 loc) · 26.9 KB
/
06-quality_control.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
# Image and cell-level quality control
The following section discusses possible quality indicators for data obtained
by IMC and other highly multiplexed imaging technologies. Here, we will focus
on describing quality metrics on the single-cell as well as image level.
## Read in the data
We will first read in the data processed in previous sections:
```{r read-data, message=FALSE}
images <- readRDS("data/images.rds")
masks <- readRDS("data/masks.rds")
spe <- readRDS("data/spe.rds")
```
## Segmentation quality control {#seg-quality}
The first step after image segmentation is to observe its accuracy.
Without having ground-truth data readily available, a common approach to
segmentation quality control is to overlay segmentation masks on composite images
displaying channels that were used for segmentation.
The [cytomapper](https://www.bioconductor.org/packages/release/bioc/html/cytomapper.html)
package supports exactly this tasks by using the `plotPixels` function.
Here, we select 3 random images and perform image- and channel-wise
normalization (channels are first min-max normalized and scaled to a range of
0-1 before clipping the maximum intensity to 0.2).
```{r overlay-masks, message=FALSE}
library(cytomapper)
set.seed(20220118)
img_ids <- sample(seq_along(images), 3)
# Normalize and clip images
cur_images <- images[img_ids]
cur_images <- cytomapper::normalize(cur_images, separateImages = TRUE)
cur_images <- cytomapper::normalize(cur_images, inputRange = c(0, 0.2))
plotPixels(cur_images,
mask = masks[img_ids],
img_id = "sample_id",
missing_colour = "white",
colour_by = c("CD163", "CD20", "CD3", "Ecad", "DNA1"),
colour = list(CD163 = c("black", "yellow"),
CD20 = c("black", "red"),
CD3 = c("black", "green"),
Ecad = c("black", "cyan"),
DNA1 = c("black", "blue")),
image_title = NULL,
legend = list(colour_by.title.cex = 0.7,
colour_by.labels.cex = 0.7))
```
We can see that nuclei are centered within the segmentation masks and all cell
types are correctly segmented (note: to zoom into the image you can right click
and select `Open Image in New Tab`). A common challenge here is to segment large (e.g.,
epithelial cells - in cyan) _versus_ small (e.g., B cells - in red). However, the
segmentation approach here appears to correctly segment cells across different
sizes.
An easier and interactive way of observing segmentation quality is to use the
interactive image viewer provided by the
[cytoviewer](https://github.com/BodenmillerGroup/cytoviewer) R/Bioconductor
package [@Meyer2024]. Under "Image-level" > "Basic controls", up to six markers
can be selected for visualization. The contrast of each marker can be adjusted.
Under "Image-level" > "Advanced controls", click the "Show cell outlines" box
to outline segmented cells on the images.
```{r, message = FALSE}
library(cytoviewer)
app <- cytoviewer(image = images,
mask = masks,
object = spe,
cell_id = "ObjectNumber",
img_id = "sample_id")
if (interactive()) {
shiny::runApp(app)
}
```
An additional approach to observe cell segmentation quality and potentially also
antibody specificity issues is to visualize single-cell expression in form of a
heatmap. Here, we sub-sample the dataset to 2000 cells for visualization
purposes and overlay the cancer type from which the cells were extracted.
```{r segmentation-heatmap, message=FALSE, fig.height=7}
library(dittoSeq)
library(viridis)
cur_cells <- sample(seq_len(ncol(spe)), 2000)
dittoHeatmap(spe[,cur_cells],
genes = rownames(spe)[rowData(spe)$use_channel],
assay = "exprs",
cluster_cols = TRUE,
scale = "none",
heatmap.colors = viridis(100),
annot.by = "indication",
annotation_colors = list(indication = metadata(spe)$color_vectors$indication))
```
We can differentiate between epithelial cells (Ecad+) and immune cells
(CD45RO+). Some of the markers are detected in specific cells (e.g., Ki67, CD20,
Ecad) while others are more broadly expressed across cells (e.g., HLADR, B2M,
CD4).
## Image-level quality control {#image-quality}
Image-level quality control is often performed using tools that offer a
graphical user interface such as [QuPath](https://qupath.github.io/),
[FIJI](https://imagej.net/software/fiji/) and the previously mentioned
[cytoviewer](https://github.com/BodenmillerGroup/cytoviewer) package. Viewers
that were specifically developed for IMC data can be seen
[here](https://bodenmillergroup.github.io/IMCWorkflow/viewers.html). In this
section, we will specifically focus on quantitative metrics to assess image
quality.
It is often of interest to calculate the signal-to-noise ratio (SNR) for
individual channels and markers. Here, we define the SNR as:
$$SNR = I_s/I_n$$
where $I_s$ is the intensity of the signal (mean intensity of pixels with true
signal) and $I_n$ is the intensity of the noise (mean intensity of pixels
containing noise). This definition of the SNR is just one of many and other
measures can be applied. Finding a threshold that separates pixels containing
signal and pixels containing noise is not trivial and different approaches can
be chosen. Here, we use the `otsu` thresholding approach to find pixels of the
"foreground" (i.e., signal) and "background" (i.e., noise). The SNR is then
defined as the mean intensity of foreground pixels divided by the mean intensity
of background pixels. We compute this measure as well as the mean signal
intensity per image. The plot below shows the average SNR _versus_ the average
signal intensity across all images.
```{r image-snr, message=FALSE, warning=FALSE}
library(tidyverse)
library(ggrepel)
library(EBImage)
cur_snr <- lapply(names(images), function(x){
img <- images[[x]]
mat <- apply(img, 3, function(ch){
# Otsu threshold
thres <- otsu(ch, range = c(min(ch), max(ch)), levels = 65536)
# Signal-to-noise ratio
snr <- mean(ch[ch > thres]) / mean(ch[ch <= thres])
# Signal intensity
ps <- mean(ch[ch > thres])
return(c(snr = snr, ps = ps))
})
t(mat) %>% as.data.frame() %>%
mutate(image = x,
marker = colnames(mat)) %>%
pivot_longer(cols = c(snr, ps))
})
cur_snr <- do.call(rbind, cur_snr)
cur_snr %>%
group_by(marker, name) %>%
summarize(log_mean = log2(mean(value))) %>%
pivot_wider(names_from = name, values_from = log_mean) %>%
ggplot() +
geom_point(aes(ps, snr)) +
geom_label_repel(aes(ps, snr, label = marker)) +
theme_minimal(base_size = 15) + ylab("Signal-to-noise ratio [log2]") +
xlab("Signal intensity [log2]")
```
We observe PD1, LAG3 and cleaved PARP to have high SNR but low signal intensity
meaning that in general these markers are not abundantly expressed. The Iridium
intercalator (here marked as DNA1 and DNA2) has the highest signal intensity
but low SNR. This might be due to staining differences between individual nuclei
where some nuclei are considered as background. We do however observe high
SNR and sufficient signal intensity for the majority of markers.
Otsu thesholding and SNR calculation does not perform well if the markers are
lowly abundant. In the next code chunk, we will remove markers that have
a positive signal of below 2 per image.
```{r, snr-adjusted, message=FALSE, warning=FALSE}
cur_snr <- cur_snr %>%
pivot_wider(names_from = name, values_from = value) %>%
filter(ps > 2) %>%
pivot_longer(cols = c(snr, ps))
cur_snr %>%
group_by(marker, name) %>%
summarize(log_mean = log2(mean(value))) %>%
pivot_wider(names_from = name, values_from = log_mean) %>%
ggplot() +
geom_point(aes(ps, snr)) +
geom_label_repel(aes(ps, snr, label = marker)) +
theme_minimal(base_size = 15) + ylab("Signal-to-noise ratio [log2]") +
xlab("Signal intensity [log2]")
```
This visualization shows a reduces SNR for PD1, LAG3 and cleaved PARP which was
previously inflated due to low signal.
Another quality indicator is the image area covered by cells (or biological
tissue). This metric identifies ROIs where little cells are present, possibly
hinting at incorrect selection of the ROI. We can compute the percentage of
covered image area using the metadata contained in the `SpatialExperiment`
object:
```{r cell-density}
cell_density <- colData(spe) %>%
as.data.frame() %>%
group_by(sample_id) %>%
# Compute the number of pixels covered by cells and
# the total number of pixels
summarize(cell_area = sum(area),
no_pixels = mean(width_px) * mean(height_px)) %>%
# Divide the total number of pixels
# by the number of pixels covered by cells
mutate(covered_area = cell_area / no_pixels)
# Visualize the image area covered by cells per image
ggplot(cell_density) +
geom_point(aes(reorder(sample_id,covered_area), covered_area)) +
theme_minimal(base_size = 15) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, size = 15)) +
ylim(c(0, 1)) +
ylab("% covered area") + xlab("")
```
We observe that two of the 14 images show unusually low cell coverage. These
two images can now be visualized using `cytomapper`.
```{r low-density-images, message=FALSE}
# Normalize and clip images
cur_images <- images[c("Patient4_005", "Patient4_007")]
cur_images <- cytomapper::normalize(cur_images, separateImages = TRUE)
cur_images <- cytomapper::normalize(cur_images, inputRange = c(0, 0.2))
plotPixels(cur_images,
mask = masks[c("Patient4_005", "Patient4_007")],
img_id = "sample_id",
missing_colour = "white",
colour_by = c("CD163", "CD20", "CD3", "Ecad", "DNA1"),
colour = list(CD163 = c("black", "yellow"),
CD20 = c("black", "red"),
CD3 = c("black", "green"),
Ecad = c("black", "cyan"),
DNA1 = c("black", "blue")),
legend = list(colour_by.title.cex = 0.7,
colour_by.labels.cex = 0.7))
```
These two images display less dense tissue structure but overall the images are
intact and appear to be segmented correctly.
Finally, it can be beneficial to visualize the mean marker expression per image
to identify images with outlying marker expression. This check does not
indicate image quality _per se_ but can highlight biological differences. Here,
we will use the `aggregateAcrossCells` function of the
`r BiocStyle::Biocpkg("scuttle")` package to compute the mean expression per
image. For visualization purposes, we again `asinh` transform the mean expression
values.
```{r mean-expression-per-image, message=FALSE, fig.height=7}
library(scuttle)
image_mean <- aggregateAcrossCells(spe,
ids = spe$sample_id,
statistics="mean",
use.assay.type = "counts")
assay(image_mean, "exprs") <- asinh(counts(image_mean))
dittoHeatmap(image_mean, genes = rownames(spe)[rowData(spe)$use_channel],
assay = "exprs", cluster_cols = TRUE, scale = "none",
heatmap.colors = viridis(100),
annot.by = c("indication", "patient_id", "ROI"),
annotation_colors = list(indication = metadata(spe)$color_vectors$indication,
patient_id = metadata(spe)$color_vectors$patient_id,
ROI = metadata(spe)$color_vectors$ROI),
show_colnames = TRUE)
```
We observe extensive biological variation across the 14 images specifically for
some of the cell phenotype markers including the macrophage marker CD206, the B
cell marker CD20, the neutrophil marker CD15, and the proliferation marker Ki67.
These differences will be further studied in the following chapters.
## Cell-level quality control {#cell-quality}
In the following paragraphs we will look at different metrics and visualization
approaches to assess data quality (as well as biological differences) on the
single-cell level.
Related to the signal-to-noise ratio (SNR) calculated above on the pixel-level,
a similar measure can be derived on the single-cell level. Here, we will use
a two component Gaussian mixture model for each marker to find cells
with positive and negative expression. The SNR is defined as:
$$SNR = I_s/I_n$$
where $I_s$ is the intensity of the signal (mean intensity of cells with
positive signal) and $I_n$ is the intensity of the noise (mean intensity of
cells lacking expression). To define cells with positive and negative marker
expression, we fit the mixture model across the transformed counts of all cells
contained in the `SpatialExperiment` object. Next, for each marker we calculate
the mean of the non-transformed counts for the positive and the negative cells.
The SNR is then the ratio between the mean of the positive signal and the mean
of the negative signal.
```{r cell-snr, message=FALSE, warning=FALSE, results="hide", fig.keep="all"}
library(mclust)
set.seed(220224)
mat <- sapply(seq_len(nrow(spe)), function(x){
cur_exprs <- assay(spe, "exprs")[x,]
cur_counts <- assay(spe, "counts")[x,]
cur_model <- Mclust(cur_exprs, G = 2)
mean1 <- mean(cur_counts[cur_model$classification == 1])
mean2 <- mean(cur_counts[cur_model$classification == 2])
signal <- ifelse(mean1 > mean2, mean1, mean2)
noise <- ifelse(mean1 > mean2, mean2, mean1)
return(c(snr = signal/noise, ps = signal))
})
cur_snr <- t(mat) %>% as.data.frame() %>%
mutate(marker = rownames(spe))
cur_snr %>% ggplot() +
geom_point(aes(log2(ps), log2(snr))) +
geom_label_repel(aes(log2(ps), log2(snr), label = marker)) +
theme_minimal(base_size = 15) + ylab("Signal-to-noise ratio [log2]") +
xlab("Signal intensity [log2]")
```
Next, we observe the distributions of cell size across the individual images.
Differences in cell size distributions can indicate segmentation biases due to
differences in cell density or can indicate biological differences due to cell
type compositions (tumor cells tend to be larger than immune cells).
```{r cell-size, message=FALSE}
dittoPlot(spe, var = "area",
group.by = "sample_id",
plots = "boxplot") +
ylab("Cell area") + xlab("")
summary(spe$area)
```
The median cell size is `r median(spe$area)` pixels with a median major axis
length of `r round(median(spe$axis_major_length), digits = 1)`. The largest cell
has an area of `r max(spe$area)` pixels which relates to a diameter of
`r round(sqrt(max(spe$area)), digits = 1)` pixels assuming a circular shape.
Overall, the distribution of cell sizes is similar across images with images from
`Patient4_005` and `Patient4_007` showing a reduced average cell size. These
images contain fewer tumor cells which can explain the smaller average cell size.
We detect very small cells in the dataset and will remove them.
The chosen threshold is arbitrary and needs to be adjusted per dataset.
```{r remove-small-cells}
sum(spe$area < 5)
spe <- spe[,spe$area >= 5]
```
Another quality indicator can be an absolute measure of cell density often
reported in cells per mm$^2$.
```{r no-cells-per-image, message=FALSE}
cell_density <- colData(spe) %>%
as.data.frame() %>%
group_by(sample_id) %>%
summarize(cell_count = n(),
no_pixels = mean(width_px) * mean(height_px)) %>%
mutate(cells_per_mm2 = cell_count/(no_pixels/1000000))
ggplot(cell_density) +
geom_point(aes(reorder(sample_id,cells_per_mm2), cells_per_mm2)) +
theme_minimal(base_size = 15) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, size = 8)) +
ylab("Cells per mm2") + xlab("")
```
The number of cells per mm$^2$ varies across images which also depends on the
number of tumor/non-tumor cells. As we can see in the following sections, some
immune cells appear in cell dense regions while other stromal regions are less
dense.
The data presented here originate from samples from different locations with
potential differences in pre-processing and each sample was stained individually.
These (and other) technical aspects can induce staining differences between
samples or batches of samples. Observing potential staining differences can be
crucial to assess data quality. We will use ridgeline visualizations to check
differences in staining patterns:
```{r ridges, message=FALSE, warning = FALSE, fig.width=7, fig.height=25}
multi_dittoPlot(spe, vars = rownames(spe)[rowData(spe)$use_channel],
group.by = "patient_id", plots = "ridgeplot",
assay = "exprs",
color.panel = metadata(spe)$color_vectors$patient_id)
```
We observe variations in the distributions of marker expression across patients.
These variations may arise partly from different abundances of cells in
different images (e.g., Patient3 may have higher numbers of CD11c+ and PD1+
cells) as well as staining differences between samples. While most of the
selected markers are specifically expressed in immune cell subtypes, we can see
that E-Cadherin (a marker for epithelial (tumor) cells) shows a similar
expression range across all patients.
Finally, we will use non-linear dimensionality reduction methods to project
cells from a high-dimensional (40) down to a low-dimensional (2) space. For this
the `r BiocStyle::Biocpkg("scater")` package provides the `runUMAP` and
`runTSNE` function. To ensure reproducibility, we will need to set a seed;
however different seeds and different parameter settings (e.g., the `perplexity`
parameter in the `runTSNE` function) need to be tested to avoid
over-interpretation of visualization artefacts. For dimensionality reduction, we
will use all channels that show biological variation across the dataset.
However, marker selection can be performed with different biological questions
in mind. Here, both the `runUMAP` and `runTSNE` function are not deterministic,
meaning they produce different results across different runs. We therefore
set a `seed` in this chunk for reproducibility purposes.
```{r dimred, message=FALSE}
library(scater)
set.seed(220225)
spe <- runUMAP(spe, subset_row = rowData(spe)$use_channel, exprs_values = "exprs")
spe <- runTSNE(spe, subset_row = rowData(spe)$use_channel, exprs_values = "exprs")
```
After dimensionality reduction, the low-dimensional embeddings are stored in the
`reducedDim` slot.
```{r show-dimred-slot}
reducedDims(spe)
head(reducedDim(spe, "UMAP"))
```
Visualization of the low-dimensional embedding facilitates assessment of
potential "batch effects". The `dittoDimPlot`
function allows flexible visualization. It returns `ggplot` objects which
can be further modified.
```{r visualizing-dimred-1, message=FALSE, fig.height=8}
library(patchwork)
# visualize patient id
p1 <- dittoDimPlot(spe, var = "patient_id", reduction.use = "UMAP", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$patient_id) +
ggtitle("Patient ID on UMAP")
p2 <- dittoDimPlot(spe, var = "patient_id", reduction.use = "TSNE", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$patient_id) +
ggtitle("Patient ID on TSNE")
# visualize region of interest id
p3 <- dittoDimPlot(spe, var = "ROI", reduction.use = "UMAP", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$ROI) +
ggtitle("ROI ID on UMAP")
p4 <- dittoDimPlot(spe, var = "ROI", reduction.use = "TSNE", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$ROI) +
ggtitle("ROI ID on TSNE")
# visualize indication
p5 <- dittoDimPlot(spe, var = "indication", reduction.use = "UMAP", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$indication) +
ggtitle("Indication on UMAP")
p6 <- dittoDimPlot(spe, var = "indication", reduction.use = "TSNE", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$indication) +
ggtitle("Indication on TSNE")
(p1 + p2) / (p3 + p4) / (p5 + p6)
```
```{r, visualizing-dimred-2, message=FALSE}
# visualize marker expression
p1 <- dittoDimPlot(spe, var = "Ecad", reduction.use = "UMAP",
assay = "exprs", size = 0.2) +
scale_color_viridis(name = "Ecad") +
ggtitle("E-Cadherin expression on UMAP")
p2 <- dittoDimPlot(spe, var = "CD45RO", reduction.use = "UMAP",
assay = "exprs", size = 0.2) +
scale_color_viridis(name = "CD45RO") +
ggtitle("CD45RO expression on UMAP")
p3 <- dittoDimPlot(spe, var = "Ecad", reduction.use = "TSNE",
assay = "exprs", size = 0.2) +
scale_color_viridis(name = "Ecad") +
ggtitle("Ecad expression on TSNE")
p4 <- dittoDimPlot(spe, var = "CD45RO", reduction.use = "TSNE",
assay = "exprs", size = 0.2) +
scale_color_viridis(name = "CD45RO") +
ggtitle("CD45RO expression on TSNE")
(p1 + p2) / (p3 + p4)
```
We observe a strong separation of tumor cells (Ecad+ cells) between the
patients. Here, each patient was diagnosed with a different tumor type. The
separation of tumor cells could be of biological origin since tumor cells tend
to display differences in expression between patients and cancer types and/or of
technical origin: the panel only contains a single tumor marker (E-Cadherin) and
therefore slight technical differences in staining causes visible separation
between cells of different patients. Nevertheless, the immune compartment
(CD45RO+ cells) mix between patients and we can rule out systematic staining
differences between patients.
## Save objects
The modified `SpatialExperiment` object is saved for further downstream analysis.
```{r save-objects-quality-control}
saveRDS(spe, "data/spe.rds")
```
```{r testing, include=FALSE}
library(testthat)
expect_equal(reducedDimNames(spe), c("UMAP", "TSNE"))
expect_equal(head(reducedDim(spe, "UMAP"), n = 10),
structure(c(-4.81016665957092, -4.39734727404236, -4.36988336107849,
-4.08161431810974, -6.23401195070862, -5.66659671328186, -4.13260585329651,
-0.930108251787412, -6.33803874514221, -5.40764981768249, -3.77736220987329,
-3.45603595407495, -3.44556103380213, -3.16211901338587, -2.43397555978784,
-3.42805753381739, -3.22162519128809, 4.09678735105505, -2.20264754922876,
-3.72411928804407), dim = c(10L, 2L), dimnames = list(c("Patient1_001_1",
"Patient1_001_2", "Patient1_001_3", "Patient1_001_4", "Patient1_001_5",
"Patient1_001_6", "Patient1_001_7", "Patient1_001_8", "Patient1_001_9",
"Patient1_001_10"), c("UMAP1", "UMAP2"))), tolerance = 0.01)
expect_equal(reducedDim(spe, "UMAP")[100:130,],
structure(c(-3.89626533053039, -7.13317567370056, -6.77943021319031,
-7.11419230959533, -2.78164083025574, -3.94929200670837, -5.95046884081482,
0.763116416715395, -5.68849593660949, -6.22845536730407, -6.58062154314636,
-5.80118590853332, -6.25312644503235, -5.86530810854553, -7.08645230791687,
-4.12036305925964, -5.97095376513122, -4.08220035097717, -5.91776162645935,
0.557355967544329, -7.09781867525696, -5.62668353579162, -5.04605323336242,
-4.7885444786322, -7.22946149370788, -5.26700240633606, -4.82962876818298,
-4.25380879900573, 1.08371841647507, 1.44114249684693, -4.87143928072571,
-3.41620216997156, -3.93748961122522, -2.58227525384912, -4.26784573228846,
-5.4897724214364, -3.4107941213418, -3.86142430933008, 3.20950664846411,
-3.71332822473535, -3.86072955759058, -2.47767458589563, -3.84708223970423,
-4.17958079011927, -3.9504874769021, -2.7868140760232, -3.12866697938928,
-2.78958783777246, -2.86517844827661, -3.41490874917993, 1.00301005212774,
-3.6809254709054, -3.49266205461511, -2.95477948816309, -2.56105003984461,
-3.1081076684762, -3.18702707918177, -3.78098068864832, -3.24055348070154,
0.368578153533841, 0.224757569713498, -2.99749766023645), dim = c(31L,
2L), dimnames = list(c("Patient1_001_100", "Patient1_001_101",
"Patient1_001_102", "Patient1_001_103", "Patient1_001_104", "Patient1_001_105",
"Patient1_001_106", "Patient1_001_107", "Patient1_001_108", "Patient1_001_109",
"Patient1_001_110", "Patient1_001_111", "Patient1_001_112", "Patient1_001_113",
"Patient1_001_114", "Patient1_001_115", "Patient1_001_116", "Patient1_001_117",
"Patient1_001_118", "Patient1_001_119", "Patient1_001_120", "Patient1_001_121",
"Patient1_001_122", "Patient1_001_123", "Patient1_001_124", "Patient1_001_125",
"Patient1_001_126", "Patient1_001_127", "Patient1_001_128", "Patient1_001_129",
"Patient1_001_130"), c("UMAP1", "UMAP2"))), tolerance = 0.01)
expect_equal(head(reducedDim(spe, "TSNE"), n = 10),
structure(c(8.5000231819133, 8.69417707607171, 8.66506409812202,
8.70346540608834, -4.85956000801397, -3.50347074831182, 8.62888756799549,
-8.0907749992851, 3.45775862206781, 7.54108785460927, -30.1566664235465,
-28.3558044334759, -28.2668374978953, -26.5385662781522, -21.5856934742621,
-26.4730337308963, -26.8568530864791, 19.6159281655837, 20.5991986552636,
-32.2252709733315), dim = c(10L, 2L), dimnames = list(c("Patient1_001_1",
"Patient1_001_2", "Patient1_001_3", "Patient1_001_4", "Patient1_001_5",
"Patient1_001_6", "Patient1_001_7", "Patient1_001_8", "Patient1_001_9",
"Patient1_001_10"), c("TSNE1", "TSNE2"))), tolerance = 0.01)
expect_equal(reducedDim(spe, "TSNE")[100:130,],
structure(c(10.6418413622177, -8.19603725541398, -7.57330997290384,
-11.9649205211375, 21.7044793746905, 10.5299308898414, -2.89361532839768,
-14.1479057033804, 7.04881694519824, -2.27845635304146, -6.55119000983192,
-1.82422115143277, -2.4097229038924, -1.64709145874245, -9.64650462467637,
8.35520499244715, -2.63232041735159, -6.92707082054738, -2.87217958426136,
-8.06273786914118, -12.041109790411, 7.21278447587393, 2.78699525470502,
2.34486289464684, -9.89574054981405, 2.1828274368045, 8.49912719972949,
8.11668313724476, -5.71319426232428, -0.190728643680821, 3.48920576978465,
-25.9423147604023, -32.0648373504634, -24.1480435193885, -33.8780988685417,
-23.1903399682141, -26.1356569942554, -33.8181999524557, 0.0329466224873345,
-32.6325983943606, -32.6301008178222, -24.1756860322692, -32.9821005945978,
-35.8676859419689, -34.0911214749092, -25.5808689943855, -26.7586018145491,
-25.6034715982434, -20.3596025910865, -28.0932829916676, -5.40775249366363,
-31.3872828096166, -32.5651665675897, -27.111323151666, -24.101850440361,
-26.9341083442237, -28.5420714838967, -30.3678523339134, -27.0214667414901,
-5.02684547281321, -16.0298817965721, -26.769553922745), dim = c(31L,
2L), dimnames = list(c("Patient1_001_100", "Patient1_001_101",
"Patient1_001_102", "Patient1_001_103", "Patient1_001_104", "Patient1_001_105",
"Patient1_001_106", "Patient1_001_107", "Patient1_001_108", "Patient1_001_109",
"Patient1_001_110", "Patient1_001_111", "Patient1_001_112", "Patient1_001_113",
"Patient1_001_114", "Patient1_001_115", "Patient1_001_116", "Patient1_001_117",
"Patient1_001_118", "Patient1_001_119", "Patient1_001_120", "Patient1_001_121",
"Patient1_001_122", "Patient1_001_123", "Patient1_001_124", "Patient1_001_125",
"Patient1_001_126", "Patient1_001_127", "Patient1_001_128", "Patient1_001_129",
"Patient1_001_130"), c("TSNE1", "TSNE2"))), tolerance = 0.01)
```
## Session Info
<details>
<summary>SessionInfo</summary>
```{r, echo = FALSE}
sessionInfo()
```
</details>