question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

multiple Visium sections in one adata object does not work with `sc.pl.spatial(img_key=None)`

See original GitHub issue

Does scanpy==1.5.1 support multiple sections in one adata object? If I concatenate several anndata object I can’t plot even with sc.pl.spatial(img_key=None).

Try concatenating 3 mouse brain adata object and plotting:

adata = adata1.concatenate([obj2, obj3], index_unique=None)
sc.pl.spatial(adata[adata.obs["sample"]==adata.obs["sample"].unique()[0], :], 
              color=["Rorb", "Vip"], img_key=None,
              vmin=0, cmap='magma',
              gene_symbols='SYMBOL')

This is the error I get:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-9-8c84185773ec> in <module>
      6               color=["Rorb", "Vip"], img_key=None,
      7               vmin=0, cmap='magma', #vmax=3.8,
----> 8               gene_symbols='SYMBOL'
      9              )

/nfs/team283/vk7/software/miniconda3farm5/envs/cellpymc/lib/python3.7/site-packages/scanpy/plotting/_tools/scatterplots.py in spatial(adata, img_key, library_id, crop_coord, alpha_img, bw, size, **kwargs)
    765     """
    766     if library_id is _empty:
--> 767         library_id = next((i for i in adata.uns['spatial'].keys()))
    768     else:
    769         if library_id not in adata.uns['spatial'].keys():

KeyError: 'spatial'

Versions:

scanpy==1.5.1 anndata==0.7.1 umap==0.3.10 numpy==1.17.3 scipy==1.4.1 pandas==0.25.3 scikit-learn==0.22.1 statsmodels==0.10.2 python-igraph==0.7.1 louvain==0.6.1 leidenalg==0.7.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ivirshupcommented, May 28, 2020

Much of the spatial data is stored in uns, which does not get combined by default.

There is an example of concatenating visium datasets in the tutorial and more information on concatenating .uns in the latest anndata docs.

0reactions
ivirshupcommented, May 31, 2020

No problem!

Read more comments on GitHub >

github_iconTop Results From Across the Web

multiple Visium sections in one adata object does not work ...
If I concatenate several anndata object I can't plot even with sc.pl.spatial(img_key=None) . Try concatenating 3 mouse brain adata object and ...
Read more >
scanpy.pl.spatial — Scanpy 1.9.1 documentation
Use size to scale the size of the Visium spots plotted on top. As this function is designed to for imaging data, there...
Read more >
scanpy_07_spatial - GitHub Pages
Spatial transcriptomic data with the Visium platform is in many ways similar to scRNAseq data. It contains UMI counts for 5-20 cells instead...
Read more >
A Landmark-based Common Coordinate Framework for ...
ever, in contrast to single cell data, spatial ... the spatial domain. Finally, we formulate a multivariate regression problem where the.
Read more >
Tutorial: 10x Genomics Visium Dataset - Vitessce
In this tutorial, we will visualize a 10x Genomics visium dataset from start to ... Run the following functions to pre-process the data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found