load_astrosample()#

function load_astrosample(sampleid, sdata=None, astrodb=None, database=None, *, image=True, annotations=True, cells_positions=MappingProxyType({}), cells_boundaries=MappingProxyType({}), cells_table=MappingProxyType({}))#

Load sample data into the SpatialData framework.

When loaded, the data will be labeled in the object by prepending the element with the unique sample specifier: “sampleid_sampleid”, followed by a unique element description. The package will use the specifier and element description for referencing the elements later. Examples of some common labels are provided in the lookup_element() method which can be used to lookup items in one of the elements for a sample (ex: images, shapes, tables).

Use input arguments for elements to optionally load sample data. Only elements with the sampleid input are affected. Sample element data is only reloaded for an element if a mapping is passed to the element argument or by passing 'reload' to the element argument.

Parameters:
  • sampleid (int | str | Sequence[int | str]) – A single or list of sampleids to load the data from.

  • sdata (SpatialData | None) – A SpatialData object to load the data into. If not provided a new SpatialData will be returned,

  • astrodb (AstroDB | None) – A AstroDB database connection instance to use. If not provided an instance will be created using the sciserver_creds.txt file.

  • database (str | None) – The database context that contains the sample. By default we use the ‘apmifwsi001_DR2’ database context. If providing an astrodb this variable is not used, be sure the context of the astrodb input specifies the appropriate database.

  • image (bool) – Load image data into the object (Defaults to True).

  • annotations (bool | Mapping[str, Any]) – A logical value to load annotations or a mapping for what to load. Allowed arguments are columns, instance_id, geometry_id, table_name, and any of the sql filters. Defaults to True. Annotations are loaded from the Annotations Table by default.

  • cells_table (bool | Mapping[str, Any]) – A logical value to load cell tables or a mapping for what to load. Allowed arguments are columns, instance_id, coordinate_ids, table_name, and any of the sql filters. (Defaults to False). Cells are loaded from the Celltag Table by default.

  • cells_positions (bool | Mapping[str, Any]) – A logical value to load cell centriods into the shapes element or a mapping for what to load. Allowed arguments are columns, instance_id, geometry_id, table_name, and any of the sql filters. (Defaults to False). Cells positions are loaded from the Celltag Table by default.

  • cells_boundaries (bool | Mapping[str, Any]) – A logical value to load cell centriods into the shapes element or a mapping for what to load. Allowed arguments are columns, instance_id, geometry_id, table_name, and any of the sql filters. (Defaults to False). Cells boundaries are loaded from the Cellgeom Table by default and only membranes are loaded using btype.

Return type:

SpatialData | None

Note

When passing columns to load additional data for the elements, be sure that the columns exist in the table the element requests data from. If passing a table_name, it is likely all of the keyword arguments need to be specified (this has not been throughly tested).

See also

AstroDB.add_sql_filters() for a full description on the filters that can be applied. In brief, the data can be filtered by passing a column name and values to include. For example, to only include tdist between 0 and 500 pass {‘tdist’:[0,500]}.

Allowed filters:
  • sampleid: Filter on the sampleid column.

  • ptype: Filter on the ptype column.

  • exprphenotype: Filter on exprphenotype column.

  • px: Filter on px column.

  • py: Filter on py column.

  • btype: Filter on btype column (0: Nuclei and 1:EntireCell).

  • lname: Filter on the annotation layer names.

  • tdist: Filter on tumor distance.

func_filter args:
  • val or <func_name>: A list or string indicating the values for the filter. Passing “*” will skip adding any filter. If passing named arguments, this can be passed as an argument to the filter name vs ‘val’ (e.g. {'ptype': '1'}). If using a default include, arguments do not have to be named.

  • table_name: (Optional(str)) The table name to query the column from. This can be applied when querying from multiple tables and must be a string not the ORM object.

  • context: (Optional(str)) The database context to query the column from. Can be used to generate cross database queries and must be a string not the ORM object.

  • include: (Optional(bool)) Should we include or exclude the values supplied in the val argument (default: True).

  • between: Optional(bool)) Should we use a “between” clause or “in” clause when passing a list to val (default: False). Overrides include.

  • bitwise: Optional(Union(bool, str))) For bitwise operations pass a boolean argument for default ‘&’ operations (uses include).