opendvp.tl.filter_by_ratio

opendvp.tl.filter_by_ratio#

opendvp.tl.filter_by_ratio(adata, end_cycle, start_cycle, label='DAPI', min_ratio=0.5, max_ratio=1.05, add_detailed_pass_fail=False)#

Filter cells by the ratio of two markers in an AnnData object.

This function computes the ratio between two markers (columns) for each cell, and flags cells whose ratio falls within the specified range. The results are stored as new columns in .obs.

Return type:

AnnData

Parameters#

adataad.AnnData

AnnData object containing the data matrix and metadata.

end_cyclestr

Name of the marker/column for the numerator of the ratio.

start_cyclestr

Name of the marker/column for the denominator of the ratio.

labelstr, default ‘DAPI’

Label prefix for the new columns in .obs.

min_ratiofloat, default 0.5

Minimum allowed ratio (exclusive).

max_ratiofloat, default 1.05

Maximum allowed ratio (exclusive).

add_detailed_pass_failbool, default False

If True, adds intermediate boolean columns indicating which cells passed the lower bound (_pass_nottoolow) and upper bound (_pass_nottoohigh).

Returns:#

ad.AnnData

A new AnnData object with new columns in .obs for the ratio and pass/fail flags.

Raises:#

ValueError

If marker names are not found or if min_ratio >= max_ratio.