Skip to content

automatic backing of sdata.tables #498

Closed

Description

@ArneDefauw

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?

Activity

  1. LucaMarconato commented on Mar 21, 2024

    @LucaMarconato
    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.

  2. melonora commented on Apr 15, 2024

    @melonora
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions