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
Trance opera—Spente le Stellebe dramaticmore quotes

pi day: exciting


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!

compute your own path

get simulation code

Download the HP lattice simulation binary. You'll need one of the three 2D methods — I used rem2dm, which does local and pull moves. If you'd like to learn more about the algorithm, read the publication.

A replica exchange Monte Carlo algorithm for protein folding in the HP model. Chris Thachuk, Alena Shmygelska and Holger H Hoos, BMC Bioinformatics 2007, 8:342 (17 Sep 2007).

download batch file

Download the batch file for 64- or 768-digit folding.

run simulation

When you run the 64-digit simulation, you're likely to find a path with E=-23, which is the lowest energy I've been able to sample. On my Intel Xeon E5540 (2.53 GHz) it takes anywhere from 1-30 seconds to find a E=-23 path (there are many possible paths at this energy), depending on the random seed. Here's the output of a typical run of the 64-digit folding simulation

> rem2dm -seq=hppphphphhhpphphhhppphpphhphhhphphppppphppphpphhhpphphpphpppphph
         -maxT=220 -numLocalSteps=500 -eng=100 -maxRunTime=60 -traceFile=pi.64 
         -minT=160 -expID=pi.64 -numReps=10 

REMC-HP2D-M

Begin Simulation
0.01: Current Best Solution: -8
0.01: Current Best Solution: -10
0.01: Current Best Solution: -13
0.02: Current Best Solution: -15
0.03: Current Best Solution: -16
0.03: Current Best Solution: -17
0.04: Current Best Solution: -18
0.04: Current Best Solution: -19
0.16: Current Best Solution: -20
0.27: Current Best Solution: -21
0.69: Current Best Solution: -22
36.23: Current Best Solution: -23
Real time: 120

ggslrrsrllssrrlrrllsrrlrrlslslrrsrlssrrsllrslrrlrsllsrsrrlsrssrs

         p--h--p         
         |     |           
         h--h  h--p--p--p
            |           |  
   p--p     h  H  h--p--p
   |  |     |  |  |        
p--h  h--h--p  p  p--p   
|              |     |     
p--p--h  h--p  p--p  p   
      |  |  |     |  |     
   h--h  h  h--p--h  h--p
   |     |              |  
   p--h  h  h--p--H  h--p
      |  |  |        |     
      p--p  p  p--h--h   
            |  |           
            p  p--h--p   
            |        |     
            p--p--h  h   
                  |  |     
                  p--p   

End Simulation

If you want to apply this to different number (e.g. φ or e ), you'll need to replace the digits with either p or h. Remember, the simulation will try to group the h's together. You can download 1,000,000 of π , φ and e .

The best path I could find for 768 digits is one with E=-223. In 1000s of simulations this solution came up only once. I also saw one path at E=-222. After that, there were many solutions at each of the less optimal energy levels.

If you manage to find a better one, let me know right away!

common problems

segmental fault

If you obtain a segmentation fault,

> ./rem2dlm
REMC-HP2D-LM

Begin Simulation
Real time: 0



Segmentation fault

don't panic just yet. The folding binaries don't do a lot of error checking, so you have to get the input parameters correct.

For example, if you do not include the -eng parameter, the code will segfault.

Try one of the batch files above (64 digit batch file, 768 digit batch file) or the following simple job

> bin/rem2dm -seq=hhpppphhhhpppphh -maxRunTime=5 -eng 10 
REMC-HP2D-M

Begin Simulation
3.13877e-17: Current Best Solution: -2
5.49284e-17: Current Best Solution: -3
1.0201e-16: Current Best Solution: -4
1.33398e-16: Current Best Solution: -5
Real time: 5

ggrllslsssrllsls
            
   p--p--p
   |     |  
   h  h--p
   |  |     
   H  h   
      |     
   H  h   
   |  |     
p--h  h   
|     |     
p--p--p   

If this segfaults, then you'll need to recompile the code (see below).

compile code (optional—only if binaries don't work)

Precompiled binaries are available for download directly: rem2dm, rem2dlm, rem2dpm, rem3dm, rem3dlm, rem3dpm.

If these don't work on your system, you need to recompile them. Download the the protein folding code and see INSTALL.txt for compilation instructions.

VIEW ALL

news + thoughts

Statistics vs Machine Learning

Tue 03-04-2018
We conclude our series on Machine Learning with a comparison of two approaches: classical statistical inference and machine learning. The boundary between them is subject to debate, but important generalizations can be made.

Inference creates a mathematical model of the datageneration process to formalize understanding or test a hypothesis about how the system behaves. Prediction aims at forecasting unobserved outcomes or future behavior. Typically we want to do both and know how biological processes work and what will happen next. Inference and ML are complementary in pointing us to biologically meaningful conclusions.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Nature Methods Points of Significance column: Statistics vs machine learning. (read)

Statistics asks us to choose a model that incorporates our knowledge of the system, and ML requires us to choose a predictive algorithm by relying on its empirical capabilities. Justification for an inference model typically rests on whether we feel it adequately captures the essence of the system. The choice of pattern-learning algorithms often depends on measures of past performance in similar scenarios.

Bzdok, D., Krzywinski, M. & Altman, N. (2018) Points of Significance: Statistics vs machine learning. Nature Methods 15:233–234.

Background reading

Bzdok, D., Krzywinski, M. & Altman, N. (2017) Points of Significance: Machine learning: a primer. Nature Methods 14:1119–1120.

Bzdok, D., Krzywinski, M. & Altman, N. (2017) Points of Significance: Machine learning: supervised methods. Nature Methods 15:5–6.

...more about the Points of Significance column

Happy 2018 `\pi` Day—Boonies, burbs and boutiques of `\pi`

Wed 14-03-2018

Celebrate `\pi` Day (March 14th) and go to brand new places. Together with Jake Lever, this year we shrink the world and play with road maps.

Streets are seamlessly streets from across the world. Finally, a halva shop on the same block!

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
A great 10 km run loop between Istanbul, Copenhagen, San Francisco and Dublin. Stop off for halva, smørrebrød, espresso and a Guinness on the way. (details)

Intriguing and personal patterns of urban development for each city appear in the Boonies, Burbs and Boutiques series.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
In the Boonies, Burbs and Boutiques of `\pi` we draw progressively denser patches using the digit sequence 159 to inform density. (details)

No color—just lines. Lines from Marrakesh, Prague, Istanbul, Nice and other destinations for the mind and the heart.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Roads from cities rearranged according to the digits of `\pi`. (details)

The art is featured in the Pi City on the Scientific American SA Visual blog.

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

Machine learning: supervised methods (SVM & kNN)

Thu 18-01-2018
Supervised learning algorithms extract general principles from observed examples guided by a specific prediction objective.

We examine two very common supervised machine learning methods: linear support vector machines (SVM) and k-nearest neighbors (kNN).

SVM is often less computationally demanding than kNN and is easier to interpret, but it can identify only a limited set of patterns. On the other hand, kNN can find very complex patterns, but its output is more challenging to interpret.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Nature Methods Points of Significance column: Machine learning: supervised methods (SVM & kNN). (read)

We illustrate SVM using a data set in which points fall into two categories, which are separated in SVM by a straight line "margin". SVM can be tuned using a parameter that influences the width and location of the margin, permitting points to fall within the margin or on the wrong side of the margin. We then show how kNN relaxes explicit boundary definitions, such as the straight line in SVM, and how kNN too can be tuned to create more robust classification.

Bzdok, D., Krzywinski, M. & Altman, N. (2018) Points of Significance: Machine learning: a primer. Nature Methods 15:5–6.

Background reading

Bzdok, D., Krzywinski, M. & Altman, N. (2017) Points of Significance: Machine learning: a primer. Nature Methods 14:1119–1120.

...more about the Points of Significance column

Human Versus Machine

Tue 16-01-2018
Balancing subjective design with objective optimization.

In a Nature graphics blog article, I present my process behind designing the stark black-and-white Nature 10 cover.

Nature 10, 18 December 2017

Machine learning: a primer

Thu 18-01-2018
Machine learning extracts patterns from data without explicit instructions.

In this primer, we focus on essential ML principles— a modeling strategy to let the data speak for themselves, to the extent possible.

The benefits of ML arise from its use of a large number of tuning parameters or weights, which control the algorithm’s complexity and are estimated from the data using numerical optimization. Often ML algorithms are motivated by heuristics such as models of interacting neurons or natural evolution—even if the underlying mechanism of the biological system being studied is substantially different. The utility of ML algorithms is typically assessed empirically by how well extracted patterns generalize to new observations.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
Nature Methods Points of Significance column: Machine learning: a primer. (read)

We present a data scenario in which we fit to a model with 5 predictors using polynomials and show what to expect from ML when noise and sample size vary. We also demonstrate the consequences of excluding an important predictor or including a spurious one.

Bzdok, D., Krzywinski, M. & Altman, N. (2017) Points of Significance: Machine learning: a primer. Nature Methods 14:1119–1120.

...more about the Points of Significance column

Snowflake simulation

Tue 16-01-2018
Symmetric, beautiful and unique.

Just in time for the season, I've simulated a snow-pile of snowflakes based on the Gravner-Griffeath model.

Martin Krzywinski @MKrzywinski mkweb.bcgsc.ca
A few of the beautiful snowflakes generated by the Gravner-Griffeath model. (explore)

The work is described as a wintertime tale in In Silico Flurries: Computing a world of snow and co-authored with Jake Lever in the Scientific American SA Blog.

Gravner, J. & Griffeath, D. (2007) Modeling Snow Crystal Growth II: A mesoscopic lattice map with plausible dynamics.