Generally, when a heatmap is generated, each cell corresponds to a single numeric value which in turn
unambiguously defines colour of this cell via some colour scale. Yet, nothing in the heatmap
chart implemented
in the linked-charts library requires the variables passed through the value
property to be just
single numeric values. Of course, the default way of defining colour scale expects these value to be single numbers,
but a user can easily override this by setting the colour
property. The function, user puts here, gets the value
exactly how it has been passed to value
property. It can be anything: an array, a sting, another function -
everything will do as soon as the user can define a way of transforming it into colour.
Here, we give an example how to utilise values that are not single numbers. The data that we are using here as an example contain the results of two assays, where 50 drugs in 5 different concentrations each were tested against 21 pancreatic cancer cell lines. RealTime-Glo (RTG) measures cell viability and is proportional to the number of methabolically active cells in a well. CellTox (CTX) gives us a value that is proportional to the amount of dead cells in a well. For each drug combination and concentration both values have been measured.
If a drug is active only in one of the assays, it means that either it doesn't really kill cells and they can recover afterwards, or it kills them not fast enough, leaving plenty of alive and active cells unharmed. Therefore it can be useful to look at both assays simultaniously. To this end we decided to use a well known in microscopy trick. We use a green channel for one assay and red for the other. Thus, the drugs, which in both assays demonstrated high effect will be shown in yellow, non-effective drugs will be shown as black cells and all others will be either red or green.
Therefore, this heatmap has two values per cell, each corresponds to a separate colour channel. For both channels we create an interactive
colourSlider
. We also demonstrate, how one can select and manipulate multiple cells, and how to
select and update several layers at ones. The chart to the rigth shows the inhibition values for each indifidual concentration of all the
selected drug.
A user of our framework can create apps with very little code. Bellow we show the part of the code that hasn't been explained in previous examples. You can find the complete code at the bottom of the page.
|
Click on all the yellow bubbles (), going from top to bottom, to see explanations of the code. Some lines of code, that have been already described in the previous examples, were omitted for the sake of simplicity. At the bottom of the page you can find the complete code. Here, we initialize and place the heampap. This heatmap will have two values per cell and the resulting colour will be
influenced by them separately. Another difference from previously described heatmaps will be the reaction to click. Now cells are not clicked,
but rather marked, allowing user to select several cells at once. By default, this behaviour is activated, when
Here, the row IDs are drug names and column IDs are cell lines. Here, we have not one, but two values. Both are average inhibitions, but measured by two different assays. RTG shows the decrease of number of metabolically active cells compared to the control, while CTX reflects the proportion of dead cells. In this heatmap we want to show the two values simultaniously and therefore both are passed to the heatmap. By now you probably have already noticed the label that appears each time the cursor hovers onver a cell, point or line.
The Any chart in the linked-charts library has two modes: clicking and selecting. In clicking mode each click on an element
triggers Here, we additionally make The Here, we generate IDs for all the layers we want to have on the curve fit plot. We take all the marked cells IDs and make a combination of a drug name, a cell line name and a type of the layer we want to have.
Here, we define all the dinamic properties of the Here, we define all the layers, providing a set of their IDs. This property works like Here, we define a type of each layer. In most cases it happens automatically, since layers are initialised by type-specific functions. But here we add layers by updating the set of layer IDs and therefore the type information is required for proper layer initialisation. The linked-charts library allows the user to manipulate several layers at once. To this end one need
to first select them. The Here, we select all the existing layers. Here, we define the number of elements for each layer depending on its type. A scatter plot will have ten points, a line chart will contain two lines. Here, we set x and y coordinates for all our scatter layers. Line charts doesn't have Like in the previous examples, here, on x-axis we have values from 0 to 4 that correspond to one of the tested concentrations. y-axis shows inhibition values. Here, we set a symbol for each assay. Inhibition values, measured by RTG will be shown as wyes and by CTX - as triangles. The linked-charts library can use the symbols supported by d3.symbol() function. They are "Circle", "Cross", "Diamond", "Square", "Star", "Triangle", "Wye". This property is also specific only to the scatters, so will be applied only to this type of layers. Here, we define the lines for curve fits almost the same way is has been done in all previous examples. The only difference here is
that we now use both assays and therefore have slightly modified the The Here, we set the colours for both scatter and line charts. Both have the To define a legend one need to provide either a scale function that will transform legend elements (colour, size, symbol etc.) into a label. Another option is an array with two columns: one with elements (colours in this case) and the other with the corresponding labels. Here, we define such an array. We construct an array of all selected drug-cell line combinations and an array of all the used colours. Here, we update the curveFit plot to display all the changes that were made to the layers. Instead of updating the entire legend one can just update the scale of a certain block. The A Here, both sliders are defined in almost identical way, so we explain setting only one of them. The full code you can finde at the bottom of the page. Here, we define the colour scale that a colour slider will then modify. This scale will take values from 0 to 50 and change from black to green. By setting the Here, we define a title of the slider. Here, we change the left margin of the slider to make it nicely aligned under the heatmap and leave space for the title. Here, we set the position (x and y coordinates) of the title and its size in pixels. Here, we define colour for each heatmap cell. We can't just take a transformed Here, we define an empty plot where the individual inhibition values and fitted curves will be shown. We set only global chart properties, such as size, axes titles, etc. the same way it has been done previously. You can find the full code at the bottom of the page. All the blocks of a legend are placed in a rectangle grid. By default, the size of the grid is estimated automatically, but here we fix the number of columns of the grid to 1. Here, we add to the legend two blocks to show which symbol and which type of line corresponds to which type of assay. Here, we add an empty block to the legend. This block will be updated after selecting cells of the heatmap. |
Show/hide full code