SEURAT : loading via h5 file and applying min.cells and min.features
1
0
Entering edit mode
9 weeks ago
ZheFrench ▴ 500

Usually from publicly available 10X spatial/scRnaseq, you end up with 4 files barcodes/counts/features/tissuesMap(for spatial only).

In my workflow, I generally use CreateSeuratObject and apply min.cells and min.features thresholds.

Sometimes features file is missing, I have only h5 file.
I was wondering (notably for spatial) how to apply min.cells and min.features thresholds. Load10X_Spatial doesn't permit it.

# barcodes
file_barcodes <- file.path(outdir_matrix_dir, glue("filtered_feature_bc_matrix"), "barcodes.tsv.gz")
df_barcodes <- read.csv(file_barcodes, sep = "\t", header = FALSE, 
                        col.names = c("barcode_id"))

# counts
file_counts <- file.path(outdir_matrix_dir, glue("filtered_feature_bc_matrix"), "matrix.mtx.gz")
counts <- readMM(file = file_counts)

# tissue map
file_tisspos <- file.path(image_spatial_dir, glue("spatial/"), "tissue_positions_list.csv")
tisspos <- read.csv(file_tisspos, header = FALSE, 
                       col.names=c("barcode_id", "in_tissue", "array_row", "array_col", 
                                   "pxl_row_in_fullres", "pxl_col_in_fullres"))


#########################################################################################
### Worklow with feature.tsv.gz available missing and filtered_feature_bc_matrix.h5 only
#########################################################################################

 # Load into seurat 
  my_image <- Read10X_Image(
   as.character(dirname(file_tisspos)),
   image.name = "tissue_lowres_image.png",
   filter.matrix = TRUE
 )

 seurat.object <- Load10X_Spatial(
  as.character(dirname(file_barcodes)),
  filename = "filtered_feature_bc_matrix.h5",
  assay = "Spatial",
  slice = "slice1",
  filter.matrix = TRUE,
  to.upper = FALSE,
  image = my_image,
)

##################################################################################
### Worklow with feature.tsv.gz available : apply threshods over cells and features
##################################################################################

#  features
file_features <- file.path(outdir_matrix_dir, glue("filtered_feature_bc_matrix"), "features.tsv.gz")
 df_features <- read.csv(file_features, sep = "\t", header = FALSE, 
                         col.names = c("gene_id", "gene_name", "feature_type"))

 # Load into seurat 
 seurat.object <- CreateSeuratObject(
      counts = Read10X( data.dir = as.character(dirname(file_features)) ,  gene.column = 2),
      assay = 'Spatial', min.cells = 3, min.features = 200
 )

 # Add image
image <- my_image[Cells(x = seurat.object)] 

DefaultAssay(object = image) <- 'Spatial'

seurat.object[['Slice1']] <- image
seurat • 204 views
ADD COMMENT
0
Entering edit mode
9 weeks ago
ZheFrench ▴ 500

Ok Read10X_h5 did the trick.

fileh5 <- glue ("{outdir}/filtered_feature_bc_matrix/filtered_feature_bc_matrix.h5")

seurat.object <- CreateSeuratObject(
          counts = Read10X_h5(filename = fileh5),
          assay = 'Spatial', min.cells = 3, min.features = 200
     )
ADD COMMENT

Login before adding your answer.

Traffic: 1833 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6