Skip to content

Commit eaa786c

Browse files
merge devlop in
1 parent da62e8a commit eaa786c

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

R/preprocessing.R

+30-17
Original file line numberDiff line numberDiff line change
@@ -500,30 +500,43 @@ GetResidual <- function(
500500
#' }
501501
#'
502502
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+
...
511511
) {
512512
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)
514515
data.dir <- data.dir[1]
515516
}
516-
data <- Read10X_h5(filename = file.path(data.dir, filename), ...)
517+
data <- Read10X_h5(filename = file.path(data.dir, filename),
518+
...)
517519
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)
519534
}
520-
object <- CreateSeuratObject(counts = data, assay = assay)
521535
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 {
527540
if (!inherits(x = image, what = "VisiumV1"))
528541
stop("Image must be an object of class 'VisiumV1'.")
529542
}

0 commit comments

Comments
 (0)