You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After talking to @ivirshup on Zulip, opening this issue here to point out an inconsistency in how anndata views currently work.
When I have a view of an anndata object, I expect that any changes to the parent anndata object will propagate to the view. This does not work for the obs and var fields.
Example: When I try adding a new column to obs or change an existing one in the parent anndata, the view is unchanged:
#make adata with obs fieldadata=anndata.AnnData(X=np.zeros((5,5)),
obs=dict(old='old_value'))
#make view by slicingview=adata[:3,:3]
#add new columnadata.obs['new']='test'#edit existing columnadata.obs['old']='new_value'#view.obs does not have the changes!print(view.obs)
#output:# old#0 old_value#1 old_value#2 old_value
For X I see the expected behavior:
#change the parent object's .Xadata.X[0,0]=1#change visible in view.Xview.X#output:#ArrayView([[1., 0., 0.],# [0., 0., 0.],# [0., 0., 0.]], dtype=float32)
(also works for obsp, obsm and layers, not shown for brevity)
I believe obs and var get copied when a view is made. IIRC this is about needing an updated obs_names and var_names which is tied to them being in obs/ var.
I also quickly checked the docs and did not find a mention of this behavior.
What should be the next steps?
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!
This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!
After talking to @ivirshup on Zulip, opening this issue here to point out an inconsistency in how anndata views currently work.
When I have a view of an anndata object, I expect that any changes to the parent anndata object will propagate to the view. This does not work for the
obs
andvar
fields.Example: When I try adding a new column to
obs
or change an existing one in the parent anndata, the view is unchanged:For
X
I see the expected behavior:(also works for
obsp
,obsm
andlayers
, not shown for brevity)According to @ivirshup
I also quickly checked the docs and did not find a mention of this behavior.
What should be the next steps?
The text was updated successfully, but these errors were encountered: