Package Bio :: Package phenotype :: Module phen_micro :: Class WellRecord
[hide private]
[frames] | no frames]

Class WellRecord

source code

object --+
         |
        WellRecord

WellRecord stores all time course signals of a phenotype Microarray well.

The single time points and signals can be accessed iterating on the WellRecord or using lists indeces or slices:

>>> from Bio import phenotype
>>> plate = phenotype.read("plate.csv", "pm-csv")
>>> well = plate['A05']
>>> for time, signal in well:
...    print("Time: %f, Signal: %f" % (time, signal))
...
Time: 0.0, Signal: 10.0
Time: 0.25, Signal: 14.0
Time: 0.5, Signal: 19.0
Time: 24.25, Signal: 32.0
...
>>> well[1]
23.0
>>> well[1:5]
[23.0, 23.0, 26.0, 26.0]
>>> well[1:5:0.5]
[23.0, 23.0, 23.0, 26.0, 26.0, 26.0, 26.0, 26.0]

If a time point was not present in the input file but it's between the minimum and maximum time point, the interpolated signal is returned, otherwise a nan value:

>>> well[1.3]
23.0
>>> well[1250]
nan

Two WellRecord objects can be compared: if their input time/signal pairs are exactly the same, the two records are considered equal:

>>> well2 = plate['H12']
>>> well == well2
False

Two WellRecord objects can be summed up or subtracted from each other: a new WellRecord object is returned, having the left operand id.

>>> well2 = well + well1
>>> print(well2.id)
A05

If SciPy is installed, a sigmoid function can be fitted to the PM curve, in order to extract some parameters; three sigmoid functions are available: * gompertz * logistic * richards The functions are described in Zwietering et al., 1990 (PMID: 16348228)

>>> well.fit()
>>> print(well.slope, well.model)
(61.853516785566917, 'logistic')

If not sigmoid function is specified, the first one that is successfully fitted is used. The user can also specify a specific function.

>>> well.fit('gompertz')
>>> print(well.slope, well.model)
(127.94630059171354, 'gompertz')

If no function can be fitted, the parameters are left as None, except for the max, min, average_height and area.

Instance Methods [hide private]
 
__init__(self, wellid, plate=None, signals=None)
Initialize the class.
source code
 
_interpolate(self, time)
Linear interpolation of the signals at certain time points (PRIVATE).
source code
 
__setitem__(self, time, signal)
Assign a signal at a certain time point.
source code
 
__getitem__(self, time)
Return a subset of signals or a single signal.
source code
 
__iter__(self) source code
 
__eq__(self, other) source code
 
__ne__(self, other) source code
 
__add__(self, well)
Add another WellRecord object.
source code
 
__sub__(self, well)
Subtract another WellRecord object.
source code
 
__len__(self)
Return the number of time points sampled.
source code
 
__repr__(self)
Return a (truncated) representation of the signals for debugging.
source code
 
__str__(self)
Return a human readable summary of the record (string).
source code
 
get_raw(self)
Get a list of time/signal pairs.
source code
 
get_times(self)
Get a list of the recorded time points.
source code
 
get_signals(self)
Get a list of the recorded signals (ordered by collection time).
source code
 
fit(self, function=('gompertz', 'logistic', 'richards'))
Fit a sigmoid function to this well and extract curve parameters.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, wellid, plate=None, signals=None)
(Constructor)

source code 
Initialize the class.
Overrides: object.__init__

__add__(self, well)
(Addition operator)

source code 

Add another WellRecord object.

A new WellRecord object is returned, having the same id as the left operand

__sub__(self, well)
(Subtraction operator)

source code 

Subtract another WellRecord object.

A new WellRecord object is returned, having the same id as the left operand

__repr__(self)
(Representation operator)

source code 
Return a (truncated) representation of the signals for debugging.
Overrides: object.__repr__

__str__(self)
(Informal representation operator)

source code 

Return a human readable summary of the record (string).

The python built-in function str works by calling the object's ___str__ method. e.g.

>>> from Bio import phenotype
>>> plate = phenotype.read("plates.csv", "pm-csv")
>>> record = plate['A05']
>>> print(record)
Plate ID: PM09
Well ID: A05
Time points: 288
Minum signal 0.00 at time 10.00
Maximum signal 7.50 at time 32.00
WellRecord('(0.0, 10.0), (0.25, 14.0), (0.5, 19.0), (0.75, 19.0), (1.0, 23.0)...(71.75, 32.0)')

Note that long time spans are shown truncated.

Overrides: object.__str__

fit(self, function=('gompertz', 'logistic', 'richards'))

source code 

Fit a sigmoid function to this well and extract curve parameters.

If function is None or an empty tuple/list, then no fitting is done. Only the object's .min, .max and .average_height are calculated.

By default the following fitting functions will be used in order:
  • gompertz
  • logistic
  • richards

The first function that is successfully fitted to the signals will be used to extract the curve parameters and update .area and .model. If no function can be fitted an exception is raised.

The function argument should be a tuple or list of any of these three function names as strings.

There is no return value.