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
Love itself became the object of her love.Jonathan Safran Foercount sadnessesmore quotes

numbers: beautiful


In Silico Flurries: Computing a world of snow. Scientific American. 23 December 2017


visualization + design

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
The 2018 Pi Day art celebrates the 30th anniversary of `\pi` day and connects friends stitching road maps from around the world. Pack a sandwich and let's go!

`\pi` Day 2014 Art Posters


Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
2018 `\pi` day shrinks the world and celebrates road trips by stitching streets from around the world together. In this version, we look at the boonies, burbs and boutique of `\pi` by drawing progressively denser patches of streets. Let's go places.

Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
2017 `\pi` day

Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
2016 `\pi` approximation day

Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
2016 `\pi` day

Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
2015 `\pi` day

Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
2014 `\pi` approx day

Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
2014 `\pi` day

Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
2013 `\pi` day

Pi Day 2014 Art Poster - Folding the Number Pi
 / Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Circular `\pi` art

On March 14th celebrate `\pi` Day. Hug `\pi`—find a way to do it.

For those who favour `\tau=2\pi` will have to postpone celebrations until July 26th. That's what you get for thinking that `\pi` is wrong.

If you're not into details, you may opt to party on July 22nd, which is `\pi` approximation day (`\pi` ≈ 22/7). It's 20% more accurate that the official `\pi` day!

Finally, if you believe that `\pi = 3`, you should read why `\pi` is not equal to 3.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
All art posters are available for purchase.
I take custom requests.

For the 2014 `\pi` day, two styles of posters are available: folded paths and frequency circles.

The folded paths show `\pi` on a path that maximizes adjacent prime digits and were created using a protein-folding algorithm.

The frequency circles colourfully depict the ratio of digits in groupings of 3 or 6. Oh, look, there's the Feynman Point!

the many paths of `pi`—how to fold numbers

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Pi Day art for 2014 is based on the idea of folding the digits of the number into a path. Here one of the most energetically favourable paths is mapped onto a circle — planet π (zoom)

This year's Pi Day art expands on the work from last year, which showed Pi as colored circles on a grid. For those of you who really liked this minimalist depiction of π , I've created something slightly more complicated, but still stylish: Pi digit frequency circles. These are pretty and easy to understand. If you like random distribution of colors (and circles), these are your thing.

But to take drawing Pi a step further, I've experimented with folding its digits into a path. The method used is the same kind used to simulate protein folding. Research into protein folding is very active — the 3-dimensional structure of proteins is necessary for their function. Understanding how structure is affected by changes to underlying sequence is necessary for identifying how things go wrong in a cell.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Folding a protein in 2-dimensions is a difficult challenge. The problem is NP-complete, even when restricted to a lattice. Simulations are used to search for energetically favourable paths. The ultimate goal is to be able to predict the 3-dimensional structure of proteins from its sequence. Images from Wikipedia. (2d folding, 3d shapes)
Enough with proteins, you're here for the art.

method — folding a number

I will be using the replica exchange Monte Carlo algorithm to create folded paths (download code).

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Folding a number | Digits of a number are assigned to a polar (black) or hydrophobic state (red). We search for a path that maximizes the number of neighbours assigned to the hydrophobic (red) state. In this example, the 64 digit number of 7s and 9s has an energy of -42, indicating the path has 42 pairs of neighbouring 7s.

The choice of mapping between digit (0-9) and state (polar, hydrophobic) is arbitrary. I have chosen to assign the prime digits (2, 3, 5, 7) as hydrophobic. Another way can be to use perfect squares (1, 2, 4, 9). I construct the path by assigning each digit to a path node. One can partition π into two (or more) digit groupings (31, 41, 59, 26, ...) as well.

Want more math + art? Look at 2013 Pi Day art, discover the Accidental Similarity Number and other number art. Find humor in my poster of the first 2,000 4s of Pi.

folding 64 digits of π

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Folding Pi | Prime digits in π (2, 3, 5, 7) are assigned a hydrophobic state. The best path is one that maximizes the number of neighbouring prime digits. The path shown here as E=-23, indicating 23 neighbouring pairs. A color scheme after the Bauhaus style will be used for the art, with a different scheme for white and black backgrounds.

The quality of the path will depend on how hard you look. Each time the folding simulation is run you run the chance of finding a better solution. For the 64 digits of π shown above, I ran the simulation 500 times and found over 200 paths with the same low energy. It's interesting to note that the path with E=-22 was found in <1 second and it took most of the computing time to find the next move.

Below I show 100 paths of 64-digits with E=-23, sorted by their aspect ratio.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
100 lowest energy paths | These are 100 E=-23 64-digit paths — there are many more paths with this energy. The paths are in increasing order of aspect ratio (width/height). First is 6x14 (0.429) and last is 8x9 (0.889). (zoom)

Running the simulation for 64 digits is very practical — it takes only a few minutes. In a sectino below, I show you how to run your own simulation.

folding 768 digits of π — the Feynman Point

Let's fold more digits! How about 768 digits — all the way to "...999999". This is the famous The Feynman Point in π where we see the first set of six 9s in row. This happens surprisingly early — at digit 762. In this sequence there are 298 prime digits with the other 470 being composite.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Folding 768 digits of Pi | The best path I could find of the first 768 digits of π with E=-223 (width=38, height=52, r=0.73, cm=1, cmabs=13). (zoom)

I have chosen not to emphasize the start and end of the path — finding them is part of the fun (You are haven't fun, aren't you?). The end is easier to spot — the 6 9s stand out. Finding the start, on the other hand, is harder.

(d,n) points in π — sequences of repeating digits

The Feynman Point is a specific instance of repeating digits, which I call (d,n) points.

You can read more about these locations, where I have enumerated all such locations in the first 268 million digits of π .

Optimal paths of π up to Feynman Point

Below is a list of the 20 best paths that I've been able to find. They range from E=-223 to E=-219. I annotate each path with a few geometrical properties, such as width, height, area and so on. In some of the art these properties annotate the path (energy x×y r cm,cmabs).

# e     - energy, as positive number
# x,y   - path width and height
# r     - aspect ratio = x/y
# area  - area (x*y)
# cm    - center of mass |(sum(x),sum(y))|/n and |(sum(|x|),sum(|y|))|/n
# dend  - distance between start and end of path
 0 e 223 size  37  51 r 0.725 area  1887 cm    1.9   13.4 dend 24.4
 1 e 222 size  36  44 r 0.818 area  1584 cm   17.3   18.8 dend 10.4
 2 e 221 size  37  50 r 0.740 area  1850 cm    7.6   14.0 dend 16.3
 3 e 221 size  70  36 r 1.944 area  2520 cm    1.0   17.3 dend 30.1
 4 e 221 size  41  55 r 0.745 area  2255 cm   17.9   20.6 dend 29.5
 5 e 221 size  50  49 r 1.020 area  2450 cm   20.8   22.1 dend 34.1
 6 e 221 size  61  35 r 1.743 area  2135 cm   11.4   18.2 dend 15.0
 7 e 221 size  53  45 r 1.178 area  2385 cm   14.7   18.1 dend 18.8
 8 e 221 size  32  52 r 0.615 area  1664 cm   14.0   18.1 dend 33.8
 9 e 220 size  46  70 r 0.657 area  3220 cm   26.6   27.8 dend 27.3
10 e 220 size  55  55 r 1.000 area  3025 cm    5.1   16.8 dend 15.0
11 e 220 size  58  34 r 1.706 area  1972 cm    9.3   14.6 dend 43.4
12 e 220 size  62  50 r 1.240 area  3100 cm   30.6   31.4 dend 33.4
13 e 220 size  41  45 r 0.911 area  1845 cm   15.4   17.6 dend 19.2
14 e 220 size  47  51 r 0.922 area  2397 cm   25.6   26.7 dend 16.0
15 e 220 size  38  52 r 0.731 area  1976 cm   13.1   15.9 dend 23.6
16 e 220 size  57  46 r 1.239 area  2622 cm   20.7   22.7 dend 51.7
17 e 220 size  43  57 r 0.754 area  2451 cm   21.3   23.3 dend 29.6
18 e 219 size  45  45 r 1.000 area  2025 cm   16.5   18.2 dend 33.1
19 e 219 size  51  46 r 1.109 area  2346 cm   16.0   19.2 dend 44.4

As you can see, the dimensions of the paths vary greatly. Low energy paths are not necessarily symmetrical. Paths with a small cm are balanced around their center. Paths with r≈1 are confined in a square boundary. Paths with small dend have their start and end points close to one another.

planet π — path lattice on a circle

The art would not be complete if we didn't somehow try to further force things into a circle! The path lattice is rectangular, but can be deformed into an ellipse or circle using the following transformation

` [(x'),(y')] = [(x sqrt(1-y^2/2)),(y sqrt(1-x^2/2)) ] `

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Deforming the path lattice | A path of π on a square lattice is blasphemous! Here the path is transformed to either an ellipse (preserving the path's aspect ratio) or a circle. So much better.
Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Planet π | Let's go there. The 64-digit path shown here has E=-219. (zoom)
VIEW ALL

news + thoughts

Predicting with confidence and tolerance

Wed 07-11-2018
I abhor averages. I like the individual case. —J.D. Brandeis.

We focus on the important distinction between confidence intervals, typically used to express uncertainty of a sampling statistic such as the mean and, prediction and tolerance intervals, used to make statements about the next value to be drawn from the population.

Confidence intervals provide coverage of a single point—the population mean—with the assurance that the probability of non-coverage is some acceptable value (e.g. 0.05). On the other hand, prediction and tolerance intervals both give information about typical values from the population and the percentage of the population expected to be in the interval. For example, a tolerance interval can be configured to tell us what fraction of sampled values (e.g. 95%) will fall into an interval some fraction of the time (e.g. 95%).

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Nature Methods Points of Significance column: Predicting with confidence and tolerance. (read)

Altman, N. & Krzywinski, M. (2018) Points of significance: Predicting with confidence and tolerance Nature Methods 15:843–844.

Background reading

Krzywinski, M. & Altman, N. (2013) Points of significance: Importance of being uncertain. Nature Methods 10:809–810.

4-day Circos course

Wed 31-10-2018

A 4-day introductory course on genome data parsing and visualization using Circos. Prepared for the Bioinformatics and Genome Analysis course in Institut Pasteur Tunis, Tunis, Tunisia.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Composite of the kinds of images you will learn to make in this course.

Oryza longistaminata genome cake

Mon 24-09-2018

Data visualization should be informative and, where possible, tasty.

Stefan Reuscher from Bioscience and Biotechnology Center at Nagoya University celebrates a publication with a Circos cake.

The cake shows an overview of a de-novo assembled genome of a wild rice species Oryza longistaminata.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Circos cake celebrating Reuscher et al. 2018 publication of the Oryza longistaminata genome.

Optimal experimental design

Tue 31-07-2018
Customize the experiment for the setting instead of adjusting the setting to fit a classical design.

The presence of constraints in experiments, such as sample size restrictions, awkward blocking or disallowed treatment combinations may make using classical designs very difficult or impossible.

Optimal design is a powerful, general purpose alternative for high quality, statistically grounded designs under nonstandard conditions.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Nature Methods Points of Significance column: Optimal experimental design. (read)

We discuss two types of optimal designs (D-optimal and I-optimal) and show how it can be applied to a scenario with sample size and blocking constraints.

Smucker, B., Krzywinski, M. & Altman, N. (2018) Points of significance: Optimal experimental design Nature Methods 15:599–600.

Background reading

Krzywinski, M., Altman, N. (2014) Points of significance: Two factor designs. Nature Methods 11:1187–1188.

Krzywinski, M. & Altman, N. (2014) Points of significance: Analysis of variance (ANOVA) and blocking. Nature Methods 11:699–700.

Krzywinski, M. & Altman, N. (2014) Points of significance: Designing comparative experiments. Nature Methods 11:597–598.

The Whole Earth Cataloguer

Mon 30-07-2018
All the living things.

An illustration of the Tree of Life, showing some of the key branches.

The tree is drawn as a DNA double helix, with bases colored to encode ribosomal RNA genes from various organisms on the tree.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
The circle of life. (read, zoom)

All living things on earth descended from a single organism called LUCA (last universal common ancestor) and inherited LUCA’s genetic code for basic biological functions, such as translating DNA and creating proteins. Constant genetic mutations shuffled and altered this inheritance and added new genetic material—a process that created the diversity of life we see today. The “tree of life” organizes all organisms based on the extent of shuffling and alteration between them. The full tree has millions of branches and every living organism has its own place at one of the leaves in the tree. The simplified tree shown here depicts all three kingdoms of life: bacteria, archaebacteria and eukaryota. For some organisms a grey bar shows when they first appeared in the tree in millions of years (Ma). The double helix winding around the tree encodes highly conserved ribosomal RNA genes from various organisms.

Johnson, H.L. (2018) The Whole Earth Cataloguer, Sactown, Jun/Jul, p. 89

Why we can't give up this odd way of typing

Mon 30-07-2018
All fingers report to home row.

An article about keyboard layouts and the history and persistence of QWERTY.

My Carpalx keyboard optimization software is mentioned along with my World's Most Difficult Layout: TNWMLC. True typing hell.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
TNWMLC requires seriously flexible digits. It’s 87% more difficult than using a standard Qwerty keyboard, according to Martin Krzywinski, who created it (Credit: Ben Nelms). (read)

McDonald, T. (2018) Why we can't give up this odd way of typing, BBC, 25 May 2018.