Micro arrays datasets

Omerobiobank has specialized objects to deal with the description of micro arrays dataset. The basic objects that should be captured are:

  • the physical chip that contain the microarray hibridization beads/grids
  • (possibly) the platform (usually a slide) where the chip is mounted
  • the raw datasets obtained by reading the hibridizaton results

The raw datasets will then be converted to biologically informative data, but this is outside the scope of this notebook.


In [1]:
import sys, os, uuid
from bl.vl.kb import KnowledgeBase

OME_HOST = os.getenv('OME_HOST', 'localhost')
OME_USER = os.getenv('OME_USER', 'test')
OME_PASSWD = os.getenv('OME_PASSWD', 'test')
CHECK_OME_VERSION = os.getenv('CHECK_OME_VERSION', "True") == "True"

BaseProxy = KnowledgeBase(driver='omero')

class Proxy(BaseProxy):
    def get_objects_dict(self, klass):
        return dict((o.label, o) for o in super(Proxy, self).get_objects(klass))

kb = Proxy(OME_HOST, OME_USER, OME_PASSWD, check_ome_version=CHECK_OME_VERSION)
kb.connect()
kb.start_keep_alive()

def cleanup():
    print "# disconnecting the kb"
    kb.disconnect()

def make_barcode():
    return uuid.uuid4().hex
    
    
sys.exitfunc = cleanup

print
print "### KB ENV PRELOADED ###"
print "# connected to %s" % OME_HOST
print "# knowledge base: kb"
print "# extra method: kb.get_objects_dict"
print "########################"


### KB ENV PRELOADED ###
# connected to 192.168.56.101
# knowledge base: kb
# extra method: kb.get_objects_dict
########################

In the following we will need a container to aliquot DNA from. For the time being, we define a function to build a TiterPlate with 24 wells filled with DNA.


In [2]:
def create_titer_plate(label, action):
    conf = {'rows': 6, 'columns': 2, 'label': label,
            'barcode': make_barcode(),
            'status': kb.ContainerStatus.READY,
            'action': action,
            }
    titer_plate = kb.factory.create(kb.TiterPlate, conf).save()
    for row in range(titer_plate.rows):
        for column in range(titer_plate.columns):
            conf = {'row': row + 1, 'column': column + 1,
                    'container': titer_plate,
                    'initialVolume': 1.0,
                    'currentVolume': 1.0,
                    'content': kb.VesselContent.DNA,
                    'status': kb.VesselStatus.CONTENTUSABLE,
                    'action': action}
            kb.factory.create(kb.PlateWell, conf).save()
    return titer_plate

In [3]:
with kb.context.sandbox():
    action = kb.create_an_action()
    titer_plate = create_titer_plate('a-foo-plate', action)
    for well in kb.get_wells_by_plate(titer_plate):
        print well.label, well.slot


A1 1
A2 2
B1 3
B2 4
C1 5
C2 6
D1 7
D2 8
E1 9
E2 10
F1 11
F2 12

Actions that create a chip

Basic actions that bring a chip into Omero.biobank:

  • import with an ActionCategory.IMPORT, no target, to create a chip with VesselStatus.UNUSED, basically something like an import in the stockroom;
  • import with an ActionCategory.ALIQUOTING from a target of type derived from Vessel, typically Tube or PlateWell, to create a chip with, if everything is ok, a VesselStatus.CONTENTUSABLE.

In [4]:
def create_action_on_well(titer_plate, row, column):
    return kb.create_an_action(target=kb.get_well_on_plate(titer_plate, row, column),
                               acat=kb.ActionCategory.ALIQUOTING)

Physical chips

Affymetrix chips

We are currently handling two major micro array technologies, Affymetrix and Illumina.

The affymetrix chips we have are individually packaged in a stand-alone object with a barcode. We model it using an object AffymetrixArray, that is understood as derived from Tube but with assigned volume. The instantiation of a AffymetrixArray requires the assignement of a value from the enum AffymetrixAssayType, besides all other field that are coming from being a Tube, that is a label, a barcode, and a content. FIXME: content should be DNA, status.


In [5]:
def create_affy_chip(label, action):
    conf={'label': label,
          'assayType': kb.AffymetrixAssayType.GENOMEWIDESNP_6,
          'barcode': make_barcode(),
          'content': kb.VesselContent.DNA,
          'status': kb.VesselStatus.UNUSED, # FIXME, this is confusing
          'action': action}
    return kb.factory.create(kb.AffymetrixArray, conf).save()

In [6]:
with kb.context.sandbox():
    action = kb.create_an_action()
    affy_chip = create_affy_chip('an-affy-chip', action)
    print affy_chip.label, affy_chip.barcode


an-affy-chip ae1a03912a5c4a30a5c5beab4994f2f0

Illumina micro arrays

Illumina chips are more complex, since they are packages, typically, 12 on a glass support (slide). The slide is modelled with a class IlluminaArrayOfArrays. A IlluminaArrayOfArray is a complex object with a type, arrayClass, and assayType choosen, respectively, between the ones listed by the enum IlluminaArrayOfArraysType, IlluminaArrayOfArraysClass and IlluminaArrayOfArraysAssayType. The model IlluminaArrayOfArrays is derived from TiterPlate.


In [7]:
def create_illumina_array_of_array(label, action):
    conf={'status': kb.ContainerStatus.READY,
          'assayType': kb.IlluminaArrayOfArraysAssayType.Infinium_HD,
          'rows': 6, 'columns': 2,
          'arrayClass': kb.IlluminaArrayOfArraysClass.Slide,
          'barcode': make_barcode(), 'label': label,
          'type': kb.IlluminaArrayOfArraysType.UNKNOWN,
          'action': action}
    return kb.factory.create(kb.IlluminaArrayOfArrays, conf).save()

In [8]:
with kb.context.sandbox():
    action = kb.create_an_action()
    array = create_illumina_array_of_array('a label', action)
    print array.label, array.barcode


a label 3d5b8efbc9e643aab881330db7bf586c

The actual Illumina chips are describe by the model IlluminaBeadChipArray, derived from PlateWell. Apart from all the standard PlateWell properties, an IlluminaBeadChipArray instance has the property assayType chosen from the enum IlluminaBeadChipAssayType.


In [9]:
def create_bead_chip_array(array, assay_type, row, column, action):
    conf = {
    'content': kb.VesselContent.DNA, 'status': kb.VesselStatus.CONTENTUSABLE,
    'container': array, 'assayType': assay_type,
    'row': row, 'column': column,'action': action,
    }
    return kb.factory.create(kb.IlluminaBeadChipArray, conf).save()

In [10]:
with kb.context.sandbox():
    action = kb.create_an_action()
    titer_plate = create_titer_plate('a-fake-plate-well', action)
    print 'we have a titer_plate', titer_plate
    array = create_illumina_array_of_array('a-fake-illumina-array', action)
    print 'we have an array'
    assay_type = kb.IlluminaBeadChipAssayType.HumanOmni5_4v1_B
    for row in range(1, array.rows + 1):
        for column in range(1, array.columns + 1):
            action_on_well = create_action_on_well(titer_plate, row, column)
            create_bead_chip_array(array, assay_type, row, column, action_on_well)
            print 'created well ({}, {})'.format(row, column)


we have a titer_plate <bl.vl.kb.drivers.omero.objects_collections.TiterPlate object at 0x4857990>
we have an array
created well (1, 1)
created well (1, 2)
created well (2, 1)
created well (2, 2)
created well (3, 1)
created well (3, 2)
created well (4, 1)
created well (4, 2)
created well (5, 1)
created well (5, 2)
created well (6, 1)
created well (6, 2)