Martin Krzywinski / Genome Sciences Center / mkweb.bcgsc.ca Martin Krzywinski / Genome Sciences Center / mkweb.bcgsc.ca - contact me Martin Krzywinski / Genome Sciences Center / mkweb.bcgsc.ca on Twitter Martin Krzywinski / Genome Sciences Center / mkweb.bcgsc.ca - Lumondo Photography Martin Krzywinski / Genome Sciences Center / mkweb.bcgsc.ca - Pi Art Martin Krzywinski / Genome Sciences Center / mkweb.bcgsc.ca - Hilbertonians - Creatures on the Hilbert Curve
syncopation & accordionCafe de Flore (Doctor Rockit)like France, but no dog poopmore quotes

differences: more


EMBO Practical Course: Bioinformatics and Genome Analysis, 5–17 June 2017.


data visualization + art

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
To view the art you'll need a pair of red-blue 3D glasses.
The data will stand out—and you will too.

BD Genomics stereoscopic art exhibit — AGBT 2017

Art is science in love.
— E.F. Weisslitz

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Our art exhibit at AGBT 2017 asked new school questions in old school ways.

The final art pieces are the outcome of a long process of exploration, experimentation and more than a few dead-ends. Here I'll take you through the process of parsing, exploring and drawing the data and finding a story.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Early sketches, looking for a data encoding.

The first step was to identify how to present the theme of "differences" in the exhibit. We wanted to draw attention to the fact that the extent to which we can answer questions about biological states depends on how accurate and precise the measurements are. Initially, I thought that this might be a useful theme—highlighting both biological and technical variation.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Early sketches, shaping the data.

In parallel, I thought about different functional sources of variation and the kinds of questions that the data might be used to answer. I narrowed them down to differences that cause disease, differences that cause disease progression and differences that allow for a variety of normal function.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Early sketch, attempting an organic, cellular look.

We also considered the idea of showing differences due to purely experimental error, which are fluctuations due to the technology not necessarily the biology.

single-cell gene expression

For each of the difference scenarios, the input data set were single-cell gene expression counts.

cell1 sample cell_type gene1 count
cell1 sample cell_type gene2 count
...
cell2 sample cell_type gene1 count
cell2 sample cell_type gene2 count
...

Each cell was identified by its sample (e.g. blood normal vs tumor) and type (e.g. B cell, T cell, etc). Typically, we had counts for about 500 genes of 100's or 1000's of cells of a given type and sample.

dimensional reduction

The transcriptome of each cell is a point in high-dimensional space—one dimension for each gene for which we have a count. To find a projection of the data onto the page, we dimensionally reduced the data using tSNE (t-distributed stochastic neighbour embedding) into either 2 or 4 dimensions.

# 2 dimensions (x,y)
cell1 sample cell_type tsne_x tsne_y
cell2 sample cell_type tsne_x tsne_y
...

# 4 dimensions (x,y,u,v)
cell1 sample cell_type tsne_x tsne_y tsne_u tsne_v
cell2 sample cell_type tsne_x tsne_y tsne_u tsne_v
...

When the cells are drawn as points based on their tSNE coordinates, typically they will cluster both by type and disease status. They cluster by type because the gene expression profile for each cell type is different—this is what causes cells to have different function.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Transcripts of the cells in the healthy vs disease data set shown by their 2-dimensional tSNE coordinates. Each point represesents a cell. On the left cells are colored by type and on the right by normal (black) or disease (orange) state. The black dashed lines highlightes the classical monocyte cluster. (zoom)

What we're looking for here is cells that cluster by disease state within a given cell type cluster, like the classical monocytes highlighted in the figure above. What this happens, we can say that there's something fundamentally different for this cell type between the normal and diseased states. For cell types that don't have a differential expression in disease, we see more of a random mixing of the normal and disease cell populations within their clusters.

exploring encodings

I like to start by exploring ways to map the data onto the page. Typically, at this stage I try a lot of different approaches and many take the shortest route to the trash.

The focus of our story is "differences". So, I'll be looking for visuals that capture the Gestalt of a difference. Because we're aiming for an equal mix of art and data visualization, it's not critical that we can judge the differences quantitatively—ability to make qualitative assessments will suffice—but it is important that something obviously appears to be different, both within one panel and across panels.

In the search for an encoding, two basic questions have to be addressed: how cells are to be (a) placed and (b) represented on the page. For example, placement could be systematic, such as on a grid, with order based on some property such as total gene count. With this approach, we can achieve a tiling that covers the full canavs.

Or, placement could be based on properties such as tSNE coordinates. In this case, we settle in not populating the canvas evenly and hope that the cells fall into groups in a meaningful way.

Below is one attempt at a tiling encoding. The cells are represented by a grid of squares and each square shows a comparison of gene counts in disease vs normal for four genes. This layout can be adapted into triangles (3 genes) or hexagons (6 genes).

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Encoding the counts of 4 genes.
BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Comparison of 400 normal vs diseased CD4 cells. (zoom)

The genes can be chosen based on ones that are known to be of clinical significance or, as below, identified from the data set as ones that have the largest change in expression between normal and disease. Cells can be ordered based on similarity in counts between normal and disease.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Comparison of 400 normal vs diseased CD4 cells for (A) genes that had the largest increase in count in disease and (b) genes that had the largest decrease count in disease. The position of the triangle vertex along each square encodes log2 of count ratio. Cells are in decreasing ordered of similarity in counts between normal and disease. (zoom)

I then tried using the 4-dimensional `(x,y,u,v)` tSNE coordinates to represent each cell, still sticking to a tiling of cells. Cells are drawn in a row-dominant order and those with more similar tSNE coordinates are drawn closer together. For example, for the circular encoding, each concentric circle radius is `(x,x+y,x+y+u,x+y+u+v)`.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Cells are represented by a set of concentric circles sized by the cell's 4-dimensional tSNE coordinates. For each coordinate, I tried (A) randomized color palette and (B) Fixed color palette. Optionally, the cell can be sized based on its total gene count. For a given cell, the next cell in the grid is one that has the most similar tSNE coordinates. (zoom)
BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Cells are represented by a set of nested triangles sized by the cell's 4-dimensional tSNE coordinates. For each coordinate, I tried (A) randomized color palette and (B) Fixed color palette. Optionally, (C) the cell can be sized based on its total gene count. For a given cell, the next cell in the grid is one that has the most similar tSNE coordinates. (zoom)

Playing with colors and shapes makes for interesting tilings.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Cells are represented by a set of nested triangles sized by the cell's 4-dimensional tSNE coordinates. For each coordinate, I tried (A) randomized color palette and (B) Fixed color palette. Optionally, (C) the cell can be sized based on its total gene count. For a given cell, the next cell in the grid is one that has the most similar tSNE coordinates. (zoom)

As much as all these attempts have pretty shapes and colors, it's hard to point your finger at any part of these encodings and say, "Here's a difference worth investigating."

As well, by placing cells on a grid makes for a rigid represntation. We agreed that we needed something that looked a little more organic. Could the way the cells were drawn look like actual cells?

clusters, networks and tesselation

We started looking at drawing the cells based on their 2-dimensional tSNE coordinates. In this representation, cells that are closer together on the plane have more similar transcription profiles.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Transcripts of the cells in the healthy vs tumor and in tumor vs metastasis data set shown by their 2-dimensional tSNE coordinates. Each point represesents a cell, color either by cell type (top) or normal, tumor or metastasis state (bottom). (zoom)

With this approach, it was really easy to draw attention to differences—either by cell type (which we wanted to do in the normal function case) or disease status. We also felt that this would be a familiar approach and one that showed populations of cells at the resolution of single cells.

One of the data sets that we identified early was the internal validation set, which captured the variability between operators and technical replication. Below are the results of six experiments, each done by a different operator on two different days. Here, we don't expect (and we don't see) any clustering based on days or operators. In the end, we chose not make use of this data set in the final exhibit and focus instead on clinically relevant differences.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Transcripts of normal cells in a series of internal validation trials performed by different operators on different days. There's no difference in the distribution of cells relative to either operator or day. The clusters that you see are the different cell types. (zoom)

We then explored ways in which the tSNE coordinates could be used to derive different representations, such as a network or tesselation.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Transcripts of the cells in the healthy vs tumor shown by their 2-dimensional tSNE coordinates (left). Nearest normal and tumor cells of a given cell type are connected into a minimum spanning tree graph (right). (zoom)
BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Transcripts of the cells in the healthy vs tumor. Cells are originally placed by tehir 2-dimensional tSNE coordinates and then a Voronoi tesselation is applied to generate polygons that bound the cells (one polygon per cell). The cell positions are then shifted to be closer to the center of each polygon and cell size adjusted to fit within the polygon. (zoom)

By hiding the cells and filling the polygons based on cell type and mixing the neighbouring polygon colors, we get a

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
The Voronoi tesselation 'gems' shown in the figure above with polygon colors based on cell types. Adjacent polygon colors are blended together to provide smoother transition across clusters. The two figures represent two different experiments from the normal vs disease data set. (zoom)

A more organic feel can be achieved by perturbing the edges of both the cells and polygons. We were happy enough with this representation to use it on the introductory panel in the exhibit.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
An organic perturbation to the Voronoi tesselation of the normal vs disease data set. Diseased cells have their polygons and cell shapes filled. (zoom)
BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
An organic perturbation to the Voronoi tesselation of the normal vs disease data set. Diseased cells have their polygons and cell shapes filled. (zoom)

The distance between a given tumor cell and its nearest normal cell of the same type can be emphasized by encoding the distance with color, such as below.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Cells placed based on Voronoi tesselation with polygons hidden. Cell color is either grey (normal) or yellow-red (tumor), where it maps the distance to the nearest normal cell of the same type. (zoom)

At this point we decided to explore mapping this difference by the 3rd dimension, literally.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Cells placed based on Voronoi tesselation with polygons hidden. Image is stereoscopic (requires red-blue 3d glasses) and depth towards the viewer encodes the distance between a tumor cell and its nearest normal neighbour of the same type. (zoom)

The stereoscopic image shown above is a quick prototype generated in Illustrator. The final images were rendered in a full 3D environment using Cinema4D.

VIEW ALL

news + thoughts

Tabular Data

Tue 11-04-2017
Tabulating the number of objects in categories of interest dates back to the earliest records of commerce and population censuses.

After 30 columns, this is our first one without a single figure. Sometimes a table is all you need.

In this column, we discuss nominal categorical data, in which data points are assigned to categories in which there is no implied order. We introduce one-way and two-way tables and the `\chi^2` and Fisher's exact tests.

Altman, N. & Krzywinski, M. (2017) Points of Significance: Tabular data. Nature Methods 14:329–330.

...more about the Points of Significance column

Happy 2017 `\pi` Day—Star Charts, Creatures Once Living and a Poem

Tue 14-03-2017


on a brim of echo,

capsized chamber
drawn into our constellation, and cooling.
—Paolo Marcazzan

Celebrate `\pi` Day (March 14th) with star chart of the digits. The charts draw 40,000 stars generated from the first 12 million digits.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
12,000,000 digits of `\pi` interpreted as a star catalogue. (details)

The 80 constellations are extinct animals and plants. Here you'll find old friends and new stories. Read about how Desmodus is always trying to escape or how Megalodon terrorizes the poor Tecopa! Most constellations have a story.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Find friends and stories among the 80 constellations of extinct animals and plants. Oh look, a Dodo guardings his eggs! (details)

This year I collaborate with Paolo Marcazzan, a Canadian poet, who contributes a poem, Of Black Body, about space and things we might find and lose there.

Check out art from previous years: 2013 `\pi` Day and 2014 `\pi` Day, 2015 `\pi` Day and and 2016 `\pi` Day.

Data in New Dimensions: convergence of art, genomics and bioinformatics

Tue 07-03-2017

Art is science in love.
— E.F. Weisslitz

A behind-the-scenes look at the making of our stereoscopic images which were at display at the AGBT 2017 Conference in February. The art is a creative collaboration with Becton Dickinson and The Linus Group.

Its creation began with the concept of differences and my writeup of the creative and design process focuses on storytelling and how concept of differences is incorporated into the art.

Oh, and this might be a good time to pick up some red-blue 3D glasses.

BD Genomics 3D art exhibit - AGBT 2017 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
A stereoscopic image and its interpretive panel of single-cell transcriptomes of blood cells: diseased versus healthy control.

Interpreting P values

Thu 02-03-2017
A P value measures a sample’s compatibility with a hypothesis, not the truth of the hypothesis.

This month we continue our discussion about `P` values and focus on the fact that `P` value is a probability statement about the observed sample in the context of a hypothesis, not about the hypothesis being tested.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Nature Methods Points of Significance column: Interpreting P values. (read)

Given that we are always interested in making inferences about hypotheses, we discuss how `P` values can be used to do this by way of the Benjamin-Berger bound, `\bar{B}` on the Bayes factor, `B`.

Heuristics such as these are valuable in helping to interpret `P` values, though we stress that `P` values vary from sample to sample and hence many sources of evidence need to be examined before drawing scientific conclusions.

Altman, N. & Krzywinski, M. (2017) Points of Significance: Interpreting P values. Nature Methods 14:213–214.

Background reading

Krzywinski, M. & Altman, N. (2017) Points of significance: P values and the search for significance. Nature Methods 14:3–4.

Krzywinski, M. & Altman, N. (2013) Points of significance: Significance, P values and t–tests. Nature Methods 10:1041–1042.

...more about the Points of Significance column

Snellen Charts—Typography to Really Look at

Sat 18-02-2017

Another collection of typographical posters. These ones really ask you to look.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Snellen charts designed using physical constants, Braille and elemental abundances in the universe and human body.

The charts show a variety of interesting symbols and operators found in science and math. The design is in the style of a Snellen chart and typset with the Rockwell font.

Essentials of Data Visualization—8-part video series

Fri 17-02-2017
Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca

In collaboration with the Phil Poronnik and Kim Bell-Anderson at the University of Sydney, I'm delighted to share with you our 8-part video series project about thinking about drawing data and communicating science.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Essentials of Data Visualization: Thinking about drawing data and communicating science.

We've created 8 videos, each focusing on a different essential idea in data visualization: encoding, shapes, color, uncertainty, design, drawing missing or unobserved data, labels and process.

The videos were designed as teaching materials. Each video comes with a slide deck and exercises.