Skip to main content

A wrapper for managing DataFrames backed by TileDB

Project description

PyPI-Server Unit tests

cellarr-frame

cellarr-frame provides a high-level, Pandas-like interface for interacting with TileDB DataFrames.

Installation

pip install cellarr-frame

Quick Start

1. Creating a Frame

You can create a new persistent CellArrayFrame directly from a Pandas DataFrame.

import pandas as pd
import shutil
from cellarr_frame import CellArrayFrame

# Prepare some data
df = pd.DataFrame({
    "name": ["GeneA", "GeneB", "GeneC", "GeneD"],
    "expression": [12.5, 0.0, 5.2, 8.1],
    "category": ["coding", "non-coding", "coding", "coding"]
})
df.index.name = "row_id"

# Create the TileDB array at the specified URI
uri = "./my_cellarr_frame"
# clean up if exists
shutil.rmtree(uri, ignore_errors=True)

# Create with sparse=True to allow flexible appending and querying
CellArrayFrame.create(uri, df, sparse=True, full_domain=True)

2. Basic Slicing

Open the frame and slice rows using standard Python syntax.

cf = CellArrayFrame(uri=uri)

# Slice the first 2 rows
# Returns a Pandas DataFrame
print(cf[0:2])
#          name  expression    category
# row_id
# 0       GeneA        12.5      coding
# 1       GeneB         0.0  non-coding

3. Column Selection

Optimize performance by selecting only specific columns.

# Select only 'name' and 'expression' for the first row
print(cf[0:1, ["name", "expression"]])

4. Querying

Filter data using string conditions. The filtering happens at the storage layer, making it highly efficient for large datasets.

# Select all rows where expression is greater than 5.0
high_expr = cf["expression > 5.0"]
print(high_expr)

# Combine queries with column selection
# Get names of all 'coding' genes
coding_genes = cf["category == 'coding'", ["name"]]
print(coding_genes)

5. Appending Data

Append new batches of data to the existing array.

new_data = pd.DataFrame({
    "name": ["GeneE"],
    "expression": [99.9],
    "category": ["coding"]
})
# Ensure the index continues correctly
new_data.index = [4]
new_data.index.name = "row_id"

# Append to the array
cf.write_batch(new_data)

# Verify the new total count
print(f"Total rows: {cf.shape[0]}")

Note

This project has been set up using BiocSetup and PyScaffold.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cellarr_frame-0.0.6.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cellarr_frame-0.0.6-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file cellarr_frame-0.0.6.tar.gz.

File metadata

  • Download URL: cellarr_frame-0.0.6.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cellarr_frame-0.0.6.tar.gz
Algorithm Hash digest
SHA256 b6e01b33aa557947d60e408ab0b3677a47cf205adc2ad573526fe3892fa8ddc9
MD5 304b898f4df9560cf5450b431938f479
BLAKE2b-256 2ee999f449516f01f22f609d2806066bc1759aefd62c7adf3936b8849b5bd153

See more details on using hashes here.

Provenance

The following attestation bundles were made for cellarr_frame-0.0.6.tar.gz:

Publisher: publish-pypi.yml on CellArr/cellarr-frame

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cellarr_frame-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: cellarr_frame-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cellarr_frame-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6ed7be11f40b31263e3cafd42c9f40d04e4930b30c1b5baf15cda54d736a6fa0
MD5 24202d1cfeb309765ae2e56150406569
BLAKE2b-256 7df9ec17515145038a5cd67f43a971cd3c182ab72475a511b73e4e7f15a44333

See more details on using hashes here.

Provenance

The following attestation bundles were made for cellarr_frame-0.0.6-py3-none-any.whl:

Publisher: publish-pypi.yml on CellArr/cellarr-frame

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page