opendvp.tl.filter_adata_by_gates

opendvp.tl.filter_adata_by_gates#

opendvp.tl.filter_adata_by_gates(adata, gates, sample_id=None)#

Filter an AnnData object to retain only markers specified in the gates DataFrame.

A very verbose function was created because of the specific way rescale works, It is finicky to small changes.

Return type:

AnnData

Parameters:#

adataAnnData

The annotated data matrix to be filtered (cells x markers).

gatesDataFrame

A DataFrame containing a ‘marker_id’ column with marker names to retain. Optionally contains a ‘sample_id’ column for filtering markers specific to a sample.

sample_idstr, optional

If provided, filters the gates DataFrame to only include rows with this sample_id.

Returns:#

AnnData

A new AnnData object with the same cells but filtered to include only the gated markers.