Molecular mapping

Analysis › DNA-PAINT · version 2

Turns clusters into molecules: one per cluster at its centre (RESI),

What it does

In DNA-PAINT every binding site is localized again and again: each time an imager strand binds, the site gives a few localizations, and over the acquisition it gives tens to hundreds, scattered about the site by the localization precision. Molecular mapping turns these clouds into molecules: one position per site, much more precise than any single localization.

It works on clusters, an id attribute that Find clusters writes (cluster_id), and has two methods:

Both are ported from Picasso, the Jungmann lab's DNA-PAINT software.

The molecules come out as a new file, a molecule per row, with its position, the precision of it (xy_err_nm), its localizations and binding events: they render, filter and measure like localizations, so Spatial statistics, SPINNA or Register layers (for RESI's imaging rounds) run on them. Or, with output set to the localizations, each localization gets its molecule's number, molecule_id, so Binding kinetics or Id statistics can measure each molecule.

It reads the localizations, not merged blinks, whatever the layer shows, and only those the layer's filter and ROI keep. G5M needs each localization's precision (xy_err_nm, and z_err_nm in 3D); the centres do not.

How it works

Centres

1. One cluster, one molecule. The molecule is the mean of the cluster's localizations.

2. Its precision. The standard deviation of the localizations about that mean, divided by the square root of their number: 50 localizations at 3 nm give a molecule known to about 0.4 nm.

3. Its binding events. The cluster's localizations split wherever more than 3 frames pass without one. A real site binds many times over the acquisition; a cluster of one or two events is suspect.

G5M

1. A mixture of Gaussians. Inside each cluster the localizations are modelled as the sum of a few round Gaussian clouds, one per molecule, each with its own centre, width and share of the localizations. The model is fitted by expectation maximisation, from several starting points chosen by k-means++ (seeded, so a run gives the same answer every time).

2. Clouds as wide as the precision. At every step a cloud's width is held between 0.8 and 1.5 times the precision of the localizations it explains. A cloud cannot grow to cover two sites, nor shrink onto a few localizations. This is what stops the mixture from inventing molecules or merging them.

3. Molecules that can be told apart. A model is refused when two of its clouds overlap so much that their summed density has no dip between them (the Sparrow criterion): two molecules closer than that are one. A cloud with fewer than minimum size localizations is not a molecule.

4. How many. One molecule, then two, then three ... are fitted, and the number with the lowest BIC (Bayesian information criterion: the fit's likelihood, penalised for every parameter added) is kept. The search stops after three numbers in a row without a better BIC.

5. Each molecule gets its position and its precision, its width, its localizations and binding events, the spread of its frames over the acquisition, and a p-value (below). Picasso's filter, on by default, drops molecules whose frames spread over less than a tenth of the acquisition (a sticky imager), with a p-value of 0.015 or less, or with 3 binding events or fewer.

A simulated DNA origami: 12 sites on a 20 nm grid, 3 nm localization precision (left, a colour per localization's site, the sites as black crosses). DBSCAN with a 10 nm radius makes it one cluster; G5M finds 12 molecules in it (right, coloured by molecule, the molecules as crosses), each within a nanometre or two of a true site.

How close two molecules can be. Two sites of 100 localizations each at 3 nm precision, 12 simulations at each separation: G5M finds both from about 7 nm on, a little more than twice the precision – the separation at which two such clouds first show a dip between them (dashed) – and below that calls them one.

In detail

Centres

For a cluster of localizations , the molecule is and its precision per axis is , with the standard deviation (divided by ). xy_err_nm of the molecule is the mean of the x and y values. The frame written is the mean frame of its localizations, rounded; mean_frame and std_frame are the mean and standard deviation of the frames.

G5M

The model. In 2D each component is a round Gaussian of variance with weight and centre ; in 3D it has one variance in x and y and another in z. The expectation-maximisation step computes each localization's responsibilities and then , and as their weighted means. The width is then clipped,

the localization's precision – in 3D separately for the plane and for z. Each number of components is fitted from starts, k-means++ with seeds 42, 43, ..., at most 100 iterations, stopping when the mean log-likelihood changes by less than . The start with the highest likelihood whose components pass the Sparrow test is kept; a component with localizations ( the minimum size) is dropped from it.

The Sparrow test. For every pair of kept components, their weighted densities summed are sampled at 40 points along the line between the centres; there must be a dip.

BIC. With the log-likelihood of the localizations under the kept components and their parameters (2 or 3 for the centre, 1 or 2 for the widths, and the weights less one),

runs from 1 to and stops after 3 values without a lower BIC. A cluster with more than largest cluster localizations is passed over.

Per molecule. The precision of the centre is , Picasso's approximation, which treats each molecule on its own; its bootstrap is not ported. sigma_rel is the width over . The binding events are the cluster's localizations split at gaps of more than 3 frames, each event's mean position given to the most likely molecule. mean_frame and std_frame are responsibility-weighted.

The p-value. A molecule's localizations' responsibility-weighted mean log-likelihood, compared with what draws from that component would give,

the dimensions and its covariance, as a normal cumulative probability. Where the fitted width is free, the two are equal and the p-value is 0.5. It moves only where the width is held at a bound: a cloud wider than 1.5 precisions – two molecules taken for one, or no molecule at all – gets a p-value near 0, which the filter drops.

Where it departs from Picasso. The algorithm is Picasso's, with its constants. It is written with numpy instead of numba, every start of a component count fitted at once. In 3D the widths are held to the precisions along each axis, where Picasso takes the shape of an astigmatic spot from its z calibration. And the Sparrow test also counts a dip with a flat bottom, which two equal molecules give with an even number of samples and Picasso's test misses.

Speed. About 0.3 s for a 12-site origami of 600 localizations on four cores; a run expected to take more than 20 s asks first. Clusters of one site each, from local maxima, are much faster.

Parameters

settingdefaultwhat it does
method
method
centres (RESI)Centres: one molecule per cluster; G5M: the molecules in each cluster, by a Gaussian mixture.

Centres when every cluster is one site – Find clusters with local maxima and a radius of about twice the precision. G5M when a cluster can hold several, or to check that it does not.

Choices: centres (RESI); G5M
clusters
id_column
autoThe id attribute naming the clusters; auto: cluster_id.

Any id attribute whose regions are clusters of localizations; auto is cluster_id.

output
output
a file of moleculesThe molecules as a new file, or each localization's molecule.

The file is what the rest of the analysis reads. molecule_id on the localizations is for measuring each molecule's own localizations – its binding kinetics, its time trace. Both runs find the same molecules, numbered alike.

Choices: a file of molecules; molecule_id on the localizations
in 3D
use_z
onX, y and z when the table has z_nm.

Off maps in x and y only, which merges molecules above one another.

G5M
   minimum size
   g5m.min_locs
10Localizations a molecule has at least.

Below the localizations a site gives over the acquisition and above what the background gathers in a cluster. Picasso's default is 10.

at least 2
   width
   g5m.sigma_min
0.8A molecule's width at least this many times its localizations' precision.

Picasso's 0.8. Higher refuses molecules that are narrower than the precision says – a precision that is overestimated.

at least 0.05
   to
   g5m.sigma_max
1.5And at most this many times.

Picasso's 1.5. Higher accepts clouds widened by residual drift or a linker, and with them pairs of molecules taken for one. The localization precision must be right for G5M to be: correct drift well before.

at least 0.05
   rounds without improvement (more)
   g5m.max_rounds
3Molecules added one by one stop after this many without a better BIC.

More tries more molecules past the best before giving up: slower, and rarely different.

at least 1
   largest cluster (more)
   g5m.max_locs
autoA cluster with more localizations is passed over (a bead); empty: none.

A bead or a sticky spot gives thousands of localizations in one cluster, and costs most of a run.

at least 1
   Picasso's filter
   g5m.filter
onDrop sticky molecules, bad fits and those with few binding events.

Off keeps every molecule G5M found, with its p_val, n_events and std_frame to filter by hand.

   frame spread (more)
   g5m.min_std_frame
0.1A molecule's frames' standard deviation at least this fraction of the acquisition.

A site visited at random through the acquisition has frames spread over about 0.29 of it (a uniform distribution's standard deviation); one that bound for a short while, much less.

0 to 1
   p-value (more)
   g5m.min_p
0.015A molecule's p_val above this.

Raise it to drop more of the molecules whose width hit the upper bound.

0 to 1
   binding events (more)
   g5m.min_events
3A molecule's n_events above this.

Short acquisitions with few binding events per site need a lower value.

Output

References