Unable to subset cells from backed anndata object after preprocessing
まだ誰も着手していません。
評価
調査の方向性
Start by tracing the backed AnnData subsetting path used by subset(selected_cells) and compare it with filter_cells() after preprocessing. Reproduce the length mismatch with the 8,212-cell example, then determine which preprocessing data structures need updating or invalidating for arbitrary metadata or barcode filters. Done means supported backed-mode subsetting works after preprocessing and has regression coverage.
索引モデルが issue の本文から書いたものです。
説明
Hi,
I am unable to subset cells in a fully preprocessed backed AnnData object using arbitrary filtering conditions.
So far, filtering based on the number of fragments (n_fragment) and/or the transcription start site enrichment score (tsse) using filter_cells() function seems to be the only reliable way to remove cells.
I have tried using the internal subset(selected_cells) function, but it fails once the AnnData object has been fully preprocessed. I have not yet identified the exact preprocessing step that causes this behavior. However, subsetting works right after applying filter_cells() and stops working at some point afterward.
Example
My AnnData object has the following structure:
AnnData object with n_obs × n_vars = 8212 × 6062095
backed at 'atac_1245.h5ad'
obs: 'n_fragment', 'frac_dup', 'frac_mito', 'tsse',
'doublet_probability', 'doublet_score'
var: 'count', 'selected'
uns: 'library_tsse', 'n_obs_before_filtering',
'frac_overlap_TSS', 'n_obs_after_filtering',
'reference_sequences', 'doublet_rate',
'scrublet_sim_doublet_score', 'TSS_profile',
'frag_size_distr'
obsm: 'fragment_paired'
When I try to subset the object using a Boolean pandas.Series of length 8212, I get the following error:
adata.subset(selected_cells)
RuntimeError: lengths don't match: could not create a new DataFrame:
height of column 'n_fragment' (8212) does not match
DataFrame height (8132)
The Boolean mask has the same length as the original AnnData object (8212 cells).
Expected behavior
I would expect to be able to subset cells based on arbitrary metadata columns or lists of cell barcodes, similar to how subsetting works with a standard AnnData object.
For example, filtering by a Boolean column in adata.obs:
adata = adata[adata.obs["condition"]]
Or selecting specific cells by barcode:
adata = adata[list_of_cell_barcodes, :]
Ideally, this functionality would remain available after preprocessing, without requiring the entire analysis to be rerun.
Why this matters
This limitation makes it difficult to remove cells based on criteria discovered during downstream analysis, such as identifying an unexpected cluster that needs to be excluded.
Reprocessing the entire dataset from import_fragments() is time-consuming. Being able to subset cells after preprocessing would make it much easier to refine cell selection without repeating computationally expensive steps.
I understand that some preprocessing results or derived data structures might need to be updated or discarded when cells are removed. However, even if subsetting invalidates certain intermediate results, it would be useful to have a supported way to filter cells without restarting the entire workflow.
Questions
- Is arbitrary cell subsetting after preprocessing currently supported?
- If so, is there a recommended way to subset cells based on metadata or cell barcodes?
- If not, could support for this functionality be considered, even if some derived data structures need to be discarded or recomputed?
- Could this be backed-mode specific ?
Thank you for your work on SnapATAC2!
- 主要言語
- Python
- スター
- 331
- フォーク
- 44
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
scverse/SnapATAC2 のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
-
Make igraph optional再び着手できるかも @kaizhang が 65 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
scverse/SnapATAC2 の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
fossasia/eventyay-exhibition#465 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
area/webapp comp/desktop P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#163341 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
cpp-best-practices/project_validator#609 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
smart-village-solutions/smart-speech-flow#765 ·
メンテナーはふだん 1 日以内に返信