-
Notifications
You must be signed in to change notification settings - Fork 709
Open
Labels
Needs info❔More information neededMore information needed
Description
Please make sure these conditions are met
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of scanpy.
- (optional) I have confirmed this bug exists on the main branch of scanpy.
What happened?
Following this common workflow:
adata.layers["counts"] = adata.X.copy()
sc.pp.normalize_total(adata)
sc.pp.log1p(adata)
adata.layers['lognorm'] = adata.X.copy()
adata.raw = adata # full dimension lognormalized data
sc.pp.scale(adata, max_value=10)
adata
If you check adata.X, adata.layers['counts'], and adata.layers['lognorm'], and adata.raw.X, you will find that adata.X and adata.raw.X are the same. The desired behavior would probably be for adata.raw.X to be the same as adata.layers['lognorm']. It appears that sc.pp.scale is changing adata.raw. Why is that?
Minimal code sample
adata.layers["counts"] = adata.X.copy()
sc.pp.normalize_total(adata)
sc.pp.log1p(adata)
adata.raw = adata
sc.pp.scale(adata, max_value=10)
adataadata.layers['lognorm']array([[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
[0. , 0. , 1.4028237, ..., 0. , 0. ,
0. ],
[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
...,
[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
[0. , 0. , 0. , ..., 0. , 0. ,
0. ]], shape=(70499, 309), dtype=float32)adata.Xarray([[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
[-0.2976397 , -0.35878736, 8.037066 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
...,
[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ]], shape=(70499, 309), dtype=float32)adata.raw.Xarray([[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
[-0.2976397 , -0.35878736, 8.037066 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
...,
[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ],
[-0.2976397 , -0.35878736, -0.2131979 , ..., -0.14714538,
-0.32566202, -0.3301082 ]], shape=(70499, 309), dtype=float32)Versions
Details
scanpy: 1.11.4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs info❔More information neededMore information needed