Open
Description
What kind of feature would you like to request?
Additional function parameters / changed functionality / changed defaults?
Please describe your wishes
background
the current implementation of 'sc.tl.embedding_density' assumes embeddings are stored in 'adata.obsm['x_']'. this works for standard embeddings like UMAP or PCA but breaks down when working with custom embeddings such as 'adata.obsm['z_umap']' or 'adata.obsm['u_umap']'.
problem
this hardcoded assumption prevents users from computing density estimates on latent spaces learned by custom models (e.g. scvi, mrvi, totalvi), especially when embeddings are stored under alternative names.
proposal
- allow an optional 'obsm_key' argument that overrides the 'x_' logic.
- or relax the naming constraint by trying 'basis' directly before falling back to 'x_'.
benefit
this improves flexibility and aligns better with increasingly common model-based workflows in the single-cell community.
example
adata.obsm['u_umap'] = u_umap
sc.tl.embedding_density(adata, basis='u_umap') # fails due to 'X_u_umap' assumption