crested.pp.sort_and_filter_regions_on_specificity#
- crested.pp.sort_and_filter_regions_on_specificity(adata, top_k, model_name=None, method='proportion', min_score=None, inplace=True)#
Sort bed regions & targets/predictions based on high Gini or proportion score per column while keeping the top k rows per column.
Combines them into a single AnnData object with extra columns indicating the original class name, the rank per column, and the score. To get an idea for the impact of different possible
top_kandmin_scorevalues, seesort_and_filter_cutoff(). We highly recommend setting amin_scorevalue especially when using “gini” on a small dataset.- Parameters:
adata (
AnnData) – The AnnData object containing the matrix (celltypes, regions) to be sorted.top_k (
int) – The number of top regions to keep per column.model_name (
str|None(default:None)) – The name of the model to look for in adata.layers[model_name] for predictions. If None, will use the targets in adata.X to decide which regions to sort.method (
Literal['gini','proportion'] (default:'proportion')) – The method to use for calculating scores, either ‘gini’ or ‘proportion’. Default is ‘proportion’ since v1.10.0, ‘gini’ before that.min_score (
float|None(default:None)) – If provided, keep only regions with gini or proportion score to be greater than this value. Will potentially lead to unbalanced numbers of regions by classes.inplace (
bool(default:True)) – Perform computation and modifyadatain-place or return a resulting copy of theadatainstead.
- Return type:
- Returns:
If
inplace=True(default), returns nothing and modifies the AnnData in-place with the sorted and filtered matrix, and extra columns indicating the original class name, the rank per column, and the score. Ifinplace=False, returns a modified copy of the AnnData object instead.
See also
Example
>>> crested.pp.sort_and_filter_regions_on_specificity( ... adata, ... top_k=500, ... method="proportion", ... )