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.
|
# 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?
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
First Issue: Typo
first of all I will fix the type from
attrstoattrSecond Issue: Standardization
but I also want to ask whether
is a correct standardization, shouldn't it be
since we'd like each feature to be gaussian units right? or am I missing something?