squidpy icon indicating copy to clipboard operation
squidpy copied to clipboard

About introducing the data to Squidpy

Open Pedramto89 opened this issue 3 years ago • 3 comments

... To begin with, how we should introduce the data to start the analysis? In the tutorial, it's mentioned that loading data is like this:

img = sq.datasets.visium_hne_image()
adata = sq.datasets.visium_hne_adata()

Now, for the image, I think it is clear what is the input but for the adata, should we use "filtered_feature_bc_matrix.h5"? Because I used it and got an error.

I used this code:

adata = sq.read.visium(path, counts_file='filtered_feature_bc_matrix.h5',
               library_id=None, load_images=True, source_image_path= "../Data_Analysis/")

And then followed by:

sc.pp.normalize_total(adata)
sc.pp.log1p(adata)
sc.tl.umap(adata)
sc.tl.leiden(adata)

And finally: adata This is what I get:

AnnData object with n_obs × n_vars = 3870 × 17943
    obs: 'in_tissue', 'array_row', 'array_col', 'leiden'
    var: 'gene_ids', 'feature_types', 'genome'
    uns: 'spatial', 'log1p', 'pca', 'neighbors', 'umap', 'leiden'
    obsm: 'spatial', 'X_pca', 'X_umap'
    varm: 'PCs'
    obsp: 'distances', 'connectivities'

But when I want to it, there is an error:

sc.pl.spatial(adata,'leiden',spot_size=1)
TypeError                                 Traceback (most recent call last)
/var/folders/1m/217nxw_53mg35gpt1pm70hdh0000gn/T/ipykernel_4901/1744331117.py in <module>
----> 1 sc.pl.spatial(adata,'leiden',spot_size=1)

TypeError: spatial() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given

@giovp

Pedramto89 avatar Nov 06 '22 16:11 Pedramto89

Hi @Pedramto89 , you should use the Squidpy plotting functions (sq.pl.spatial_scatter in your case), here's an example, not the Scanpy one; lmk if this helps.

michalk8 avatar Nov 14 '22 23:11 michalk8

@michalk8 Sorry for the late response. Did not work. I again got a huge error.

Pedramto89 avatar Nov 27 '22 04:11 Pedramto89

@Pedramto89 you need to provide more details, please.

Zethson avatar Jan 09 '23 16:01 Zethson

For reading spatial omics data, please now refer to spatialdata-io.

LLehner avatar Jun 11 '24 16:06 LLehner