Skip to main content

A class to handle data from a Soma experiment made by Phenomic AI

Project description

Pai Soma Data

Description

This package provides a class, SomaData, for handling data from a Soma experiment produced by Phenomic using TileDBSOMA. It allows users to interact with cached observation data as a Pandas DataFrame and retrieve subsets of data as AnnData objects, with features to query raw or normalized counts.

Features

  • Load and cache observation (obs) and variable (var) data from a SOMA experiment.
  • Retrieve subsets of data based on specified rows and columns.
  • Automatically chooses the appropriate layer (raw or norm) based on the number of genes requested.
  • Converts queried data into AnnData format for compatibility with downstream analysis tools.

Installation

To use this package, you'll need Python 3.8 or later.

pip install pai-soma-data

Usage

Initializing the SomaData Class

To start using the SomaData class, initialize it with the URI of your SOMA experiment. You can choose the data layer (raw or norm) based on your needs:

from pai_soma_data import SomaData

# Instantiate SomaData with normalized counts
sdata = SomaData(
    corpus_uri="...",
    layer="norm"  # Change to "raw" for raw counts
)

Accessing Metadata

The observation and gene metadata are stored in the .obs and .var attributes of the SomaData object, respectively. These are accessible as Pandas DataFrames:

# View the first few rows of observation metadata
print(sdata.obs.head())

# View the first few rows of variable (gene) metadata
print(sdata.var.head())

Slicing X Data

The SomaData class allows for Pandas-style slicing of data using the format (row_filter, col_filter). The data is fetched in the layer specified during instantiation (default is "norm" for normalized data).

  • Row filter: Can be a pd.Series, list of integers, or slices.
  • Column filter: Can be a gene name (string) or a list of gene names.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License.

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

pai_soma_data-1.0.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

pai_soma_data-1.0.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file pai_soma_data-1.0.3.tar.gz.

File metadata

  • Download URL: pai_soma_data-1.0.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.10

File hashes

Hashes for pai_soma_data-1.0.3.tar.gz
Algorithm Hash digest
SHA256 3db1f54187e96613a4bf1e102fc7dbfb1a13b8f63ca04872f60713ecd95c9337
MD5 cd1e76d124dc2cffcb1c7fb76fb46ce0
BLAKE2b-256 72c6ebea20e276cfeb58a527cd908a758c1e36f7dc90d6dc29f4e0c3e79fde54

See more details on using hashes here.

File details

Details for the file pai_soma_data-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pai_soma_data-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.10

File hashes

Hashes for pai_soma_data-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 de3fb53a910cbce193e0c0cf2f30d0c7653f1654c5e968cbade8e79549dc9793
MD5 c4b96fa658eecd16ebad36682e247e02
BLAKE2b-256 7f5bd40c0a9539d72a9d438b47071875c717122d9c40043f81b8dfb54e1c457d

See more details on using hashes here.

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