Unable to subset cells from backed anndata object after preprocessing
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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!
- Lingua principale
- Python
- Stelle
- 331
- Fork
- 44
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di scverse/SnapATAC2
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
-
Make igraph optionalForse di nuovo libera @kaizhang l’ha presa 65 giorni fa e non c’è nessuna pull request aperta. Aperta
Tutte le issue di scverse/SnapATAC2
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
fossasia/eventyay-exhibition#465 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
area/webapp comp/desktop P2 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#163341 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
cpp-best-practices/project_validator#609 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
smart-village-solutions/smart-speech-flow#765 ·
I maintainer di solito rispondono entro 1 giorno