scverse / scverse/scanpy

Different connectivties and UMAP if using data in X or obsm

Open
#1,993 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

  • [ x] I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the master branch of scanpy.
    Version: '1.8.0.dev70+g560bd5d3'

I have made adata with same data in X and obsm. Then I used either of those two matrices for neighbours and subsequent UMAP. The connectives and UMAPs however look different despite same starting data (does not seem to be due to randomness as I get same UMAPs with same representations on multiple runs).

# Adata
adata_pb=sc.AnnData(latent_pb)
adata_pb.obsm['X_integrated']=latent_pb

# From rep=X
sc.pp.neighbors(adata_pb,n_pcs=0,use_rep='X')
c_x=adata_pb.obsp['connectivities']
sc.tl.umap(adata_pb)
rcParams['figure.figsize']=(6,6)
sc.pl.umap(adata_pb)

image

# From rep=obsm
sc.pp.neighbors(adata_pb,n_pcs=0,use_rep='X_integrated')
c_o=adata_pb.obsp['connectivities']
sc.tl.umap(adata_pb)
rcParams['figure.figsize']=(6,6)
sc.pl.umap(adata_pb)

image

np.allclose(c_x.A, c_o.A)
False

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sc.pp.neighbors calls using use_rep='X' and use_rep='X_integrated', then follow how sc.tl.umap consumes the resulting connectivities. Reproduce the example with identical data in X and obsm, compare c_x.A with c_o.A and the resulting UMAPs, and consider the issue done when equivalent representations produce equivalent results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.