ehrdata can store a numeric .X/layer as sparse.COO tensor, but two core functions don't handle it correctly::
infer_feature_types crashes on sparse.COO input:
>>> ed.infer_feature_types(edata) # edata.X is sparse.COO
NotImplementedError: The `order` parameter is not supported
It tries to reshape the sparse array the same way it reshapes a dense one, which sparse.COO.reshape doesn't support. Since several downstream functions (e.g .ep.pp.scale_norm) call infer_feature_types automatically whenever edata.var["feature_type"] isn't set yet, this blocks normal usage of any sparse.COO-backed EHRData
harmonize_missing_values silently does nothing for sparse.COO:
For a sparse array, the implicit 0 fill value is ambiguous, it can mean "not measured" or "measured as zero", but harmonize_missing_values currently treats all numeric layers (dense or sparse) as a no-op, so there's no way to mark genuinely-missing sparse entries as NaN.
TODO
ehrdata can store a numeric .X/layer as sparse.COO tensor, but two core functions don't handle it correctly::
infer_feature_typescrashes on sparse.COO input:It tries to reshape the sparse array the same way it reshapes a dense one, which
sparse.COO.reshapedoesn't support. Since several downstream functions (e.g .ep.pp.scale_norm) callinfer_feature_typesautomatically wheneveredata.var["feature_type"]isn't set yet, this blocks normal usage of any sparse.COO-backed EHRDataharmonize_missing_valuessilently does nothing for sparse.COO:For a sparse array, the implicit 0 fill value is ambiguous, it can mean "not measured" or "measured as zero", but
harmonize_missing_valuescurrently treats all numeric layers (dense or sparse) as a no-op, so there's no way to mark genuinely-missing sparse entries as NaN.TODO