Read spatial data from GSM8557976 using Seurat
2
1
Entering edit mode
19 days ago
tujuchuanli ▴ 140

Hi,

I am trying to load the spatial data from GSM8557976 using Seurat. The dataset includes seven files: "barcodes.tsv.gz", "features.tsv.gz", "matrix.mtx.gz", "scalefactors_json.json.gz", "tissue_hires_image.png.gz", "tissue_lowres_image.png.gz", and "tissue_positions_list.csv.gz".

I`ve attempted several approaches but haven’t been able to read them successfully. Could you please help me import this data using Seurat?

Thanks in advance!

spatial data Seurat • 922 views
ADD COMMENT
0
Entering edit mode

Without knowing exactly what you tried, someone will suggest a solution and you will say that you already tried it. Then someone else will suggest a different solution, and you will again say that you already tried it. Hopefully, it is clear what you are supposed to do before we start guessing.

ADD REPLY
0
Entering edit mode

Hi Mensur Dlakic , Thank you for your reply and suggestions.

After several rounds of attempts, I have finally resolved the issue. Below is the code I used, and I hope it will be helpful to others who encounter the same problem.

As mentioned in my previous post, the dataset consists of seven files:

barcodes.tsv.gz
features.tsv.gz
matrix.mtx.gz
scalefactors_json.json.gz
tissue_hires_image.png.gz
tissue_lowres_image.png.gz
tissue_positions_list.csv.gz.

To proceed, we need to create two folders:

filtered_feature_bc_matrix
spatial

Place the first three files into the filtered_feature_bc_matrix folder, and the remaining four files into the spatial folder.

Then, run the following code. It will generate an object identical to the one produced by the Load10X_Spatial() function.

dir <- "./GSM8557976_BPH_1/"
counts <- Read10X(paste0(dir, "filtered_feature_bc_matrix/"))
BPH_1 <- CreateSeuratObject(counts = counts, project = "GSM8557976_BPH_1", assay = "Spatial")
image <- Read10X_Image(image.dir = paste0(dir, "spatial/"))
image <- image[Cells(x = BPH_1)]
DefaultAssay(image) <- "Spatial"
BPH_1[["slice1"]] <- image

Since this solution has not been fully validated, I warmly welcome any feedback or suggestions for improvement.

ADD REPLY
1
Entering edit mode
16 days ago
fracarb8 ★ 1.8k

If you have recreated the spaceranger folder structure (spatial + fitlered), then Load10X_Spatial(dir) should work just fine. If it doesn't it might simply be that the files are compressed (.gz) probabily to save space. For more details, you should look at the function on seurat repo.

ADD COMMENT
0
Entering edit mode

Oh, I see. That was my fault — the files in the spatial folder need to be decompressed. Thanks for catching that~~

ADD REPLY
0
Entering edit mode
16 hours ago

Hi tujuchuanli,

The files you have are from a 10X Visium spatial dataset, so you need to recreate the expected Space Ranger folder structure for Seurat to read them easily. Create a main directory (e.g., GSM8557976/) with two subfolders: filtered_feature_bc_matrix/ and spatial/. Place barcodes.tsv.gz, features.tsv.gz, and matrix.mtx.gz into the first folder. For the second, unzip the four files first (e.g., using gunzip or R's gzfile), then add the uncompressed versions: scalefactors_json.json, tissue_hires_image.png, tissue_lowres_image.png, and tissue_positions_list.csv.

Once set up, load with this simple code:

library(Seurat)

data_dir <- "./GSM8557976/"
seurat_obj <- Load10X_Spatial(data_dir)

This should work out of the box. If you run into issues with gzipped files, the manual approach in your follow-up comment is a solid alternative.

Kevin

ADD COMMENT

Login before adding your answer.

Traffic: 3751 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