@@ -500,30 +500,43 @@ GetResidual <- function(
500
500
# ' }
501
501
# '
502
502
Load10X_Spatial <- function (
503
- data.dir ,
504
- filename = ' filtered_feature_bc_matrix.h5' ,
505
- assay = ' Spatial' ,
506
- slice = ' slice1' ,
507
- filter.matrix = TRUE ,
508
- to.upper = FALSE ,
509
- image = NULL ,
510
- ...
503
+ data.dir ,
504
+ filename = ' filtered_feature_bc_matrix.h5' ,
505
+ assay = ' Spatial' ,
506
+ slice = ' slice1' ,
507
+ filter.matrix = TRUE ,
508
+ to.upper = FALSE ,
509
+ image = NULL ,
510
+ ...
511
511
) {
512
512
if (length(x = data.dir ) > 1 ) {
513
- warning(" 'Load10X_Spatial' accepts only one 'data.dir'" , immediate. = TRUE )
513
+ warning(" 'Load10X_Spatial' accepts only one 'data.dir'" ,
514
+ immediate. = TRUE )
514
515
data.dir <- data.dir [1 ]
515
516
}
516
- data <- Read10X_h5(filename = file.path(data.dir , filename ), ... )
517
+ data <- Read10X_h5(filename = file.path(data.dir , filename ),
518
+ ... )
517
519
if (to.upper ) {
518
- rownames(x = data ) <- toupper(x = rownames(x = data ))
520
+ data <- imap(data , ~ {
521
+ rownames(.x ) <- toupper(rownames(.x ))
522
+ .x
523
+ })
524
+ }
525
+ if (is.list(data ) & " Antibody Capture" %in% names(data )) {
526
+ matrix_gex <- data $ `Gene Expression`
527
+ matrix_protein <- data $ `Antibody Capture`
528
+ object <- CreateSeuratObject(counts = matrix_gex , assay = assay )
529
+ object_protein <- CreateAssayObject(counts = matrix_protein )
530
+ object [[" Protein" ]] <- object_protein
531
+ }
532
+ else {
533
+ object <- CreateSeuratObject(counts = data , assay = assay )
519
534
}
520
- object <- CreateSeuratObject(counts = data , assay = assay )
521
535
if (is.null(x = image )) {
522
- image <- Read10X_Image(
523
- image.dir = file.path(data.dir , ' spatial' ),
524
- filter.matrix = filter.matrix
525
- )
526
- } else {
536
+ image <- Read10X_Image(image.dir = file.path(data.dir ," spatial" ),
537
+ filter.matrix = filter.matrix )
538
+ }
539
+ else {
527
540
if (! inherits(x = image , what = " VisiumV1" ))
528
541
stop(" Image must be an object of class 'VisiumV1'." )
529
542
}
0 commit comments