-
Notifications
You must be signed in to change notification settings - Fork 12
/
07-batch_correction.Rmd
1347 lines (1226 loc) · 80.4 KB
/
07-batch_correction.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
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Batch effect correction {#batch-effects}
In Section \@ref(cell-quality) we observed staining/expression differences
between the individual samples. This can arise due to technical (e.g.,
differences in sample processing) as well as biological (e.g., differential
expression between patients/indications) effects. However, the combination of these effects
hinders cell phenotyping via clustering as highlighted in Section \@ref(clustering).
To integrate cells across samples, we can use computational
strategies developed for correcting batch effects in single-cell RNA sequencing
data. In the following sections, we will use functions of the
[batchelor](https://www.bioconductor.org/packages/release/bioc/html/batchelor.html),
[harmony](https://github.com/immunogenomics/harmony) and
[Seurat](https://satijalab.org/seurat/articles/integration_introduction.html)
packages to correct for such batch effects.
Of note: the correction approaches presented here aim at removing any
differences between samples. This will also remove biological differences
between the patients/indications. Nevertheless, integrating cells across samples
can facilitate the detection of cell phenotypes via clustering.
First, we will read in the `SpatialExperiment` object containing the single-cell
data.
```{r read-data-batch-correction, message=FALSE}
spe <- readRDS("data/spe.rds")
```
## fastMNN correction
The `batchelor` package provides the `mnnCorrect` and `fastMNN` functions to
correct for differences between samples/batches. Both functions build up on
finding mutual nearest neighbors (MNN) among the cells of different samples and
correct expression differences between the batches [@Haghverdi2018]. The `mnnCorrect` function
returns corrected expression counts while the `fastMNN` functions performs the
correction in reduced dimension space. As such, `fastMNN` returns integrated
cells in form of a low dimensional embedding.
Paper: [Batch effects in single-cell RNA-sequencing data are corrected by matching mutual nearest neighbors](https://www.nature.com/articles/nbt.4091)
Documentation: [batchelor](https://www.bioconductor.org/packages/release/bioc/vignettes/batchelor/inst/doc/correction.html)
### Perform sample correction
Here, we apply the `fastMNN` function to integrate cells between
patients. By setting `auto.merge = TRUE` the function estimates the best
batch merging order by maximizing the number of MNN pairs at each merging step.
This is more time consuming than merging sequentially based on how batches appear in the
dataset (default). We again select the markers defined in Section \@ref(cell-processing)
for sample correction.
The function returns a `SingleCellExperiment` object which contains corrected
low-dimensional coordinates for each cell in the `reducedDim(out, "corrected")`
slot. This low-dimensional embedding can be further used for clustering and
non-linear dimensionality reduction. We check that the order of cells is the
same between the input and output object and then transfer the corrected
coordinates to the main `SpatialExperiment` object.
```{r, echo=FALSE}
start_time <- Sys.time()
```
```{r batch-correction-fastMNN, message=FALSE, warning=FALSE}
library(batchelor)
set.seed(220228)
out <- fastMNN(spe, batch = spe$patient_id,
auto.merge = TRUE,
subset.row = rowData(spe)$use_channel,
assay.type = "exprs")
# Check that order of cells is the same
stopifnot(all.equal(colnames(spe), colnames(out)))
# Transfer the correction results to the main spe object
reducedDim(spe, "fastMNN") <- reducedDim(out, "corrected")
```
```{r, echo=FALSE}
end_time <- Sys.time()
```
The computational time of the `fastMNN` function call is
`r round(as.numeric(difftime(end_time, start_time, units = "mins")), digits = 2)` minutes.
Of note, the warnings that the `fastMNN` function produces can be avoided as follows:
1. The following warning can be avoided by setting `BSPARAM = BiocSingular::ExactParam()`
```
Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth = TRUE, :
You're computing too large a percentage of total singular values, use a standard svd instead.
```
2. The following warning can be avoided by requesting fewer singular values by setting `d = 30`
```
In check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - :
more singular values/vectors requested than available
```
### Quality control of correction results
The `fastMNN` function further returns outputs that can be used to assess the
quality of the batch correction. The `metadata(out)$merge.info` entry collects
diagnostics for each individual merging step. Here, the `batch.size` and
`lost.var` entries are important. The `batch.size` entry reports the relative
magnitude of the batch effect and the `lost.var` entry represents the percentage
of lost variance per merging step. A large `batch.size` and low `lost.var`
indicate sufficient batch correction.
```{r batch-correction-fastMNN-QC, message=FALSE}
merge_info <- metadata(out)$merge.info
merge_info[,c("left", "right", "batch.size")]
merge_info$lost.var
```
We observe that Patient4 and Patient2 are most similar with a low batch effect.
Merging cells of Patient3 into the combined batch of Patient1,
Patient2 and Patient4 resulted in the highest percentage of lost variance and
the detection of the largest batch effect. In the next paragraph we can
visualize the correction results.
### Visualization
The simplest option to check if the sample effects were corrected is by using
non-linear dimensionality reduction techniques and observe mixing of cells across
samples. We will recompute the UMAP embedding using the corrected
low-dimensional coordinates for each cell.
```{r dimred-batch-correction-fastMNN, message=FALSE, warning=FALSE}
library(scater)
set.seed(220228)
spe <- runUMAP(spe, dimred= "fastMNN", name = "UMAP_mnnCorrected")
```
Next, we visualize the corrected UMAP while overlaying patient IDs.
```{r visualizing-batch-correction-fastMNN-1, message=FALSE, warning=FALSE, fig.height=3}
library(cowplot)
library(dittoSeq)
library(viridis)
# 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 before correction")
p2 <- dittoDimPlot(spe, var = "patient_id",
reduction.use = "UMAP_mnnCorrected", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$patient_id) +
ggtitle("Patient ID on UMAP after correction")
plot_grid(p1, p2)
```
We observe an imperfect merging of Patient3 into all other samples. This
was already seen when displaying the merging information above.
We now also visualize the expression of selected markers across all cells
before and after batch correction.
```{r visualizing-batch-correction-fastMNN-2, warning=FALSE, message=FALSE, fig.height=8}
markers <- c("Ecad", "CD45RO", "CD20", "CD3", "FOXP3", "CD206", "MPO", "SMA", "Ki67")
# Before correction
plot_list <- multi_dittoDimPlot(spe, var = markers, reduction.use = "UMAP",
assay = "exprs", size = 0.2, list.out = TRUE)
plot_list <- lapply(plot_list, function(x) x + scale_color_viridis())
plot_grid(plotlist = plot_list)
# After correction
plot_list <- multi_dittoDimPlot(spe, var = markers, reduction.use = "UMAP_mnnCorrected",
assay = "exprs", size = 0.2, list.out = TRUE)
plot_list <- lapply(plot_list, function(x) x + scale_color_viridis())
plot_grid(plotlist = plot_list)
```
We observe that immune cells across patients are merged after batch correction
using `fastMNN`. However, the tumor cells of different patients still cluster
separately.
## harmony correction
The `harmony` algorithm performs batch correction by iteratively clustering and
correcting the positions of cells in PCA space [@Korsunsky2019]. We will first
perform PCA on the asinh-transformed counts and then call the `RunHarmony`
function to perform data integration.
Paper: [Fast, sensitive and accurate integration of single-cell data with Harmony](https://www.nature.com/articles/s41592-019-0619-0)
Documentation: [harmony](https://portals.broadinstitute.org/harmony/index.html)
Similar to the `fastMNN` function, `harmony` returns the corrected
low-dimensional coordinates for each cell. These can be transfered to the
`reducedDim` slot of the original `SpatialExperiment` object.
```{r, echo=FALSE}
start_time <- Sys.time()
```
```{r batch-correction-harmony, message=FALSE, warning=FALSE}
library(harmony)
library(BiocSingular)
spe <- runPCA(spe,
subset_row = rowData(spe)$use_channel,
exprs_values = "exprs",
ncomponents = 30,
BSPARAM = ExactParam())
set.seed(230616)
out <- RunHarmony(spe, group.by.vars = "patient_id")
# Check that order of cells is the same
stopifnot(all.equal(colnames(spe), colnames(out)))
reducedDim(spe, "harmony") <- reducedDim(out, "HARMONY")
```
```{r, echo=FALSE}
end_time <- Sys.time()
```
The computational time of the `HarmonyMatrix` function call is
`r round(as.numeric(difftime(end_time, start_time, units = "mins")), digits = 2)` minutes.
### Visualization
We will now again visualize the cells in low dimensions after UMAP embedding.
```{r dimred-batch-correction-harmony, message=FALSE}
set.seed(220228)
spe <- runUMAP(spe, dimred = "harmony", name = "UMAP_harmony")
```
```{r visualizing-batch-correction-harmony-1, message=FALSE, warning=FALSE, fig.height=3}
# 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 before correction")
p2 <- dittoDimPlot(spe, var = "patient_id",
reduction.use = "UMAP_harmony", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$patient_id) +
ggtitle("Patient ID on UMAP after correction")
plot_grid(p1, p2)
```
And we visualize selected marker expression as defined above.
```{r visualizing-batch-correction-harmony-2, warning=FALSE, message=FALSE, fig.height=8}
# Before correction
plot_list <- multi_dittoDimPlot(spe, var = markers, reduction.use = "UMAP",
assay = "exprs", size = 0.2, list.out = TRUE)
plot_list <- lapply(plot_list, function(x) x + scale_color_viridis())
plot_grid(plotlist = plot_list)
# After correction
plot_list <- multi_dittoDimPlot(spe, var = markers, reduction.use = "UMAP_harmony",
assay = "exprs", size = 0.2, list.out = TRUE)
plot_list <- lapply(plot_list, function(x) x + scale_color_viridis())
plot_grid(plotlist = plot_list)
```
We observe a more aggressive merging of cells from different patients compared
to the results after `fastMNN` correction. Importantly, immune cell and epithelial
markers are expressed in distinct regions of the UMAP.
## Seurat correction
The `Seurat` package provides a number of functionalities to analyze single-cell
data. As such it also allows the integration of cells across different samples.
Conceptually, `Seurat` performs batch correction similarly to `fastMNN` by
finding mutual nearest neighbors (MNN) in low dimensional space before
correcting the expression values of cells [@Stuart2019].
Paper: [Comprehensive Integration of Single-Cell Data](https://www.cell.com/cell/fulltext/S0092-8674(19)30559-8)
Documentation: [Seurat](https://satijalab.org/seurat/index.html)
To use `Seurat`, we will first create a `Seurat` object from the `SpatialExperiment`
object and add relevant metadata. The object also needs to be split by patient
prior to integration.
```{r prepare-seurat, message=FALSE, warning=FALSE}
library(Seurat)
library(SeuratObject)
seurat_obj <- as.Seurat(spe, counts = "counts", data = "exprs")
seurat_obj <- AddMetaData(seurat_obj, as.data.frame(colData(spe)))
seurat.list <- SplitObject(seurat_obj, split.by = "patient_id")
```
To avoid long run times, we will use an approach that relies on reciprocal PCA
instead of canonical correlation analysis for dimensionality reduction and
initial alignment. For an extended tutorial on how to use `Seurat` for data
integration, please refer to their
[vignette](https://satijalab.org/seurat/articles/integration_rpca.html).
We will first define the features used for integration and perform PCA on cells
of each patient individually. The `FindIntegrationAnchors` function detects MNNs between
cells of different patients and the `IntegrateData` function corrects the
expression values of cells. We slightly increase the number of neighbors to be
considered for MNN detection (the `k.anchor` parameter). This increases the integration
strength.
```{r, echo=FALSE}
start_time <- Sys.time()
```
```{r seurat-correction, message=FALSE, warning=FALSE}
features <- rownames(spe)[rowData(spe)$use_channel]
seurat.list <- lapply(X = seurat.list, FUN = function(x) {
x <- ScaleData(x, features = features, verbose = FALSE)
x <- RunPCA(x, features = features, verbose = FALSE, approx = FALSE)
return(x)
})
anchors <- FindIntegrationAnchors(object.list = seurat.list,
anchor.features = features,
reduction = "rpca",
k.anchor = 20)
combined <- IntegrateData(anchorset = anchors)
```
```{r, echo=FALSE}
end_time <- Sys.time()
```
We now select the `integrated` assay and perform PCA dimensionality reduction.
The cell coordinates in PCA reduced space can then be transferred to the
original `SpatialExperiment` object. **Of note:** by splitting the object into
individual batch-specific objects, the ordering of cells in the integrated
object might not match the ordering of cells in the input object. In this case,
columns will need to be reordered. Here, we test if the ordering of cells in the
integrated `Seurat` object matches the ordering of cells in the main
`SpatialExperiment` object.
```{r message=FALSE, warning=FALSE}
DefaultAssay(combined) <- "integrated"
combined <- ScaleData(combined, verbose = FALSE)
combined <- RunPCA(combined, npcs = 30, verbose = FALSE, approx = FALSE)
# Check that order of cells is the same
stopifnot(all.equal(colnames(spe), colnames(combined)))
reducedDim(spe, "seurat") <- Embeddings(combined, reduction = "pca")
```
The computational time of the `Seurat` function calls is
`r round(as.numeric(difftime(end_time, start_time, units = "mins")), digits = 2)` minutes.
### Visualization
As above, we recompute the UMAP embeddings based on `Seurat` integrated results
and visualize the embedding.
```{r umap-seurat, message=FALSE, warning=FALSE}
set.seed(220228)
spe <- runUMAP(spe, dimred = "seurat", name = "UMAP_seurat")
```
Visualize patient IDs.
```{r visualizing-batch-correction-seurat-1, message=FALSE, warning=FALSE, fig.height=3}
# 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 before correction")
p2 <- dittoDimPlot(spe, var = "patient_id",
reduction.use = "UMAP_seurat", size = 0.2) +
scale_color_manual(values = metadata(spe)$color_vectors$patient_id) +
ggtitle("Patient ID on UMAP after correction")
plot_grid(p1, p2)
```
Visualization of marker expression.
```{r visualizing-batch-correction-seurat-2, warning=FALSE, message=FALSE, fig.height=8}
# Before correction
plot_list <- multi_dittoDimPlot(spe, var = markers, reduction.use = "UMAP",
assay = "exprs", size = 0.2, list.out = TRUE)
plot_list <- lapply(plot_list, function(x) x + scale_color_viridis())
plot_grid(plotlist = plot_list)
# After correction
plot_list <- multi_dittoDimPlot(spe, var = markers, reduction.use = "UMAP_seurat",
assay = "exprs", size = 0.2, list.out = TRUE)
plot_list <- lapply(plot_list, function(x) x + scale_color_viridis())
plot_grid(plotlist = plot_list)
```
Similar to the methods presented above, `Seurat` integrates immune cells correctly.
When visualizing the patient IDs, slight patient-to-patient differences within tumor
cells can be detected.
Choosing the correct integration approach is challenging without having ground truth
cell labels available. It is recommended to compare different techniques and different
parameter settings. Please refer to the documentation of the individual tools
to become familiar with the possible parameter choices. Furthermore, in the following
section, we will discuss clustering and classification approaches in light of
expression differences between samples.
In general, it appears that MNN-based approaches are less conservative in terms
of merging compared to `harmony`. On the other hand, `harmony` could well merge
cells in a way that regresses out biological signals.
## Save objects
The modified `SpatialExperiment` object is saved for further downstream analysis.
```{r save-objects-batch-correction}
saveRDS(spe, "data/spe.rds")
```
```{r testing-1, include=FALSE}
library(testthat)
test_that("fastMNN is reproducible", {
# For some reason the fastMNN results are different between local and CI
skip_on_ci()
expect_equal(reducedDim(spe, "fastMNN")[100:130,],
structure(c(0.0555066864233039, -0.376685579206132, -0.252739525524294,
-0.494775249273822, -0.356174222705102, 0.0943526799704248, -0.258244125426127,
0.17733053556045, -0.193591777441387, -0.344142131941669, -0.278188983413437,
-0.219325589487363, -0.311352297948212, -0.307134751140399, -0.319592525280579,
0.0727360528269941, -0.115121987746013, 0.131544710131599, -0.191972597823719,
0.207466113820364, -0.448757984064417, -0.142093142041906, 0.0397820688856466,
-0.00946103924086451, -0.335140380527218, -0.137059173990884,
-0.209314533911835, 0.0833283457360696, 0.269113975452294, 0.25934754389491,
-0.0494071609458672, -0.0327775799291401, -0.00714236858566566,
-0.0588414685784061, -0.118665902512575, -0.119851878685113,
-0.0863547811818214, -0.0436730080653819, 0.119310255213287,
0.0344314754388543, 0.00295489342559455, -0.0621008160301834,
-0.0213738009363044, -0.187183083078127, -0.00846018088839628,
-0.0862602215620686, 0.156584959494637, 0.0108457386725162, -0.0102979194336111,
0.0110015129443188, 0.107582520847604, -0.115195268992971, -0.0308356052430772,
0.169365180946331, 0.126988452933187, -0.0846796197562863, 0.109445225536363,
-0.0476200624368486, 0.129103076065945, -0.0113683795780981,
-0.0434178070823923, 0.135561871641459, 0.0693506631634604, 0.0327450891797031,
-0.0803698636945959, -0.0623667475566475, -0.0395667803556818,
0.0499985045005842, 0.000466990752991746, -0.10325989444694,
-0.0679063543439679, 0.0278518013124757, -0.139952956097058,
-0.0165502865812351, 0.0215319720561742, -0.0304932570053294,
-0.119499888589694, 0.0370986377014467, 0.0352542179694793, -0.00334412016834903,
-0.109454826560381, -0.111674491002359, -0.112748089189858, -0.102601365181284,
0.030200504715045, -0.124642616468368, -0.0822137360818573, -0.00742478169132346,
0.00413257966238621, 0.0870787166940596, 0.0441880191431011,
-0.0145475686944586, -0.0114743348719288, -0.156597106252763,
-0.236094684929595, -0.0624306467014826, -0.352229284049912,
-0.221021392736712, -0.139925622826313, -0.176471539208473, -0.0881778441632775,
-0.165534657384002, -0.264827893851503, -0.069829989557507, -0.219548102979185,
-0.261724712913361, -0.245748599685159, -0.090180863404838, -0.236597633611585,
-0.145783611167993, 0.00265297083727064, -0.145254486227536,
-0.0377288399022407, -0.279687936807314, -0.0571158940434893,
-0.188187501821002, -0.0778106255994327, -0.155628012177308,
-0.210823526048042, -0.203523838054162, -0.275752688020206, -0.0195502386275699,
-0.0317864714878119, -0.174219752385599, 0.0668470146477796,
0.232160629584983, 0.0239720559219634, 0.0447975063351009, 0.0753358624426755,
0.105904863902053, 0.147474038336105, 0.119224101386351, 0.110874147520982,
0.142206264168915, -0.110009041331691, 0.098331811616523, 0.0924303415617775,
0.136546265646412, 0.0776925782009161, 0.0842884051539965, 0.156391421177066,
-0.028809336380959, 0.180219792096698, -0.0408043560411371, -0.0119228049862121,
0.0579981368021695, 0.18708123612231, 0.0152919413151482, 0.166885828550716,
0.14135565336378, 0.105349500485991, 0.129761199280287, -0.0340636361734652,
-0.00620239392069414, 0.126074953403176, -0.154985253485035,
0.0369843363332208, -0.114487228493789, 0.0489713934695946, -0.00352662161841868,
-0.109461597800026, 0.00456622782078878, -0.0552997075380645,
-0.0346161459717188, 0.0281913410460953, -0.122208157594647,
0.0115774126039165, -0.0681433642016216, 0.0212631600460597,
-0.0705445540842436, -0.00165198561308853, -0.0607366339393942,
-0.0432681782467414, 0.0362397316916961, 0.17250333711553, 0.0227780056950953,
-0.041748174782414, -0.00928477714425987, -0.0685187496449622,
-0.0252058105452144, 0.000989503381727364, 0.00193612240802238,
-0.00770784814221957, 0.0843554729248641, 0.0924659277067343,
-0.0331345581372456, -0.0228585731785537, 0.0416594888064206,
0.113887686134824, 0.0268392129406701, 0.0187294686865044, -0.0808791113636265,
0.029924433391266, -0.0664903993758273, 0.0277622651615942, 0.0529582396028129,
0.157227427809114, 0.0116268003696106, -0.0151851108939854, 0.0263652525164572,
0.0839239610023156, 0.00116649528582076, 0.0388720309416176,
0.0321009652624147, 0.0172384525131936, -0.0243456561698053,
0.0395818089239406, 0.0734473915773696, -0.00606533880850707,
0.0599786811546165, 0.0416836545077962, 0.00116627989319901,
0.0265780184739187, -0.0601217772050757, -0.0436982570882287,
-0.0539966754786461, 0.0189362911432362, 0.0834014980758258,
-0.0478390804031047, -0.0220731713252107, 0.0464572450012621,
-9.70189661060388e-05, 0.0877946346002273, -0.00786677438725711,
0.00156736249623454, -0.0277291631977686, -0.000518765713634728,
0.0197400894502952, 0.0479480594058104, -0.0753295359198694,
-0.0103612049012742, -0.053420898519672, 0.00858059248724463,
-0.0358827766818376, 0.0331559924775603, 0.0353573280281203,
-0.0967507889134137, 0.0452225926391208, -0.0582218830798213,
-0.0222010871467585, -0.0190691183540168, -0.05269953636172,
0.00315511521691603, 0.0190605445647289, 0.0718953652934959,
-0.0174418513000815, -0.00284063087017903, -0.0203417384931704,
0.0998451684266203, 0.000302508984282676, 0.0274717671858806,
0.0226382029278991, 0.0371074658381416, 0.0354593417703745, 0.0035700600080338,
0.0386871684122045, -0.00707047550652074, -0.0145288890636233,
9.27973900927344e-05, -0.0343776862374934, -0.00872364092702,
-0.00335050562466944, 0.0794627019788202, -0.00514437597898057,
0.0138561017776895, 0.00197110823815825, -0.0736689210499862,
0.075789715933634, 0.0217091303284696, -0.0174304835434333, 0.037152854230202,
0.038933800098954, 0.0423080051318538, -0.0300768817174647, -0.0414648922528551,
0.0160791054359561, 0.024408244084763, 0.131572066530685, 0.0398751677647523,
-0.0186253777191856, -0.0207748642504336, -0.0460874943539027,
0.0321498110324406, 0.000837575827876203, -0.0606720164887489,
-0.0319899145382063, 0.0108320613732245, -0.0290381113070728,
-0.0555758111761564, -0.045150308774936, -0.0209707741182465,
0.0203450104309502, -0.0107904583068994, 0.00848271783271791,
0.0308434381024673, -0.0459375846997313, -0.00966929917608214,
-0.0635695434110534, -0.0297989478568491, 0.0144335328679027,
-0.00567969479114323, 0.0304347098084035, -0.00595739949349746,
0.0158117351389313, -0.0552673078613463, -0.011287385513057,
-0.0034652288663771, -0.0365445610679661, -0.0318776558288904,
-0.0136878168508349, -0.0596396634875313, -0.0423798373545359,
-0.0998519170885334, 0.0512762616348029, -0.0454852042685576,
-0.032634153766637, -0.066683574642794, -0.0309792414791641,
-0.042433894320734, -0.0278651182223758, -0.0825793600777593,
-0.0485401761343436, -0.0178582279971468, -0.019524668748276,
-0.0616202929184901, 0.0521813154221659, -0.0329639305710472,
-0.136356343890165, -0.0587557746017979, -0.0136696443931024,
-0.0243013681780633, -0.0705748479131594, -0.000818697718328034,
-0.0491750312959409, -0.0307726386747934, -0.0284943832909215,
-0.0176256204231322, 0.0395038755282281, -0.0469124374530145,
-0.0472231808236446, -0.0304706744806545, -0.0804519559508679,
-0.0346403916721905, -0.00190002808192705, -0.0424993503581421,
0.0265912162968909, -0.0939154954313602, 0.0277151021241177,
-0.146277512223971, 0.082362093759294, -0.0514311230787558, 0.00554837427513713,
-0.00251849074097219, 0.00949452160226631, 0.0184608915589337,
0.0456605761095473, -0.0641158864392105, 0.00590201370974871,
-0.0212527703506549, -0.0732886420297585, -0.00246580198923328,
-0.016968680237046, 0.046198461603803, -0.0836317574481866, 0.0475429549961598,
0.01217095574193, -0.0224602738618357, -0.0137949543796623, -0.0608249822373647,
-0.0565999199018669, -0.0538059199813178, 0.0346608524569786,
-0.0132035924558634, -0.0113499300101072, 0.0100509290335407,
-0.0026570132594592, 0.0191865211762315, 0.00387116190467113,
0.0235566471328988, 0.0263360628861923, -0.00154836593438445,
-0.0396865544299505, 0.000546754335276384, 0.0409795906206373,
-0.0264713610065198, -0.0152075749797449, 0.0400279349784027,
0.0285525913513718, 0.0347148105458833, 0.0844982173363206, -0.00677834883010675,
-0.00787710648688014, 0.0162958391677002, 0.0166599147032981,
-0.00825080531507753, 0.0632367464287489, 0.0437847366717417,
0.0237535317435505, 0.0115170659221002, -0.000145025938433308,
0.0678882250127276, -0.0550509065037379, 0.0341561893864924,
0.0412617152245407, 0.0503552079963614, 0.0184258429951948, 0.0261554435127881,
0.0775250852000742, 0.0274241281816282, 0.0569326872107649, 0.00206711810081885,
0.0293071611961038, 0.0358983916376745, -0.0223471658896151,
0.0171634137667772, 0.0473127542602661, 0.0592976385051183, -0.00858430497402607,
0.0331028664688532, -0.0148438015833746, 0.0731466458995994,
0.0025290372426191, 0.138245240687189, 0.0471908993832605, 0.0360005533749097,
0.0315702736703723, -0.0023951303367115, 0.0290441748979701,
0.0339350946259503, 0.0383842341234913, 0.041959209543747, 0.129681884024485,
0.131915649703635, -0.0275565761770391, -0.0247807687853444,
-0.00936721220362494, -0.0277304366808384, -0.0190383338792366,
-0.0162222213466958, 0.0391693446771318, -0.0215798946870169,
-0.0397807665576878, -0.0368161796503357, -0.00946034326151564,
-0.0455725026973126, 0.0172355074181117, 0.0354532262944698,
-0.0151117123960829, -0.0671361340173793, -0.0490812995536939,
-0.00820492088687049, -0.0215929327701684, 0.0103769496518801,
-0.0956095421858557, -0.0367685751976901, -0.0210812119125544,
-0.0729898775685931, -0.052764079585109, -0.0106405290905433,
-0.0211337813835937, -0.0127472105738778, 0.0303223215707406,
-0.0233493911462659, -0.0588028419663878, -0.024007977185821,
0.0457580371303742, 0.0137316997334742, 0.00405508769899622,
0.0569181709791397, 0.0366997506453044, 0.0648754343506703, 0.0692898379933917,
0.10336936396102, 0.0505515605906313, 0.0242426503401015, 0.0227287200393402,
0.034055915740674, 0.110639248719906, 0.0671429647037647, -8.02594482688457e-05,
0.0121415773427495, 0.0508526404066457, -0.139067586253886, -0.0159170137854751,
0.00975659999997822, 0.0323124137342274, 0.0403050089675505,
-0.00281432472252924, 0.05564525089721, 0.0121344557393101, 0.0450849012426618,
0.0699775768775871, 0.0059773471117456, -0.131732422240258, 0.0634074476275573,
0.0293343297282773, 0.0623634313658121, -0.0460551549646148,
-0.0395877951201933, -0.1010745692815, -0.0681248770917488, 0.00564513505875263,
-0.0235683308694978, 0.00872538207228907, -0.0960003289387772,
-0.057068956768314, -0.0300817627332878, -0.0703960405548294,
-0.0800855954280931, -0.113013159790274, -0.0653059600660074,
0.0289196077974869, -0.0277104351359822, -0.0470109113731935,
-0.0356468505562619, 0.0122128678528725, -0.0921686574690599,
-0.0992785934963499, 0.0149402781957114, -0.0313271210105417,
-0.0767194246135443, -0.0340156935945212, -0.0395319536551978,
-0.0278851222322525, -0.0510652729428072, 0.0307875794910013,
0.00990067294108665, -0.0436334255925458, -0.00212328384685945,
-0.00957276291566211, -0.0141952622884622, -0.0334094926942309,
-0.00524598353537757, -0.0110970169603058, 0.00156198126945087,
-0.0249327216141164, 0.0499789029683995, -0.0312192974960022,
-0.000931683378218325, 0.00241434971476509, 0.00182024525638855,
0.00423840851608946, 0.027068012626968, 0.0264149134210959, -0.0488526163091095,
0.0432888657337982, 0.0229965867509951, -0.0287969633889284,
-0.0451792762874676, -0.00106734361409277, -0.00896311648587119,
0.0216992897688855, -0.00419284713191106, 0.0311732264706278,
0.0173345987661852, 0.0146610023451836, 0.0020878527478817, 0.0171596113572166,
-0.0232407399838341, -0.0967138141634814, -0.0773031694414168,
-0.109604884975019, -0.170807417921418, -0.0136122241864109,
-0.0905913365296551, -0.0180082201811178, -0.134356661585017,
-0.0852939272886329, -0.0717144740177325, -0.0933240088238313,
-0.0984706238901621, -0.109536695650013, -0.0799999691475837,
-0.0419994728027613, -0.03021629979843, -0.118994003147859, -0.0168909657313222,
0.0153460754019851, -0.0752441079497873, -0.109677977740475,
-0.0260245206348199, -0.0464765708330147, -0.0693930404143731,
-0.0348808605279563, -0.0882894300941724, -0.0673309771963403,
-0.138840731143577, 0.0697757266860694, -0.0491397693732511,
0.0504879807979603, 0.00795804655599808, 0.0652405957854477,
0.010303885006092, -0.00346653578384348, 0.076180393050171, 0.00909577741990203,
0.0647652872189794, 0.0179531614648816, -0.00126635143508905,
0.0641732817427119, 0.0446038651269159, 0.0223899943122417, -0.00569907401168052,
0.0224087853921547, 0.0488922613900467, 0.0137651692255512, 0.182689983341938,
-0.00602423199400426, 0.086658496451002, 0.029858554092404, 0.0396285278568809,
0.045168905959083, 0.0189398848158437, -0.0106415658936581, 0.0200070831677964,
-0.00713503341311175, 0.0508952404436825, 0.160035177340572,
0.141368875131917, 0.0369701680266775, 0.0364652904404659, 0.0439321901126694,
0.0350248887275094, 0.0292668442542893, 0.0280183079733657, 0.0518808085449654,
0.0168497241750744, -0.0215310652357583, -0.00933318481807096,
0.0315057576483202, 0.00638453343762929, 0.0136138023338959,
0.0172529156866275, 0.012355107332743, 0.0359391422777961, -0.0108013412881178,
0.0256711840700659, 0.0444620330807008, -0.0518354602112145,
0.0125388850497308, 0.0175441701619556, 0.0040459610051675, 0.0511810693286473,
0.00614065930421417, 0.0462660545496595, 0.034592555781281, 0.0310990681056794,
0.00757090560430376, 0.0635922222083423, 0.0814688911109739,
-0.000678042804397318, 0.0231929005555344, 0.0196147594061883,
-0.00120524484972441, 0.0118000263856703, 0.00377807225880795,
-0.00140878096305648, 0.00602256157023158, -0.0224088883191995,
0.00308333122142237, 0.00434847012161226, 0.0089642116923476,
0.0305900539861522, -0.00714623759194553, 0.00241892243343799,
0.0319900494628574, 0.0189579212339809, 0.0236256758852523, -0.0284091300846886,
0.0372818736607956, 0.0288991424312324, 0.00338220858947109,
-0.0106877017725447, 0.00583121559834676, -0.00710044479017778,
0.019482456882789, 0.0073863117305667, 0.00205755624083278, 0.00952792207696736,
0.0106329026155027, 0.0536021275691259, 0.0318972785229272, 0.0597804119861756,
0.0866487504818878, 0.0881453190816903, 0.0262438059480489, -0.0404219499930261,
0.0812793891566826, 0.0973452489732215, 0.0126405119038025, -0.0436248931189695,
0.0760779183093093, 0.0805082101019516, 0.072971750840727, 0.0121011274621391,
-0.0397402442843993, 0.089566696654187, 0.0243146536069093, 0.0795022489125833,
0.0586201583100734, 0.0757143472425071, 0.0389762237250948, 0.0525276236059135,
-0.00322834577319932, 0.0863040821973156, 0.0190917889252836,
0.104512913449722, 0.0702969695172205, 0.0940031140372858, 0.0496673305348157,
0.0515942786154185, 0.0316596669372608, 0.0715159884111184, -0.0179171119505199,
-0.0144879979127845, 0.0150028550241686, 0.00430446571016739,
-0.0107952907615753, 0.00137784843708864, 0.0050850835593025,
0.000603930077711836, -0.00278936882156145, -0.0150402585964438,
-0.0103223798764542, 0.0148294042110442, -0.014602829343841,
0.0199685646931066, 0.000861755175856388, -0.00421733039554215,
-0.0041654034615184, 0.0222224813791979, -0.0256475905699271,
-0.00958289902387723, 0.00101829484718559, -0.00439374223670644,
-0.0107780186679144, -0.00539651719390708, 0.0226029710082494,
-0.0334531908931231, -0.0231928749526589, -0.0296253575901518,
0.0197802047589982, 0.0188415750990626, -0.0200993456678173,
0.00553167908055056, 0.0654069568987626, 0.0311976277942525,
0.108775695786944, 0.0944919179147916, -0.0123207562103062, 0.0244395623355869,
-0.00516754480871375, 0.103157204942326, 0.0398852164363245,
0.0852372080379811, 0.0138854100756503, 0.0568565406057042, 0.107607532841567,
0.0452580193288554, 0.0219380882087457, 0.0239166885640944, -0.00709737149080841,
0.0207862693463316, 0.0568521746639652, 0.0622889763428052, 0.0674916765895444,
0.00429059306133424, 0.0542682555895744, 0.0295235568531424,
0.00880752811761686, 0.0528861065543999, 0.00530905285488861,
0.00576384199643299, 0.0604913819767532, 0.0632705965486803,
0.0380252671758709, -0.0297514226958261, -0.0135464946621068,
0.0571882884416469, 0.0233341370934609, 0.0307122250503271, 0.00800673046040559,
0.0113950981489067, 0.0120826833246197, 0.00170825581959382,
0.0196854797637371, 0.0298295009795783, -0.00300461290794871,
0.0263792386536297, 0.00597581852293875, -0.0066053838551298,
0.0103615131889087, 0.0288682845457842, -0.00397991969026664,
-0.0466800191985471, 0.0152953808050235, -0.00529381352901398,
-0.0247734213283368, 0.0198584596391616, 0.0103889025221804,
0.00867702423044339, 0.0149608002755079, -0.0274959243303686,
0.00715461025174414, 0.0116582590687493, 0.0151767945585516,
0.00482116890685557, -0.0164096932078882, -0.00865242773971668,
0.0347816661194286, 0.0222402346456312, 0.0225701018113004, -0.00762099360075864,
-0.0154495257439238, 0.00631924375641697, -0.0278191712088166,
-0.00483264209868916, 0.0197643114788226, 0.0181415805982666,
0.00541559503590814, -0.0250153672805714, 0.012053256154928,
0.02877686447893, -0.0176068799196582, 0.00604278456942368, 0.0287215728210211,
0.0201869544610238, 0.0030524228963458, -0.0147570433403804,
0.0170130259073002, 0.00389423146687373, 0.0046989749705354,
-0.025855272981633, 0.0304025977865429, -0.0121720338409444,
-0.00788645846784791, 0.0193208987262917, -0.0263384254474628,
-0.0426622540361808, -0.00374810691082424, -0.031988381220565,
-0.0282610110597228, -0.00869816176262689, -0.017557632774482,
-0.0314116283923484, -0.0301011818503935, -0.0136718795391639,
-0.039159522526968, -0.0435622579213385, -0.06626469872996, -0.0514759806002895,
-0.0349507174945262, -0.00666096252230823, -0.0236904610482856,
-0.00792326342920758, -0.00688992424122035, -0.00690371891274296,
-0.00880920944584887, -0.0266197270237093, -0.0298924205494648,
-0.00788571418733675, -0.0195634206814721, -0.0330077769604602,
-0.0488228159036305, -0.0266256441205994, 0.00381560689028226,
0.0147811354581081, -0.0266972619258605, -0.0435479747962753,
0.0170076132781089, -0.0128979853273021, 0.026924234724107, -0.0264676523600393,
-0.0192825491213538, -0.0129511765257251, -0.0116335249136955,
-0.0312589548982489, -0.0157257401650388, -0.0152693984682477,
-0.01322228395809, -0.0101571731273043, -0.0204845937209356,
-0.0253256687540577, -0.0330722725904352, -0.0307862810446647,
-0.011952966159031, -0.0214529745616757, 0.00934530184183101,
0.0376017402293333, -0.0299632462501725, -0.0283293685938966,
-0.0321968336272391, -0.0195453561184567, -0.0192506816066278,
-0.0398266019401645, -0.0158716831780909, -0.00143827244407394,
-0.0279726846729399, -0.0408640166564564, 0.0303046696438775,
0.0118464467046819, 0.0449837374872015, 0.0521406846406885, 0.0566744155073524,
0.0223615340302092, -0.0202249497364444, 0.0163033954387992,
0.0182255123774822, 0.0372041790500445, 0.0446597446903211, -0.00421475590762587,
0.0298152416505037, 0.0380107570379857, 0.0259022940645092, 0.0143739108919433,
-0.0123963746368886, 0.022706032920436, 0.0457376189416942, 0.0629810007767599,
0.0370234860278132, 0.0424308239350969, -0.0067255534666703,
0.0295636594566853, 0.00052891665697587, -0.00190178477654566,
0.0189869433020292, 0.0301690611269919, 0.0342826761366065, 0.0444854837891297,
0.00308182736180258, -0.0057396329512834, 0.000652156594485465,
0.0186534217738638, 0.0315234474210467, 0.0122586010655217, -0.0270705211561491,
-0.00275496828161327, -0.0217953708241621, -0.00286530300142868,
0.00846933114060002, 0.00659065810850772, -0.011995131551928,
0.0341253880721118, 0.00680610775319092, 0.0247684951502281,
0.0162771285793825, 0.03881627523236, 0.0308504115874135, 0.011805084402254,
-0.0154789734893282, 0.0314024514008173, -0.00911961239299123,
-0.031135788047387, -0.0106462251243008, 0.00549980787602597,
-0.00130969558764618, -0.0105594204182049, 0.0421209875220253,
0.0243335049509736, 0.0209500045720267, 0.0193000967018484, 0.00607489710830187,
-0.0136398502608397, -0.0249134564273842, -0.0103941509327084,
-0.0147288002389298, 0.00186659684058298, -0.0259559035577247,
0.00766044155972282, -0.018097424558508, -0.00622653335848791,
-0.0583416994857919, -0.0125260140504867, -0.0135885536980681,
-0.011009197438023, -0.0199049310459936, 0.00526314617002634,
-0.0167779685661225, -0.0235411662207863, 0.000897011489441418,
-0.039723967108065, 0.00645419243841864, -0.0312171456562539,
0.0152125654442568, -0.00887861086928223, -0.0183522532959697,
-0.00603159208356828, -0.0242925744376008, -0.00547958964038343,
0.00138377843407418, -0.0270126126747682, -0.000969657596926501,
-0.0379146018919459, -0.00583494186407422, -0.00451626800150919,
-0.0355077574506491, -0.0427566640151123, -0.0016696053021161,
-0.0210121712624585, -0.0198555928644914, 0.00127015410178151,
0.00136761105645319, 0.0214887293615971, -0.00979604368817589,
-0.0298095438542174, -0.0221976927399187, 0.000841222394544494,
0.00863243862603553, -0.0224384077882825, 0.00564312942662724,
-0.00126688768920207, -0.0803064091863531, -0.0326992547930266,
0.0161086554974438, 0.00359577711400688, -0.00812442237952728,
-0.0119846012390529, -0.00777392718715822, -0.0195153427002153,
-0.0203825945874387, -0.0370667305618394, -0.0531229738209593,
-0.00591162017419609, 0.0064076004171142, 0.00406220037479069,
0.00207900293759924, 0.0456890861182108, 0.0247471155635124,
-0.0149345304716684, -0.0212243485675998, -0.00587678345075267,
0.0128021899575927, -0.00352970022816278, 0.00231239080378293,
-0.00808325588724252, 0.0194060820308352, 0.0123621412140401,
-0.0108047211160027, -0.0133676511551604, -0.0200230899508758,
0.00465962299421749, 0.00325629262163034, 0.00329368285116967,
0.0299708555071227, -0.000532884001919511, -0.0139637643973461,
-0.0178993910371108, -0.0229920764461106, 0.00379558973424014,
0.00793135416443388, 0.015315557016266, 0.00910418417549223,
0.017537362512473, -0.0107541277922863, -0.000987013247938102,
-0.0311656570534982, 0.0065653001585232, -0.0055885518202638,
-0.0305101154193489, -0.00332134093234569, 0.00215750650816555,
-0.0256666976118249, -0.00480696809861828, -0.0122974488011052,
0.00696620081460667, 0.000464028747424411, -0.00436306599005847,
-0.0167168519304575, 0.00119011399808615, 0.0133665873365825,
-0.0365547394461806, 0.0215823506305918, 0.0328893622529672,
-0.00153269996077489, 0.0151713383049629, -0.00836718183579373,
-0.00426485500989503, -0.00688842482667262, -0.00720767893969143,
0.00217474623370382, 0.0217161778791357, -0.0325823563171023,
-0.00900436383557646, -0.0473908881782194, -0.00893388166135415,
-0.0323314912429898, -0.037288699172816, -0.0247824133076004,
-0.0289304070282566, -0.0562785276829641, 0.00034870401858719,
-0.041520941973138, 0.0216398396038903, -0.0309788694616043,
-0.0288067054212414, -0.0297618014146456, -0.0075433173956559,
-0.0282234024973713, -0.0381189370601301, -0.028888830038195,
-0.0185625677682893, -0.00216221074142321, -0.00697991626614388,
-0.0281204059280488, -0.0151032475899559, -0.029702561250172,
-0.00643331711245015, -0.0137763989303242, -0.0240209798048119,
-0.0179672407353932, -0.0106252564024961, 0.0573828466227139,
-0.0222254706313383, 0.0125462722215207, -0.0133278228456822,
-0.0134537509151647), dim = c(31L, 36L), 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"), NULL)))
expect_equal(head(reducedDim(spe, "UMAP_mnnCorrected"), n = 10),
structure(c(-5.68709674774978, -4.08356181084487, -3.9715031713185,
0.406542685634164, -6.86016717850539, -3.45563093125197, -2.17657152115676,
1.60496243537095, -8.83462444245193, -5.39916101395461, 0.205106232490877,
0.385086599912981, 0.343267116871217, -1.44879555312123, -1.6039677819344,
-3.13234579173054, -0.549943800840041, -4.74440729227986, -1.92871057597127,
-0.815554912957808), 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"))))
expect_equal(reducedDim(spe, "UMAP_mnnCorrected")[100:130,],
structure(c(-0.647811624401541, -6.67081228195998, -6.47172609268996,
-8.377138289803, -4.91355768143508, -0.703490558260413, -5.82361427246902,
2.85219272673753, -5.14411512314651, -6.04714408814284, -7.35421005188796,
-5.50622049271438, -6.60668674408767, -5.00127378403518, -7.23215547501418,
-2.55905309616897, -4.06728807389113, 3.78116592467454, -4.45819106995437,
5.2097438246074, -8.6331197351155, -5.40011421143386, -2.63672533928725,
-1.10023108422134, -6.7623397439656, -4.27042451798293, -5.48645368515822,
-2.60052290856216, 4.11852201522019, 4.16747745574143, -3.51621046959731,
2.23933899792705, 1.261030439463, -1.04409896937337, 0.995997253980974,
-1.31911360827412, 2.49197137745891, 0.43796912225757, -2.26304089632954,
-0.700864668759963, 0.866950873461107, -1.44684004393544, 0.38755995425258,
0.15539345535312, -0.848683055314681, -0.735966916951796, 0.954718236055711,
0.362733010378221, 1.99401295575176, 0.660122696485857, 0.614571754064897,
0.154946778145174, -0.888410921964308, 0.858761612501482, -2.12558543292012,
0.338658664551118, 0.424750153150896, 0.279058922257761, 1.06508684548412,
1.84644365700755, 1.58234751614604, 0.228656251159051), 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"))))
expect_equal(reducedDimNames(spe), c("UMAP", "TSNE", "fastMNN", "UMAP_mnnCorrected", "PCA", "harmony",
"UMAP_harmony", "seurat", "UMAP_seurat"))
expect_equal(dim(reducedDim(spe, "fastMNN")), c(47794L, 36L))
expect_equal(dim(reducedDim(spe, "UMAP_mnnCorrected")), c(47794L, 2L))
expect_equal(dim(reducedDim(spe, "harmony")), c(47794L, 30L))
expect_equal(head(reducedDim(spe, "harmony"), n = 10),
structure(c(-1.15998881988164, -3.39106567604373, -2.82944567391184,
-7.61365725578412, 0.907486960901114, 0.199701464176572, -4.75013036289799,
1.57343039720961, 0.519134010767422, 0.610932910558848, 5.09604108173292,
4.66279855883839, 4.25593873403847, 3.49447145576111, 2.06436843261896,
2.12877662885168, 2.60165871687915, -1.4633796500263, 3.5006413069131,
3.60675730535935, -0.350494147714564, -0.0892559484292092, 0.224113326084467,
0.875498560356647, -0.638007997274435, -0.724371462485355, 0.973270363302904,
0.350629430959436, -0.349998622898803, -0.679625182699179, 0.738362676039422,
-1.45520620619593, 0.207066109475047, 0.572070178639148, 1.90216261414724,
2.04116335730029, 0.474253711349838, 0.852740953880013, 1.83812226606269,
1.40461760687985, 1.11993353038686, -0.340523997772893, -0.221613231624777,
0.510538116502968, 2.30632548037059, 0.569974814494, -0.384757186616772,
1.32387240789402, 3.79152453092805, 1.05247289096672, -0.684821562156861,
-0.446510430741164, -0.18623619503556, 1.06631957061612, 0.327823445364811,
0.431140904363093, 0.791320367417151, -0.503003498596062, -0.390568958657279,
-0.199661527415992, -1.02964421946257, -1.67649462738659, -0.720319114514527,
0.29299877668513, 1.14914055312827, -0.0409535373872491, -0.171207558239531,
-1.52581237878512, 1.22128601801715, -0.337404247370429, -0.108443151839034,
0.0239255637581883, 0.811272498370517, 0.872338711118872, 0.546371087157391,
0.229347670953821, -0.0384617210937493, -0.757705727347054, 0.0917996090005646,
0.073739535646633, 0.534391726722732, -0.237172104579188, -0.180217471522976,
0.779210989962219, -0.489285302046971, 0.226193813564269, -0.189226181427628,
1.75996958088541, -0.896630528768584, -0.0500022617471234, -0.230815347553389,
-0.824645389892454, -0.348646784600715, -0.467844370311532, 0.0127574166835001,
-0.348690361247778, 0.0317197557100315, -0.704126529772774, -0.704549026794772,
-0.215118029535852, -0.192478092341435, 0.290240523363791, 0.399839784626682,
0.372496427718607, -0.99946287997833, -0.386577963049251, -0.170323247749329,
-1.09220104344745, -0.889865866081382, 0.0267320017252748, 0.596255849938276,
0.537826168743066, 0.126402948164382, 0.441233342988999, 0.417504192946301,
-0.354305439323142, 0.650897166641301, 0.688878126714712, 0.916842631842611,
0.414474065079925, -0.187240014294795, 0.453277809124187, 0.017339109166262,
-0.574083052193849, -0.0641472395423206, -0.552683264876961,
0.238955975993975, -0.159793111750467, -0.00935520895121081,
-0.176259060035581, 0.306278877973865, -0.213778106651265, -0.138725752710841,
0.0413212216476015, -0.0751096037594299, 1.02019861868901, 0.910026227031111,
-0.166219685065859, 0.0685879845685476, 0.36001478017533, -0.0198947980052817,
0.949350115554519, 0.329064885093393, -0.321443177934493, 0.997830423820286,
0.113991004416195, 0.0314897317723534, 0.580408632944185, -0.181354263492702,
0.0392441531877127, -0.0666291236169449, 0.650433992898884, 0.0131769473545568,
-0.0315552094071054, 0.477878240760466, 0.405815298147881, 0.596579099513433,
0.00389619991861491, -0.0795316479787468, 0.126213082681566,
-0.354549992373095, -0.244719392011663, -0.34781440615248, -0.42721035085738,
0.472863409677476, 0.127276397108356, 0.262238542247804, 0.173068800565048,
0.315281500832077, -0.626821721126135, 0.161288149929905, 0.579930589980492,
0.487756891510136, 0.189440403434554, -0.519210251914134, -0.804526346069707,
-0.0441523031209502, -0.0400207643735324, 0.0559399145511079,
0.285636928737658, -0.28501612119568, -1.12443450991784, -0.20652791366478,
0.28893977351747, 0.21561780332319, 0.0485287521148911, 0.338745101728697,
-0.502953584789587, 0.37624849532904, -0.128839495276231, 0.231795326211438,
0.890879994491173, 0.557362755310435, 0.388998291002224, 0.688095979935856,
0.269426435158068, -0.379104293404382, 0.289977759217442, 0.546738060650981,
0.967588348912491, 0.298303865424916, 0.984115919713235, 0.56658956272241,
0.00885278483482189, 0.112236192715632, 0.0753449576011975, 0.0736158971847437,
0.0984324700078995, 0.226640608000927, 0.769833988036894, -0.0896802520490992,
0.701302790625752, 0.785732022712254, 0.280959910509831, -0.433784421473301,
-0.488313551972938, -0.180657975073151, 0.701462300738578, -0.183996559092517,
0.59688472604838, 0.0165942929771203, -0.971528449390337, -1.01265478253511,
0.0352059505210221, -0.0433216183184302, 0.617390982961843, 0.309711390021321,
0.746887102703767, 0.178439585557561, -1.41596303360321, -0.20670332192193,
0.315350184883516, -0.218437763642656, 0.584993669988687, 0.293689575652249,
0.572927211947246, 0.361860162465272, 0.831143351352982, -0.216686897711864,
-0.50833742156595, -0.46974233666884, 0.348848104597183, 0.366656062322983,
0.246815658378999, 0.481179059128202, -0.136143948402302, 0.545035081462414,
0.0279715334045918, 0.897541769876753, 0.179419861822079, 0.244425193581558,
-0.853256388703351, -0.494313480680024, 0.00101689723669014,
0.40296742566629, -0.0333826854293577, -0.918067502564957, 0.327854957042677,
-0.090043094911341, -0.452469300634422, 0.18670690158671, 0.0522992199568274,
0.237271449581991, 0.163517461795561, -0.172237328439345, -0.0419123913041026,
-0.0964040867491361, -0.614255710568056, 0.542004646900877, 0.0561621725090094,
0.049274740218738, -0.56867562397012, -0.422826551633928, 0.148759326615731,
0.157345416015629, -0.283734353599969, -0.169980473923803, -0.19905017537625,
-0.302598656227517, -0.55777010745564, 0.133448212413735, 0.374346882127388,
-0.524724989099842, 0.297338678141653, 0.0274298835802952, -0.00634532373090483,
0.0207920815894537, 0.264292734133356, -0.372225222573357, -0.0195749301634168,
-0.159991919625601, 0.322742703618409, -0.339737115303537, 0.159606184388184,
0.477378973014343, 0.181561005981218, 0.0833770686309567, -0.281342888341853,
-0.303302011319233, -0.249694149391713), dim = c(10L, 30L), 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("HARMONY_1", "HARMONY_2",
"HARMONY_3", "HARMONY_4", "HARMONY_5", "HARMONY_6", "HARMONY_7",
"HARMONY_8", "HARMONY_9", "HARMONY_10", "HARMONY_11", "HARMONY_12",
"HARMONY_13", "HARMONY_14", "HARMONY_15", "HARMONY_16", "HARMONY_17",
"HARMONY_18", "HARMONY_19", "HARMONY_20", "HARMONY_21", "HARMONY_22",
"HARMONY_23", "HARMONY_24", "HARMONY_25", "HARMONY_26", "HARMONY_27",
"HARMONY_28", "HARMONY_29", "HARMONY_30"))))
expect_equal(dim(reducedDim(spe, "UMAP_harmony")), c(47794L, 2L))
expect_equal(head(reducedDim(spe, "UMAP_harmony"), n = 10),
structure(c(-6.74963569098971, 0.983713453469065, 0.96953988617399,
1.08088249510267, -6.80463933402559, -6.657812589946, 1.17699134891966,
2.28156567162016, -6.88329171592257, -6.96932506019137, 1.54207256190253,
2.71187427393867, 2.70013597361518, 2.11441674582435, -0.0655559624009031,
0.085542333645354, 2.0906204258628, -4.69663712628411, -0.0140544498734372,
0.9547401940055), 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"))))
expect_equal(reducedDim(spe, "UMAP_harmony")[100:130,],
structure(c(1.43729830330351, -9.3616437857773, -7.39797830039522,
-9.12673472816012, -5.12571334296725, 1.92089450901487, -7.44227170402071,
1.94314075058439, -6.9989409392502, -7.719739908519, -7.22660731727144,
-7.69212674552462, -7.84372758323214, -7.85073708945772, -8.11271762305758,
0.765295093712595, -6.25862407142183, 3.61820030754545, -6.28211926871798,
3.30280852859953, -7.81758975440523, -6.30248927527926, 0.152186976579216,
-0.621444756331655, -8.4613981192734, 0.34129740839937, -6.81769275123141,
0.906501477417734, 3.98505139893034, 3.67537785118559, 0.315176119861391,
2.83209016673041, 0.853131619615088, -1.43655500062035, 1.60533860079719,
1.93563094489051, 2.64531281344367, 1.21191462628318, -2.44633767254876,
0.833791998548041, 1.47491624705268, -0.911437126474847, 0.9112831627555,
1.78390863291694, 1.20822265498115, -1.71485278256463, 2.43169811121894,
-0.357134136038293, 0.0896467094845874, -0.213918777780999, -1.57245347149896,
-0.0246971870236295, -0.3797564233117, 2.82522895686103, 0.709802416486274,
-1.40615865834283, 3.04348566882087, 1.5889992987342, 2.66575219981147,
0.748059031886588, -0.0796031380467313, 2.7937112127967), 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"))))
expect_equal(dim(reducedDim(spe, "seurat")), c(47794L, 30L))
expect_equal(head(reducedDim(spe, "seurat"), n = 10),
structure(c(-0.163926554406479, -1.81563789755359, -0.988949531108586,
-10.1460080938759, 2.0744394087411, 0.452486241470208, -7.42708681132397,
3.40177301103099, 0.996501039028137, 0.830308208755332, -5.77110257575236,
-6.37230090932417, -6.12122173204844, -2.0794532518042, -3.46316239487451,
-3.35859508178375, -0.814232889563149, 2.72811683077554, -5.27321289202087,
-6.47891919814399, 2.85778645240078, 3.34099752768287, 3.30968552449228,
4.84057736429225, 0.91375581149314, 1.93674503021308, 2.75452540366229,
-0.412217503058739, 2.40074426037249, 2.12487768481838, 0.169908054718571,
-1.29746571830621, -0.0769420322007152, -0.636820437956978, -0.459173491585829,
-0.493076739796234, -1.96430879579538, 1.11937296817048, -0.700322195066293,
-0.0447564875060655, 0.87927224885952, -0.389600549647395, -1.25236848978314,
1.11145552550372, -0.0327011002787631, -0.291842035881262, 0.553626257442666,
2.44334520063705, 0.0735301371315649, -0.299259414066224, 0.394030442601913,
1.24086146886924, 0.678388796015737, 0.767713783755665, -0.201055706524871,
0.680594428868993, 1.3265237768532, 1.26621424147655, -0.302739219516304,
0.854086155490356, -1.03373588188169, -0.393819230204133, -0.83409920701849,
-2.00606719958371, 0.222446918739281, -0.0659759778762641, 0.125750659392752,
0.355730807767343, -0.43706911359785, 0.138846950482687, 0.946412620223268,
1.78637284512652, 0.538034819689847, 2.52095171327046, 0.951284474210047,
1.76999103241674, 0.610180344044832, 2.91050518215761, 0.282753546273144,
0.922075654726458, 1.79125782483262, 2.46955544052264, 1.32383017606673,
1.30050289042559, -0.225040083108116, 0.064917841998442, 1.74500465576633,
2.17000328053213, 1.20554034934777, 1.4986693712843, 1.82717482162008,
-0.13902302824896, -0.299521728968593, -0.790674733633185, 0.557356413259838,
-1.27719816953672, 0.260834619430395, 0.0957310961988009, 0.178175581234436,
-0.845167280237736, 1.50205336679497, -0.714563165145695, -0.911633930363501,
-0.0740586912788037, -1.01236650418616, -1.26568638845836, -1.27852106634399,
-1.49885230581594, -0.687987418767694, -1.00885589679555, -2.57624362853904,
-0.480602925193408, 0.0529931666060835, -1.15209548082075, -1.20663383677923,
-0.118754281770999, -1.47871646125381, 0.190206724655892, -1.30423142143044,
0.0105301717005198, 0.763293796877189, 0.859748593275575, 1.08968725480088,
1.3833676542152, -1.43133214664098, -0.548644058020895, 0.445356435858369,
-0.0767235144234227, -0.944324635701847, 1.03546454979902, -0.218264697167622,
-1.32350427629302, -0.977586722674951, -0.572430114633532, 0.306507835637722,
-0.0173202411121227, 0.698853655948917, -1.1302670841465, 0.264922662043011,
-1.12819562794055, -0.836899275938098, -1.32160395065521, -1.20060036010272,
-0.0492862724465446, -1.30268234023804, 0.366960614845117, 0.500864651723894,
0.388626565216079, -1.00369833793543, -1.47400935873384, 1.35260036428822,
-0.966389852229108, -0.292880245024842, -0.21924118703702, 0.308888896863478,
0.0337859353645099, -0.623201131229032, -1.71183548424112, 0.823909024876327,
0.519619886500736, 0.546277111010219, 0.277000736371077, 1.10308750833323,
0.678428541512693, -0.495944708851795, 0.750683939225104, -0.324923125843223,
-1.00060035682153, 0.0138604775085465, 1.75525178512039, -0.461311246996555,