nadeemlab / SPT

Spatial profiling toolbox for spatial characterization of tumor immune microenvironment in multiplex images
https://oncopathtk.org
Other
21 stars 2 forks source link

create_bimodal_vector may return List instead of Series #371

Closed CarlinLiao closed 1 month ago

CarlinLiao commented 1 month ago

When create_bimodal_vector uses this return block, it returns a normal python list instead of a pandas series, since that's what BimodalityAssessor does.

https://github.com/nadeemlab/SPT/blob/a8985a41a75534f522faf48afdbb5a61bf1f6d7a/data_curation/convenience_scripts/bimodality_assessor.py#L162-L163

A quick fix to

if quality >= 0.5:
    res = pd.Series(assessor.get_dichotomized_feature(use_threshold=True, original=s), index=s.index)
    res.name = s.name
    return res

will preserve the ordering/index/metadata of the input series s, as if you ran apply on it like is done if this if block isn't triggered.