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

Class PlateRecord

source code

object --+
         |
        PlateRecord

PlateRecord object for storing Phenotype Microarray plates data.

A PlateRecord stores all the wells of a particular phenotype Microarray plate, along with metadata (if any). The single wells can be accessed calling their id as an index or iterating on the PlateRecord:

>>> from Bio import phenotype
>>> plate = phenotype.read("plate.csv", "pm-csv")
>>> well = plate['A05']
>>> for well in plate:
...    print("%s" % well.id)
...
A01
A02
...

The plate rows and columns can be queried with an indexing system similar to NumPy and other matrices:

>>> print(plate[1])
PlateRecord('WellRecord['B01'], WellRecord['B02'], WellRecord['B03'], ..., WellRecord['B12']')
>>> print(plate[:,1])
PlateRecord('WellRecord['A02'], WellRecord['B02'], WellRecord['C02'], ..., WellRecord['H02']')

Single WellRecord objects can be accessed using this indexing system:

>>> print(plate[1,2])
WellRecord('(0.0, 11.0), (0.25, 11.0), (0.5, 11.0), (0.75, 11.0), (1.0, 11.0), ..., (95.75, 11.0)')

The presence of a particular well can be inspected with the "in" keyword: >>> 'A01' in plate True

All the wells belonging to a "row" (identified by the first character of the well id) in the plate can be obtained:

>>> for well in plate.get_row('H'):
...     print("%s" % well.id)
...
H01
H02
H03
...

All the wells belonging to a "column" (identified by the number of the well) in the plate can be obtained:

>>> for well in plate.get_column(12):
...     print("%s" % well.id)
...
A01
B12
C12
...

Two PlateRecord objects can be compared: if all their wells are equal the two plates are considered equal:

>>> plate2 = phenotype.read("plate.json", "pm-json")
>>> plate == plate2
True

Two PlateRecord object can be summed up or subracted from each other: the the signals of each well will be summed up or subtracted. The id of the left operand will be kept:

>>> plate3 = plate + plate2
>>> print(plate3.id)
PM01

Many Phenotype Microarray plate have a "negative control" well, which can be subtracted to all wells:

>>> subplate = plate.subtract_control()
Instance Methods [hide private]
 
__init__(self, plateid, wells=None)
Initialize the class.
source code
 
_update(self)
Update the rows and columns string identifiers (PRIVATE).
source code
 
_is_well(self, obj)
Check if the given object is a WellRecord object (PRIVATE).
source code
 
__getitem__(self, index)
Access part of the plate.
source code
 
__setitem__(self, key, value) source code
 
__delitem__(self, key) source code
 
__iter__(self) source code
 
__contains__(self, wellid) source code
 
__len__(self)
Return the number of wells in this plate.
source code
 
__eq__(self, other) source code
 
__ne__(self, other) source code
 
__add__(self, plate)
Add another PlateRecord object.
source code
 
__sub__(self, plate)
Subtract another PlateRecord object.
source code
 
get_row(self, row)
Get all the wells of a given row.
source code
 
get_column(self, column)
Get all the wells of a given column.
source code
 
subtract_control(self, control='A01', wells=None)
Subtract a 'control' well from the other plates wells.
source code
 
__repr__(self)
Return a (truncated) representation of the plate for debugging.
source code
 
__str__(self)
Return a human readable summary of the record (string).
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, plateid, wells=None)
(Constructor)

source code 
Initialize the class.
Overrides: object.__init__

_is_well(self, obj)

source code 

Check if the given object is a WellRecord object (PRIVATE).

Used both for the class constructor and the __setitem__ method

__getitem__(self, index)
(Indexing operator)

source code 

Access part of the plate.

Depending on the indices, you can get a WellRecord object (representing a single well of the plate), or another plate (representing some part or all of the original plate).

plate[wid] gives a WellRecord (if wid is a WellRecord id) plate[r,c] gives a WellRecord plate[r] gives a row as a PlateRecord plate[r,:] gives a row as a PlateRecord plate[:,c] gives a column as a PlateRecord

plate[:] and plate[:,:] give a copy of the plate

Anything else gives a subset of the original plate, e.g. plate[0:2] or plate[0:2,:] uses only row 0 and 1 plate[:,1:3] uses only columns 1 and 2 plate[0:2,1:3] uses only rows 0 & 1 and only cols 1 & 2

>>> from Bio import phenotype
>>> plate = phenotype.read("plate.csv", "pm-csv")

You can access a well of the plate, using its id.

>>> w = plate['A01']

You can access a row of the plate as a PlateRecord using an integer index:

>>> first_row = plate[0]
>>> print(first_row)
PlateRecord('WellRecord['A01'], WellRecord['A02'], WellRecord['A03'], ..., WellRecord['A12']')
>>> last_row = plate[-1]
>>> print(last_row)
PlateRecord('WellRecord['H01'], WellRecord['H02'], WellRecord['H03'], ..., WellRecord['H12']')

You can also access use python's slice notation to sub-plates containing only some of the plate rows:

>>> sub_plate = plate[2:5]
>>> print(sub_plate)
PlateRecord('WellRecord['C01'], WellRecord['C02'], WellRecord['C03'], ..., WellRecord['E12']')

This includes support for a step, i.e. plate[start:end:step], which can be used to select every second row:

>>> sub_plate = plate[::2]

You can also use two indices to specify both rows and columns. Using simple integers gives you the single wells. e.g.

>>> w = plate[3, 4]
>>> print(w.id)
'D05'

To get a single column use this syntax:

>>> sub_plate = plate[:, 4]
>>> print(sub_plate)
PlateRecord('WellRecord['A05'], WellRecord['B05'], WellRecord['C05'], ..., WellRecord['H05']')

Or, to get part of a column,

>>> sub_plate = plate[1:3, 4]
>>> print(sub_plate)
PlateRecord(WellRecord['B05'], WellRecord['C05'])

However, in general you get a sub-plate,

>>> print(align[1:5, 3:6])
PlateRecord('WellRecord['B04'], WellRecord['B05'], WellRecord['B06'], ..., WellRecord['E06']')

This should all seem familiar to anyone who has used the NumPy array or matrix objects.

__add__(self, plate)
(Addition operator)

source code 

Add another PlateRecord object.

The wells in both plates must be the same

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

__sub__(self, plate)
(Subtraction operator)

source code 

Subtract another PlateRecord object.

The wells in both plates must be the same

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

get_row(self, row)

source code 

Get all the wells of a given row.

A row is identified with a letter (e.g. 'A')

get_column(self, column)

source code 

Get all the wells of a given column.

A column is identified with a number (e.g. '6')

subtract_control(self, control='A01', wells=None)

source code 

Subtract a 'control' well from the other plates wells.

By default the control is subtracted to all wells, unless a list of well ID is provided

The control well should belong to the plate A new PlateRecord object is returned

__repr__(self)
(Representation operator)

source code 
Return a (truncated) representation of the plate 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
>>> record = phenotype.read("plates.csv", "pm-csv")
>>> print(record)
Plate ID: PM09
Well: 96
Rows: 8
Columns: 12
PlateRecord('WellRecord['A01'], WellRecord['A02'], WellRecord['A03'], WellRecord['A04']...WellRecord['H12']')

Note that long well lists are shown truncated.

Overrides: object.__str__