Skip to content

Instantly share code, notes, and snippets.

@johnkerl
Created August 8, 2024 21:05
Show Gist options
  • Save johnkerl/8c8020271bec82ff341772e1a26c1606 to your computer and use it in GitHub Desktop.
Save johnkerl/8c8020271bec82ff341772e1a26c1606 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# ================================================================
# This script demonstrates some issues for tiledbsoma-py for GitHub
# issue https://github.com/single-cell-data/TileDB-SOMA/issues/2822.
# These are issues:
#
# * Involving tiledbsoma.io.from_anndata / tiledbsoma.io.from_h5ad,
# and not tiledbsoma.Experiment.add_new_dataframe. (Those issues
# will be separately discussed.)
# * Involving various kinds of "null" -- Python None, pd.NA, math.nan --
# contained within AnnData input objects
# * Involving column types of categorical-of-string, bool, and int.
# ================================================================
import tiledbsoma
import tiledb
import sys
# ================================================================
if len(sys.argv) == 2:
uri = sys.argv[1]
else:
print("Need URI as argument.")
sys.exit(1)
sep = "-" * 64
with tiledb.open(uri) as A:
print()
print(sep)
print("OBS TILEDB-PY SCHEMA:")
print()
print(A.schema)
print()
print(sep)
print("OBS TILEDB-PY READ:")
print()
print(A.df[:])
print()
with tiledbsoma.DataFrame.open(uri) as obs:
print()
print(sep)
print("OBS TILEDB-SOMA SCHEMA:")
print()
print(obs.schema)
print()
print(sep)
print("OBS TILEDB-SOMA READ ARROW:")
print()
print(obs.read().concat())
print()
print(sep)
print("OBS TILEDB-SOMA READ PANDAS:")
print()
print(obs.read().concat().to_pandas())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment