scverse / scverse/scanpy

subset adata is a view

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

Nobody has claimed this yet.

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

Description

Hi thanks for your excellent work!

I noticed for a subset adata object, say
batch1 = adata[adata.obs["batch"] == "batch1", :]
it will be a view of the original adata

For further analysis, if I just wanted to calculate the mean of selected rows (it will give me the mean of all the rows of original data as it is a view),
I was wondering if there is any memory-efficient way to do it instead of using copy?

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

Reproduce the slicing example with adata[adata.obs["batch"] == "batch1", :] and compare the mean from the resulting view with the expected selected rows. Start by tracing how views are handled during subsetting; done means the selected-row mean is correct without requiring a full copy, with the memory implications documented or tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics, data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.