Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatic backing of sdata.tables #498

Closed
ArneDefauw opened this issue Mar 21, 2024 · 2 comments · Fixed by #501
Closed

automatic backing of sdata.tables #498

ArneDefauw opened this issue Mar 21, 2024 · 2 comments · Fixed by #501

Comments

@ArneDefauw
Copy link
Contributor

I was testing the new mutlitple tables feature on the main branch, and noticed that automatic backing of sdata.tables to the backing zarr store no longer works (or I fail to get it working). This is how it used to work:


import anndata as ad
import numpy as np
import pandas as pd
from spatialdata import SpatialData
import spatialdata
import os

path=""

n_cells = 100
n_genes = 50

# Creating random data
X = np.random.randn(n_cells, n_genes)
obs = pd.DataFrame(index=[f'cell_{i}' for i in range(n_cells)])
var = pd.DataFrame(index=[f'gene_{i}' for i in range(n_genes)])

adata = ad.AnnData(X=X, obs=obs, var=var)

adata.obs['cell_type'] = ['type1' if i < n_cells // 2 else 'type2' for i in range(n_cells)]
adata.var['highly_variable'] = np.random.choice([True, False], size=n_genes)


sdata=SpatialData()
sdata.write( os.path.join( path, "sdata_dummy.zarr" ) )

sdata.tables[ "dummy_table" ] = spatialdata.models.TableModel.parse( adata,
)

assert sdata.table is not None # this is ok

sdata=SpatialData.read( os.path.join( path, "sdata_dummy.zarr" ) )
sdata

assert sdata.table is not None # this gives assertionerror

Is this related to #496?

@LucaMarconato
Copy link
Member

Hi, thanks for reporting. Yes it is related to the bug you mentioned. I will fix this over the weekend before the next release. You can call the internal functions that we use when calling write() for the moment. Sorry for the inconvenience.

@melonora
Copy link
Collaborator

@LucaMarconato bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants