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.

Running and saving PCA on different anndata layers

See original GitHub issue
  • Additional function parameters / changed functionality / changed defaults?
  • New analysis tool: A simple analysis tool you have been using and are missing in sc.tools?
  • New plotting function: A kind of plot you would like to seein sc.pl?
  • External tools: Do you know an existing package that should go into sc.external.*?
  • Other?

I find using the adata.layers really useful to compare normalisation strategies. I’d like to also be able to seamlessly run sc.tl.pca on data stored in different layers of the same anndata object.

At the moment my workaround is to set adata.X before PCA and changing the key to the adata.obsm element after:

adata.X = adata.layers["mylayer"]
sc.tl.pca(adata)
adata.obsm["mylayer_pca"] = adata.obsm["X_pca"]

Ideally I’d like to just be able to set a layer argument in sc.tl.pca, as in the plotting functions.

Any plans on linking data layers to dimensionality reductions?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Ebony-Watsoncommented, Oct 15, 2021

Is there any update on the progress of this?

1reaction
Koncopdcommented, Jul 7, 2020

Hi, you can also do this directly adata.obsm["mylayer_pca"] = sc.tl.pca(adata.layers["mylayer"])

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running and saving PCA on different anndata layers #1301
pca on data stored in different layers of the same anndata object. At the moment my workaround is to set adata.X before PCA...
Read more >
scanpy_07_spatial - GitHub Pages
visium_sge() downloads the dataset from 10x genomics and returns an AnnData object that contains counts, images and spatial coordinates. We will calculate ...
Read more >
scanpy.pl.pca — Scanpy 1.9.1 documentation - Read the Docs
Name of the AnnData object layer that wants to be plotted. By default adata.raw.X is plotted. If use_raw=False is set, then adata.X is...
Read more >
Introduction to scvi-tools — scvi 0.7.0 documentation
Now it's time to run setup_anndata() , which alerts scvi-tools to the locations of various matrices inside the anndata. It's important to run...
Read more >
anndata: annotated data in R - R-bloggers
anndata is a commonly used Python package for keeping track of data ... and anndata through reticulate, but run into issues converting some ......
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