-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Labels
conceptualConceptual discussionsConceptual discussionslow-prioLow priority issue.Low priority issue.
Description
hi @giovp
I am writing this issue to document one of the commits I will make in #696. At this point it will be hard for me to separate that commit in the PR and it will be a small discussion compared to how big the PR will be. I want to discuss this implementation.
moscot/src/moscot/base/problems/problem.py
Lines 615 to 634 in 0892c6b
# TODO(@giovp): refactor | |
@staticmethod | |
def _spatial_norm_callback( | |
term: Literal["x", "y"], | |
adata: AnnData, | |
adata_y: Optional[AnnData] = None, | |
attr: Optional[Literal["X", "obsp", "obsm", "layers", "uns"]] = None, | |
key: Optional[str] = None, | |
) -> TaggedArray: | |
if term == "y": | |
if adata_y is None: | |
raise ValueError("When `term` is `y`, `adata_y` cannot be `None`.") | |
adata = adata_y | |
if attr is None: | |
raise ValueError("`attrs` cannot be `None` with this callback.") | |
spatial = TaggedArray._extract_data(adata, attr=attr, key=key) | |
logger.info(f"Normalizing spatial coordinates of `{term}`.") | |
spatial = (spatial - spatial.mean()) / spatial.std() | |
return TaggedArray(spatial, tag=Tag.POINT_CLOUD) |
First Issue: Typo
first of all I will fix the type from attrs
to attr
Second Issue: Standardization
but I also want to ask whether
spatial = (spatial - spatial.mean()) / spatial.std()
is a correct standardization, shouldn't it be
spatial = (spatial - spatial.mean(axis=0,keepdims=True)) / spatial.std(axis=0,keepdims=True)
since we'd like each feature to be gaussian units right? or am I missing something?
Metadata
Metadata
Assignees
Labels
conceptualConceptual discussionsConceptual discussionslow-prioLow priority issue.Low priority issue.