JEFworks-Lab / STdeconvolve

Reference-free cell-type deconvolution of multi-cellular spatially resolved transcriptomics data
http://jef.works/STdeconvolve/
98 stars 12 forks source link

About loading 10X data #26

Closed Pedramto89 closed 1 year ago

Pedramto89 commented 1 year ago

I wanted to load a filtered data from a spatial 10X experiment by:

se <- SpatialExperiment::read10xVisium(samples = "outs/filtered_feature_bc_matrix.h5", type = "sparse", data = "filtered")

However, I get en error: Error in SpatialExperiment::read10xVisium(samples = "outs/filtered_feature_bc_matrix.h5", : No matching files found for 'images=c(“lowres”)

I tried to change the code to: se <- SpatialExperiment::read10xVisium(samples = "outs/filtered_feature_bc_matrix.h5", type = "sparse", data = "filtered", images = c("lowres"), load = TRUE) but didn't work. What would I do?

Thanks

AteeqMKhaliq commented 1 year ago

Hi, I think its not finding the images (H&E) folder. please verify if you have a "spatial" folder in "outs" folder. for example /spatial_analysis/spaceranger_samples/sample1/outs/spatial/ in the spatial folder you should have lowres.png as /spatial_analysis/spaceranger_samples/sample1/outs/spatial/tissue_lowres_image.png if you don't have tissue_lowres_image.png then you will get this error. regards, AMK PS: I am the User of this wonderful package.

Pedramto89 commented 1 year ago

@AteeqMKhaliq Thank you for your response. So, there is a "spatial" folder in the "outs" from spaceranger and the image is there. I tried to set the directory for it but it again gave me the same error:

Error in match.arg(images, imgs, several.ok = TRUE) : 'arg' should be one of “lowres”, “hires”, “detected”, “aligned”

bmill3r commented 1 year ago

Hi @Pedramto89 (and thanks for your help @AteeqMKhaliq!)

In the tutorial Analysis of 10X Visium data, there is an example of using the function SpatialExperiment::read10xVisium(). I think the issue is that you are setting the parameter samples equal to a file, when instead it needs to be a directory. See the manual page for more details. For example, I believe you want to instead set samples = "outs/", which should be a directory that contains not only the filtered_feature_bc_matrix.h5 but also the subdirectory "spatial" that contains the images that this function is looking for.

Let me know if this helps or if you are still having problems, Brendan

Pedramto89 commented 1 year ago

Hi @bmill3r Thank you for your response. I understand it should be in the correct directory. That is why I set the directory already to the existing files and folders. The current working directory is this: "/Users/pedram/Documents/MASTER/Thesis/Visium/Data_Analysis/Res_of_Seq/9137/9137A/outs"

But again, I get the error again with this code: se <- SpatialExperiment::read10xVisium(samples = "filtered_feature_bc_matrix.h5", type = "sparse", data = "filtered", images = "spatial/tissue_lowres_image.png", load = TRUE)

The Error:

Error in match.arg(images, imgs, several.ok = TRUE) : 'arg' should be one of “lowres”, “hires”, “detected”, “aligned”

bmill3r commented 1 year ago

Hi @Pedramto89,

Based on the manual for SpatialExperiment::read10xVisium() I think that the parameter "samples" actually needs to be set to the directory itself and not to a specific file. And to be safe I also recommend using absolute paths when pointing functions to directories or files. What happens if you try:

se <- SpatialExperiment::read10xVisium(
        samples = "/Users/pedram/Documents/MASTER/Thesis/Visium/Data_Analysis/Res_of_Seq/9137/9137A/outs/",
        type = "sparse",
        data = "filtered",
        images = "lowres",
        load = TRUE
)

Let me know if that helps, Brendan

Pedramto89 commented 1 year ago

Thank you @bmill3r It finally worked. It seems the absolute path was the problem. For any reason, it didn't work before.