single-cell-data / SOMA

A flexible and extensible API for annotated 2D matrix data stored in multiple underlying formats.
MIT License
70 stars 9 forks source link

Add `Experiment` base type and `AxisExperimentQuery`. #76

Closed thetorpedodog closed 1 year ago

thetorpedodog commented 1 year ago

First adds the very basics of the Experiment wrapper type, then adds the interface for AxisExperimentQuery.

To elaborate on this from the commit message:

Because there is no TileDB-specific behavior in ExperimentAxisQuery, I believe we can actually pull the entire implementation here (it only uses the properties of Experiment itself) but that is for a later date.

I think this may actually be necessary—because of the “wrap, don’t extend” design of the Measurement and Experiment types (where they are implemented to be a proxy around any existing Collection rather than to be subclassed as a separate parent of a concrete Collection implementation), we want to provide the implementation so that in the SOMA library, it looks like:

# inside the SOMA implementation
exp_collection = load_collection()
soma_exp = somacore.Experiment(exp_collection)

# what the user does
query = soma_exp.axis_query(...)

An implementation could implement their own specialization of the axis query and experiment:

class SpecialExperiment(somacore.Experiment):
  # This is OK provided that SpecialAxisQuery is a subclass of AxisQuery.
  def axis_query(self, ...) -> SpecialAxisQuery:
    ...

This is still a useful place to get started, though.