@@ -268,6 +268,7 @@ def _init_common(self):
268268
269269 def _init_as_view (self , mudata_ref : "MuData" , index ):
270270 from anndata ._core .index import _normalize_indices
271+ from anndata ._core .views import _resolve_idxs
271272
272273 obsidx , varidx = _normalize_indices (index , mudata_ref .obs .index , mudata_ref .var .index )
273274
@@ -307,9 +308,13 @@ def _init_as_view(self, mudata_ref: "MuData", index):
307308 cvaridx = slice (None )
308309 if a .is_view :
309310 if isinstance (a , MuData ):
310- self .mod [m ] = a ._mudata_ref [cobsidx , cvaridx ]
311+ self .mod [m ] = a ._mudata_ref [
312+ _resolve_idxs ((a ._oidx , a ._vidx ), (cobsidx , cvaridx ), a ._mudata_ref )
313+ ]
311314 else :
312- self .mod [m ] = a ._adata_ref [cobsidx , cvaridx ]
315+ self .mod [m ] = a ._adata_ref [
316+ _resolve_idxs ((a ._oidx , a ._vidx ), (cobsidx , cvaridx ), a ._adata_ref )
317+ ]
313318 else :
314319 self .mod [m ] = a [cobsidx , cvaridx ]
315320
@@ -334,6 +339,8 @@ def _init_as_view(self, mudata_ref: "MuData", index):
334339 self .file = mudata_ref .file
335340 self ._axis = mudata_ref ._axis
336341 self ._uns = mudata_ref ._uns
342+ self ._oidx = obsidx
343+ self ._vidx = varidx
337344
338345 if mudata_ref .is_view :
339346 self ._mudata_ref = mudata_ref ._mudata_ref
0 commit comments