Represent microplates using HTML/SVG and JavaScript.
The easiest way to use labwarejs in your project is to grab the labware.min.js file
See labwarejs in action here.
My goal at the outset was to keep dependencies at a minimum. At present, labwarejs
only requires jQuery. In the future, this may change as I expand the baked-in capabilities of the library. For example, I've thought of leveraging d3's color scales to indicate the volume in a microplate well or the number of reads in a flowcell lane. Handlebars or lodash templates would also be a big help.
A Microplate has wells in rows and columns. These wells can have a square
, rounded
square, or circle
shape.
A Microplate can also have annotations--row and column labels. To enable annotations, pass annotation: true
when instantiating a Microplate, and make sure your padding
value is at least 20
.
By default, a new Microplate will have 96 circular wells.
You can pass any number of optional attributes to a Microplate instance:
attributes { 'id': 'myplate' }
By default, microplate coordinates are specified using letters for rows and numbers for columns. This can be changed by specifying letter
or number
for the rowIterator
or colIterator
property at instantiation.
You can set the plate margin
, padding
, and wellGap
values at instantiation.
Microplates are styled as black with white wells by default. You can style a microplate using CSS and svg properties.
The Well
prototype contains methods for volume tracking. The maxVolume
property of the well instance must be set. From there the addVol
and removeVol
methods can add and subtract volume from the wells down to zero and up to the maxVolume
value. There are also empty
and full
boolean properties.
If you want to attach event handlers to a component to make it interactive, the following component-class associations may be helpful:
Each Well
element has a well
class.
The Microplate
rectangle has a plate
class.
Annotation text elements have an annotation
class.
var plate = new Microplate();
$('#target_div').append(plate.render());
var plate = new Microplate({
padding: 30,
annotations: true,
wellShape: 'rounded'
});
$('#target_div').append(plate.render());
var plate = new Microplate({
padding:30,
annotations: true,
wellShape: 'circle',
rows: 4,
columns: 6
});
$('#target_div').append(plate.render());
var funkyPlate = new Microplate({
padding: 30,
annotations: true,
wellShape: 'square',
attributes: {
'id': 'funky'
}
});
$('#target_div').append(funkyPlate.render());
Then in your CSS you can do something like:
#funky text.annotation{
fill: pink;
}
#funky .plate{
fill: purple;
}
#funky .well{
fill: yellow;
stroke: white;
}
A Flowcell
prototype models Illumina flowcells and has one or more Lane
instances.
Flowcells are styled as black with white lanes by default. You can style a flowcell using CSS and svg properties. See the examples for more detail.
The Lane
prototype can track the number of clusters. If the clusters
property value exceeds the Lane
's maxClusters
property value, the overClustered
property will return true
. Similarly, you can see the cluster density as a percentage via the percentFull
property.
Illumina flowcells are subdivided into surfaces, swathes, and tiles. There's currently no visual representation of these concepts, but you can store integer values for the properties and get the total tiles via the totalTiles
property of the Lane
prototype.
If you want to attach event handlers to a component to make it interactive, the following component-class associations may be helpful:
Each Flowcell
element has a flowcell
class.
Each Lane
element has a lane
class.
var flowcell = new Flowcell({
lanes: 8,
padding: 20,
annotations: true
});
$('#target_div').append(flowcell.render());