Observable¶
This module provides API class definition to define observables.
Classes¶
Observable
: main object to define observables.
-
class
tunacell.base.observable.
FunctionalObservable
(name=None, f=None, observables=[])¶ Combination of
Observable
instancesParameters: - name (str) – user defined name for this observable
- f (callable) – the function to apply to observables
- observables (list of
Observable
instances) – parameters of the function f to be applied
Warning
Contrary to
Observable
, instances ofFunctionalObservable
cannot be represented as a string usingrepr()
, that could be turned into a new instance with identical parameters usingeval()
. This is due to the applied function, difficult to serialize as a string AND keeping a human-readable format to read its definition.-
label
¶ get unique string identifier
-
latexify
(show_variable=True, plus_delta=False, shorten_time_variable=False, prime_time=False, as_description=False, use_name=None)¶ Latexify observable name
-
mode
¶ Returns mode depending on observables passed as parameters
-
timing
¶ Return timing depending on observables passed as parameters
-
class
tunacell.base.observable.
Observable
(name=None, from_string=None, raw=None, differentiate=False, scale='linear', local_fit=False, time_window=0.0, join_points=3, mode='dynamics', timing='t', tref=None)¶ Defines how to retrieve observables.
Parameters: - name (str) – user name for this observable (can be one of the raw observable)
- raw (str (default None)) – raw name of the observable: must be a column name of raw data, i.e. first element of one entry of Experiment.datatype
- differentiate (boolean (default False)) – whether to differentiate raw observable
- scale (str {'linear', 'log'}) – expected scaling form as a function of time (used for extrapolating values at boundaries, including in the local_fit procedure)
- local_fit (boolean (default False)) – whether to perform local fit procedure
- time_window (float (default 20.)) – Time window over which local fit procedure is applied (used only when local_fit is activated)
- join_points (int (default 3)) – number of points over which extrapolation procedure is led by fitting linearly [the scale of] the observable w.r.t time
- mode (str {'dynamics', 'birth', 'division', 'net_increase', 'rate',) –
‘average’} mode used to retrieve data:
- ’dynamics’: all timepoints are retrieved
- ’birth’: only birth value is retrieved
- ’division’: only division value is retrieved
- ’net-increase-additive’: difference between division value
- and birth value
- ’net-increase-multiplicative’: ratio between division value
- and birth value
- ’rate’: rate of linear fit of [scale of] observable
- ’average’: average of observable over cell cycle
- timing (str {'t', 'b', 'd', 'm', 'g'}) –
set the time at which cell cycle observable is associated:
- ’t’ : time-lapse timing (associated to mode ‘dynamics’)
- ’b’ : cell cycle birth time
- ’d’ : cell cycle division time
- ’m’ : cell cycle midpoint (half time)
- ’g’ : cell cycle generation index
- tref (float or 'root' (default None)) – when timing is set to ‘g’, sets the 0th generation to the cell that bounds this reference time when timing is set to ‘t’ (time-lapse timing), allows to translate time values by substracting floating point value (if given as a float), or aligns to the colony root cell last time value as origin.
-
as_latex_string
¶ Export as LaTeX string. Old format, replaced by latexify
-
as_string_table
()¶ Human readable output as a table.
-
as_timelapse
()¶ Convert current observable to its dynamic counterpart
This is needed when computing cell-cycle observables.
-
label
¶ Label is outputing a unique string representation
This method creates a string label that specifies each parameter to re-construct the Observable. The output string is (kind-of) human readable. More importantly, it is suitable to be a filename (only alphanumeric caracters, and underscores), and in fact serves to name directories in analysis folder.
Note
__repr__()
: returns another string representation, that can be called by the built-ineval()
, to instantiate a new object with identical functional parameters.
-
latexify
(show_variable=True, plus_delta=False, shorten_time_variable=False, prime_time=False, as_description=False, use_name=None)¶ Returns a latexified string for observable
Parameters: - show_variable (bool) – whether to print out time/generation variable
- plus_delta (bool) – whether to add a $Delta$ to time/generation variable; used for auto- and cross-correlation labeling
- shorten_time_variable (bool) – when active, will display only $t$/$g$
- prime_time (bool) – whether to set a prime on the time/generation variable
- as_description (bool (default False)) – sets up the description of the observable from rules to compute it (derivatives, log, and raw label)
- use_name (str (default None)) – when the observable name is too cumbersome to be printed, and the user wants to choose a specific name for such a printout
-
load_from_string
(codestring)¶ Set Observable instance from string code created by label method
Parameters: codestring (str) – must follow some rules for parsing
-
exception
tunacell.base.observable.
ObservableError
¶
-
exception
tunacell.base.observable.
ObservableNameError
¶
-
exception
tunacell.base.observable.
ObservableStringError
¶
-
tunacell.base.observable.
set_observable_list
(*args, **kwargs)¶ Make raw, and functional observable lists for running analyses
Parameters: - *args – Variable length argument list of
Observable
orFunctionalObservable
instances - **kwargs – Accepted keyword arguments: ‘filters=[]’ with a list of
FilterSet
orFilterGeneral
instance (must have a .obs attribute)
Returns: lists of raw observables, functional observables (correctly ordered)
Return type: raw_obs, func_obs
- *args – Variable length argument list of
-
tunacell.base.observable.
unroll_func_obs
(obs)¶ Returns flattened list of FunctionalObservable instances
It inspect recursively the observable content of the argument to yield all nested FunctionalObservable instances. They are ordered from lower to deeper layers in nested-ness. If you need to compute f(g(h(x))), where x is a raw Observable, the generator yields h, g, and f lastly, so that evaluation can be performed in direct order.
Parameters: obs ( FunctionalObservable
instance) – the observable to inspectYields: FunctionalObservable
instance – The generator yields funcObs instance in appropriate order (from lower to higher level in nested-ness).
-
tunacell.base.observable.
unroll_raw_obs
(obs)¶ Returns a generator over flattened list of Observable instances
Parameters: obs ((list of) Observable
orFunctionalObservable
instances) –Yields: flatten – Observable
instances found in argument list, going into nested layers in the case of nested list, or forFunctionalObservable
instances