Skip to content

Commit

Permalink
updating layer management as in scverse#1667 for _highly_variable_pea…
Browse files Browse the repository at this point in the history
…rson_residuals() as well
  • Loading branch information
jlause committed Mar 5, 2021
1 parent 76073cc commit 89e0dd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 6 additions & 3 deletions scanpy/preprocessing/_highly_variable_genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _highly_variable_pearson_residuals(
clip: Union[Literal['auto', 'none'], float] = 'auto',
chunksize: int = 100,
subset: bool = False,
inplace: bool = True,
inplace: bool = True
) -> Optional[pd.DataFrame]:
"""\
See `highly_variable_genes`.
Expand Down Expand Up @@ -211,7 +211,9 @@ def _highly_variable_pearson_residuals(
in all batches
"""

X = adata.layers[layer] if layer is not None else adata.X
view_to_actual(adata)
X = _get_obs_rep(adata, layer=layer)
computed_on = layer if layer else 'adata.X'

# Check for raw counts
if check_nonnegative_integers(X) is False:
Expand Down Expand Up @@ -325,7 +327,8 @@ def _highly_variable_pearson_residuals(
df = df.loc[adata.var_names]

if inplace or subset:
adata.uns['hvg'] = {'flavor': 'pearson_residuals'}
adata.uns['hvg'] = {'flavor': 'pearson_residuals',
'computed_on':computed_on}
logg.hint(
'added\n'
' \'highly_variable\', boolean vector (adata.var)\n'
Expand Down
8 changes: 2 additions & 6 deletions scanpy/preprocessing/_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,8 @@ def normalize_pearson_residuals(
)
adata = adata.copy()

# TODO: is this needed and if yes what for?
# normalize_total() has it so I used it here
# TODO: add to other files as well?!
view_to_actual(adata)

X = _get_obs_rep(adata, layer=layer) ## TODO add to other files as well!
view_to_actual(adata)
X = _get_obs_rep(adata, layer=layer)
computed_on = layer if layer else 'adata.X'

msg = 'computing analytic Pearson residuals on %s' % computed_on
Expand Down

0 comments on commit 89e0dd1

Please sign in to comment.