@@ -677,9 +677,14 @@ Add_10X_CellTypes <- function(data.dir, object) {
677677 cell_types_path <- file.path(data.dir , " cell_types" , " cell_types.csv" )
678678 if (file.exists(cell_types_path )) {
679679 cell.types <- read.csv(cell_types_path )
680- object @ meta.data <- dplyr :: left_join(tibble :: rownames_to_column(object @ meta.data , " barcode" ),
681- cell.types , by = " barcode" ) %> %
682- tibble :: column_to_rownames(" barcode" )
680+ meta_data_with_barcodes <- tibble :: rownames_to_column(object @ meta.data , " barcode" )
681+ merged_meta_data <- merge(
682+ x = meta_data_with_barcodes ,
683+ y = cell.types ,
684+ by = " barcode" ,
685+ all.x = TRUE
686+ )
687+ object @ meta.data <- tibble :: column_to_rownames(merged_meta_data , " barcode" )
683688 return (object )
684689 } else {
685690 return (object )
@@ -689,9 +694,9 @@ Add_10X_CellTypes <- function(data.dir, object) {
689694# ' Load a 10x Genomics Single Cell Experiment into a \code{Seurat} object
690695# '
691696# ' @inheritParams Read10X
692- # ' @inheritParams SeuratObject::CreateSeuratObject
697+ # ' @inheritParams SeuratObject::CreateSeuratObject If multiome 10x data the
698+ # ' assay param will not be used. The names of each assay contained in the matrix are used.
693699# ' @param data.dir Directory containing the H5 file specified by \code{filename}
694- # ' and the image data in a subdirectory called \code{spatial}
695700# ' @param filename Name of H5 file containing the feature barcode matrix
696701# ' @param to.upper Converts all feature names to upper case. This can provide an
697702# ' approximate conversion of mouse to human gene names which can be useful in an
@@ -719,14 +724,14 @@ Load10X <- function(data.dir, filename = "filtered_feature_bc_matrix.h5",
719724 stop(" `data.dir` expects a single directory path but received multiple values." )
720725 }
721726 if (! file.exists(data.dir )) {
722- stop(paste0( " No such file or directory: '" , data.dir , " '" ) )
727+ stop(" No such file or directory: '" , data.dir , " '" )
723728 }
724729
725730
726731 filename <- list.files(data.dir , filename , full.names = FALSE , recursive = FALSE )
727732 counts.path <- file.path(data.dir , filename )
728733 if (! file.exists(counts.path )) {
729- stop(paste0( " File not found: '" , counts.path , " '" ) )
734+ stop(" File not found: '" , counts.path , " '" )
730735 }
731736
732737 counts <- Read10X_h5(counts.path , ... )
@@ -747,7 +752,7 @@ Load10X <- function(data.dir, filename = "filtered_feature_bc_matrix.h5",
747752 )
748753 })
749754
750- for (i in 1 : seq_along(seurat.list )) {
755+ for (i in seq_along(seurat.list )) {
751756 if (Assays(seurat.list [[i ]]) %in% c(" Gene Expression" , " RNA" )) {
752757 seurat.list [[i ]] <- Add_10X_CellTypes(data.dir , seurat.list [[i ]])
753758 }
0 commit comments