Plexora

attach_table

Point a project's cell table at a file a node is serving, and load it once.

Generated from Plexora 0.0.55View source
from plexora import attach_table
attach_table(
    project,
    node,
    resource_id,
    spec=None,
    table=None,
    subset_column=None,
    subset_value=None,
    reinspect=False,
    reload=True,
    **spec_fields,
)

The project keeps every answer about what the table MEANS -- which column is the cell id, which matrix holds the intensities, whether the values are already log-transformed. Those travel to the node with each load and are never stored there; only the read spec and the loaded shape travel back.

When to use

Call this to move an existing project's table onto a node: pass just project, node and resource_id, and the project's existing table spec is reused. Pass spec (or the spec fields as keywords) to attach a table the project has never had before. The image, the mask and the table are attached independently -- see plexora.attach_image and plexora.attach_segmentation -- so "table on the cluster, image on the laptop" is two calls, not a mode.

Parameters

projectstr | Projectrequired

The project to update, by name or object.

nodestrrequired

The registered node serving the file, as given to plexora.register_node.

resource_idstrrequired

The table resource's id on that node (see plexora.node_resources).

specdict | DataSpecdefault None

How to read the file. When neither spec nor any spec_fields are given and the project already has a table spec, that spec is reused with its source pointed at the node. When the project has no spec yet either, the node is asked to inspect the file and propose one (see plexora.inspect_table).

tablestrdefault None

Which table to read, for a file that holds more than one (a SpatialData .zarr store).

subset_columnstrdefault None

The obs column that names which image's rows belong to this project, for a file that spans several images.

subset_valuestrdefault None

The value of subset_column that selects this project's rows.

reinspectbooldefault False

Ask the node to inspect the file afresh instead of reusing the project's existing spec. Use this when the file at resource_id is not the file the project's spec was built for -- reusing a CSV's spec to read an .h5ad reads the wrong columns silently.

reloadbooldefault True

Reload the project in this process after saving. Defaults to True; pass False when a different process is serving the project and will be told to reload separately.

**spec_fields

DataSpec fields (type, src, coordinates, features, obs_id_field, normalization, ...) to build a read spec from scratch, as an alternative to spec.

Returns

Project

The project, saved with the table pointed at the node and (unless reload=False) reloaded so this process serves it.

Raises

KeyError

If project names an unknown project, or node names an unregistered node.

ValueError

If no read spec can be worked out for the table -- pass spec or the spec fields.

Examples

import plexora

plexora.attach_table("tonsil", node="hpc", resource_id="cells")

Guides

On this page