attach_table
Point a project's cell table at a file a node is serving, and load it once.
from plexora import attach_tableattach_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 | ProjectrequiredThe project to update, by name or object.
nodestrrequiredThe registered node serving the file, as given to
plexora.register_node.
resource_idstrrequiredThe table resource's id on that node (see
plexora.node_resources).
specdict | DataSpecdefault NoneHow 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 NoneWhich table to read, for a file that holds
more than one (a SpatialData .zarr store).
subset_columnstrdefault NoneThe obs column that names which image's rows belong to this project, for a file that spans several images.
subset_valuestrdefault NoneThe value of subset_column that
selects this project's rows.
reinspectbooldefault FalseAsk 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 TrueReload 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_fieldsDataSpec fields (type, src, coordinates,
features, obs_id_field, normalization, ...) to build a read
spec from scratch, as an alternative to spec.
Returns
ProjectThe project, saved with the table pointed at the node and
(unless reload=False) reloaded so this process serves it.
Raises
KeyErrorIf project names an unknown project, or node names an
unregistered node.
ValueErrorIf 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")Related
attach_image
Point a project's image at a file a node is serving.
attach_segmentation
Point a project's segmentation mask at a file a node is serving.
detach
Bring one of a project's resources back to this machine.