Modified Pearson correlation coefficient for two-color imaging in spherocylindrical cells

The revolution in fluorescence microscopy enables sub-diffraction-limit (“superresolution”) localization of hundreds or thousands of copies of two differently labeled proteins in the same live cell. In typical experiments, fluorescence from the entire three-dimensional (3D) cell body is projected along the z-axis of the microscope to form a 2D image at the camera plane. For imaging of two different species, here denoted “red” and “green”, a significant biological question is the extent to which the red and green spatial distributions are positively correlated, anti-correlated, or uncorrelated. A commonly used statistic for assessing the degree of linear correlation between two image matrices R and G is the Pearson Correlation Coefficient (PCC). PCC should vary from − 1 (perfect anti-correlation) to 0 (no linear correlation) to + 1 (perfect positive correlation). However, in the special case of spherocylindrical bacterial cells such as E. coli or B. subtilis, we show that the PCC fails both qualitatively and quantitatively. PCC returns the same + 1 value for 2D projections of distributions that are either perfectly correlated in 3D or completely uncorrelated in 3D. The PCC also systematically underestimates the degree of anti-correlation between the projections of two perfectly anti-correlated 3D distributions. The problem is that the projection of a random spatial distribution within the 3D spherocylinder is non-random in 2D, whereas PCC compares every matrix element of R or G with the constant mean value \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$ \overline{R} $$\end{document}R¯ or \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$ \overline{G} $$\end{document}G¯. We propose a modified Pearson Correlation Coefficient (MPCC) that corrects this problem for spherocylindrical cell geometry by using the proper reference matrix for comparison with R and G. Correct behavior of MPCC is confirmed for a variety of numerical simulations and on experimental distributions of HU and RNA polymerase in live E. coli cells. The MPCC concept should be generalizable to other cell shapes. Electronic supplementary material The online version of this article (10.1186/s12859-018-2444-3) contains supplementary material, which is available to authorized users.


Background
In widefield and superresolution fluorescence microscopy of eukaryotic and prokaryotic cells, the fluorescent species occupy a three-dimensional (3D) volume. In typical usage, the laser illuminates the entire thickness of the cell ("epi illumination"). The microscope then projects fluorescence from a 3D source along the z axis to form a two-dimensional (2D) image at the xy camera plane. For two-color imaging of two different species, herein called the "red species" and the "green species", an important biological question is the degree to which the red and green spatial distributions are positively correlated, anti-correlated, or uncorrelated with each other. Positive correlation may suggest binding to each other or to a common cytoplasmic element such as a membrane or the chromosomal DNA. It may also suggest common sites of production, action, or degradation. Negative correlation may suggest a physical or biochemical mechanism that sequesters red and green species from each other [1,2]. A number of different procedures for assessing co-localization between two images are described in a recent review [3].
For super-resolution images, a family of point pattern analysis methods evaluates the spatial co-distribution of points on very short (sub-100 nm) length scales. These include Ripley's K test [4][5][6] and a variety of cross-correlation methods [7][8][9][10]. These procedures provide a function of r (the inter-particle separation distance) that describes the spatial distribution of red and green molecules with respect to each other. Such methods take advantage of the sub-pixel accuracy and allow determination of whether the red and green proteins are dispersed, clustered, or randomly distributed within the region of interest. The data density must be commensurate with the length scale of interest, i.e., high data density is required to obtain information on the sub-100 nm scale.
For some time now, we have been interested in the degree to which ribosomes and the chromosomal DNA are spatially segregated from each other on a length scale of 200 nm and longer in E. coli bacterial cells growing exponentially under different conditions [11,12]. The cells are spherocylindrical, typically of length 3-5 μm and diameter~1 μm or smaller. In rapidly growing cells, the chromosomal DNA has segregated into two nucleoid lobes that interleave three ribosome-rich regions [11], each of whose size is of the order of 0.5-1.0 μm. For this problem, sub-pixel resolution is not needed. In small bacterial cells, the coordinate based cross-correlation methods provide readily interpretable information only for r substantially smaller than the shortest cell dimension. Accordingly, we have chosen to use superresolution imaging to minimize the blurring inherent in widefield microscopy. We subsequently pixelate the red and green images and calculate a modification of the Pearson correlation coefficient (PCC) that returns a single number in the range + 1.0 to − 1.0 that measures the degree of linear correlation or anti-correlation between red and green images, averaged over the entire cell.
As described in detail below, all correlation quantification methods have limitations in the common case of 2D images projected from the 3D spatial distributions of fluorophores emitting from small bacterial cells. A reference distribution that is random in 3D within the cell boundaries produces a non-uniform 2D spatial distribution when projected onto the camera plane. Moerner and co-workers have recently applied Ripley's K to characterize the clustering of HU proteins in the crescent-shaped bacteria C. crescentus and corrected the reference random distribution by methods similar to those we employ here [13]. Here we describe a detailed procedure for handling the same problem in estimates of the Pearson correlation coefficient in the case of spherocylindrical cells like E. coli and B. subtilis.
The Pearson correlation coefficient (PCC) [14,15] is one of the most commonly used statistical tools to measure the degree of linear correlation in pixel-by-pixel intensity between two data sets X and Y: Here (x i , y i ) are individual paired samples from the data sets X and Y and n is the total number of pairs; x and y are the mean values of the samples in data sets X and Y. With the advent of two-color superresolution fluorescence microscopy, the PCC is increasingly used as a statistic for quantifying the degree of correlation between the subcellular distributions of two distinguishable species. For image matrices R (red channel) and G (green channel), the formula for PCC becomes: Here m and n are the number of rows and columns in the image matrices; there are m x n total pixels in each image. The R ij and G ij are the corresponding intensities of pixel ij in R and G; for superresolution images these are integers (counts/pixel). R and G are the mean pixel intensities of R and G. In the PCC formula, all elements of the reference matrix with which R or G is compared have the same value. The value R (or G ) is subtracted from each individual pixel intensity R ij (or G ij ), yielding both positive and negative difference intensities ðR ij −RÞ and ðG ij −GÞ . Thus, the product in the PCC numerator provides information about the correlation between deviations of R ij from R and deviations of G ij from G. The denominator normalizes PCC so that it always lies in the range − 1 to + 1. Ideally, PCC = 1 indicates two perfectly linearly correlated images for which each red pixel ij deviates from the red mean in direct proportion to the deviation of the corresponding green pixel ij from the green mean. PCC = 0 indicates two linearly uncorrelated images. PCC = − 1 indicates two perfectly anti-correlated images (red and green deviations of equal magnitude but of opposite sign). A PCC value significantly different from zero is a measure of the degree to which two distributions are correlated or anti-correlated as compared with the null hypothesis of PCC = 0, corresponding to two uncorrelated, random distributions.
The ImageJ software [16] extensively used for image analysis in the field of fluorescence microscopy provides Coloc2 and JaCoP plugins [17] that enable the user to calculate PCC between two images. In the recent literature, PCC has been used to characterize the correlation in 2D spatial distributions of two fluorescently labeled proteins in both bacterial cells [18][19][20] and eukaryotic cells [21][22][23][24][25][26][27].
McDonald and co-workers recently catalogued some common pitfalls in the use of PCC on eukaryotic cells [23].
For the most common shapes of bacteria (spherical, rod-shaped and spiral), the standard PCC procedure applied to 2D projected images fails both qualitatively and quantitatively. We specialize to small, rod-shaped, approximately spherocylindrical bacterial cells such as E. coli and B. subtilis, whose typical length is L cell4 μm and whose diameter is 2r~1 μm. Spherocylinders have strong curvature at the two endcaps and in the cylindrical region. As a result, the projection of molecules randomly distributed in a 3D spherocylindrical volume does not form a random distribution in 2D. In Fig. 1, we illustrate the 2D projection of 5000 molecules that are distributed randomly in a 3D spherocylinder with dimensions similar to that of an E. coli cell in good growth conditions. The endcap regions and the edges of the spherocylinder project a smaller volume onto the camera plane, and thus have fewer counts/pixel in the 2D image than the central cylindrical region. This effect is clear in the pixelated 2D localization density maps shown in Fig. 1c-e. Pixels in the 2D projection of a random 3D distribution vary in intensity by a factor of five or more, depending on the chosen pixel size. The variations are highly systematic.
Consequently, the PCC reference matrix used for comparison with R and G is inappropriate. The PCC difference intensities ðR ij −RÞ and ðG ij −GÞ for pixels at the edges and end caps are systematically negative, i.e., strongly biased towards having fewer molecules/pixel than the mean value in a 2D projection of a 3D random distribution. In those regions, the products ðR ij −RÞðG ij − GÞ are systematically positive. Similarly, the difference intensities of the pixels in the central region of the spherocylinder are systematically positive, strongly biased towards having more molecules/pixel than the mean of a projection of a 3D random distribution. In that region, the products ðR ij −RÞðG ij −GÞ are again systematically positive. For two uncorrelated, random distributions in 3D, this causes the traditional PCC of the 2D projection to incorrectly approach + 1, not the desired result of zero. The same systematic positive bias causes the traditional PCC to underestimate the degree of anti-correlation between two perfectly anti-correlated images, as we will show.
In the following sections, we describe a procedure for calculating what we call the modified Pearson correlation coefficient (MPCC) in the special case of interest, spherocylindrical bacterial cells. The procedure could prove useful for both widefield and superresolution images, and in principle it could be adapted to other cell shapes [3]. We use numerical simulations to show that MPCC properly approaches zero for random sampling from two uncorrelated, random distributions, approaches − 1 for sampling from two perfectly anti-correlated distributions, and approaches + 1 for sampling from two perfectly correlated distributions. We also provide guidance for pixelation of superresolution images and show how to determine the probability p that a measured non-zero MPCC did not arise from two uncorrelated, random 3D distributions. We conclude with an experimental example of a significantly positive MPCC between

The modified Pearson correlation coefficient MPCC
The MPCC of two images R and G is evaluated as follows: Here we have replaced R and G in Eq. 2 with the modified reference matricesŨ R ij andŨ G ij , respectively. U R ij andŨ G ij denote the intensity of pixel ij in the 2D projection of a large set of molecules distributed randomly in a 3D spherocylinder. The total number of molecules inŨ R andŨ G has been scaled to be the same as the total number of molecules in R and G, respectively. In favorable conditions, superresolution imaging provides (x,y) spatial localization of hundreds or thousands of molecules per cell with spatial resolution of σ x,y~2 0-50 nm. Conversion of these single molecule locations into 2D probability density maps requires selection of a pixel size; several examples are shown in Fig. 1c-e. The intensity in each pixel equals the total number of molecules assigned to it. The dependence of the calculated MPCC on the chosen pixel size and the number of imaged molecules is described later. These pixelated 2D maps for the red and green channels are denoted by R and G, the image matrices in Eq. 3.
To form the numerator of Eq. 3, we then subtractŨ R andŨ G from the corresponding image matrix in the red and green channels (R and G, respectively) to obtain the (unnormalized) difference matrices Δ R and Δ G . The resultant difference matrices have pixels with positive and negative values. Finally, to constrain MPCC to lie in the range + 1 to − 1, we normalize Δ R and Δ G so that the sum of the squares of individual pixel values in the difference matrix is 1. The resultant normalized 2D difference matrices are calledΔ R andΔ G respectively. MPCC is obtained by taking the Frobenius inner product of the two normalized matricesΔ R andΔ G (Eq. 6 in Methods).
A detailed step-by-step description of the methodology for obtaining MPCC is presented in the Methods section.
The MPCC ranges from + 1 to − 1, as does standard PCC. The MPCC for two images is + 1 when the normalized difference matrices are perfectly linearly related, i.e., whenΔ R ij ¼Δ G ij for every pixel ij. As a result, MPCC is − 1 when the normalized difference matrices are perfectly inversely related to each other, i.e.,Δ When the normalized difference matrices of two images are uncorrelated with each other, the MPCC is 0.
Next, we carry out numerical simulations comparing MPCC with PCC for sampling from 2D projections of three model distributions in 3D spherocylinders: perfect 3D correlation that projects into perfect 2D correlation, perfect 3D anti-correlation that projects into perfect 2D anti-correlation, and uncorrelated, random 3D distributions. For all these examples, the R and G image matrices have 10,000 molecules each. The spherocylinder has tip-to-tip length L cell = 3.5 μm and diameter 2r = 0.82 μm. The 2D pixel size in the image matrices R and G is chosen to be 200 nm in both dimensions, so that 75 pixels cover the 2D projection.

Perfect anti-correlation in 3D
To examine the case of two perfectly anti-correlated distributions, we have simulated 3D random distributions of 20,000 molecules confined to the spherocylindrical volume. The~10,000 molecules located in the left half of the spherocylinder are designated red; the~10,000 molecules located in the right half are designated green. This ensures that there is no spatial overlap of molecules in the red and green channels. We call this anti-correlation Case I. For such strong spatial anti-correlation, we should expect MPCC = − 1. An example of the corresponding 2D image matrices R and G is shown in Fig. 2a. In Fig. 2b, c, we have compared the reference matrices and the key normalized difference matrices the products of whose corresponding elements enter the traditional PCC (Eq. 2) and the new MPCC (Eq. 3).
For the traditional PCC (Fig. 2b), there are~10,000 molecules of each color distributed in a cell area covering 75 pixels. As in Eq. 2, we subtract the mean pixel intensity R = 133.3 and G = 133.3 from each individual pixel intensities R ij and G ij . The resulting normalized difference matrices, In the left half of the spherocylinder, the red difference matrix has a thin shell of systematically negative values (endcap and edge pixels) and a central core of systematically positive values. When multiplied by the corresponding elements of the left half of the green difference matrix, which contains all equal negative elements, the contributions to PCC will be positive and negative, respectively. The same type of systematically positive and negative contributions will arise from the right half of the spherocylinder. The resulting red and green contributions to PCC are not linearly anti-correlated. This is seen clearly in Fig. 2d, where we show a scatter plot of the individual red normalized differences vs the corresponding green normalized differences. The net result is PCC = − 0.47, suggesting only partial anti-correlation of the two spatial distributions even though they are completely anti-correlated in both 3D and 2D. In contrast, the MPCC formula of Eq. 3 subtracts from each pixel the proper 2D contribution of the projection of a smooth 3D random distribution (Fig. 2c). The resulting normalized difference matricesΔ R andΔ G are also depicted in Fig. 2c. The scatter plot of individual difference matrix Fig. 2d shows the expected strong linear anti-correlation for all pixels. The resulting MPCC is − 0.99, very close to the expected value of − 1.
In Additional file 1: SI Text S1, we examine two additional examples of anti-correlation. In anti-correlation Case II shown in Additional file 1: Figure S1, the two endcap regions are occupied by~10,000 red molecules and the central region is occupied by~10,000 green molecules. Again, the normalized difference matrix elements are linearly anti-correlated and the calculated MPCC is − 0.99. In anti-correlation Case III (Additional file 1: Figure S1), the~10,000 red molecules occupy the leftmost 2/3 of the spherocylinder volume while the~10,000 green molecules occupy the rightmost 1/3. The result is the same. The advantages of MPCC vs traditional PCC are apparent.

Perfect positive correlation in 3D and 2D
When the red and green 3D spatial distributions are perfectly positively correlated, so will be their 2D projections. As described before, an MPCC value of + 1 is expected for a case of perfect correlation in the 2D projections. The same is true of the traditional PCC. To examine the case of two perfectly correlated distributions, we have simulated 3D random distributions of 20,000 molecules confined to the spherocylindrical volume. The~10,000 molecules located in the left half of the spherocylinder are designated red; the molecules in the right half are deleted. We then independently simulated another 20,000 molecules distributed randomly in a 3D spherocylinder. The~10,000 molecules located in the left half of the spherocylinder are designated green; the molecules in the right half are again deleted. The resulting 3D distributions are projected into 2D and pixelated to yield the image matrices depicted in Additional file 1: Figure S2A. We calculate the MPCC = + 0.99 between these two distributions, very close to the anticipated value of + 1. The resulting normalized differ- If R ij = G ij and R ¼ G, then PCC = 1. Therefore, for two spatial distributions that are perfectly correlated in 3D and in the 2D projection, both the MPCC and the PCC will approach + 1 within the statistical noise.

Random distributions in 3D
Two independent, uncorrelated, random distributions should have a Pearson correlation coefficient of 0 within the statistical noise. In the numerical tests, we have randomly distributed 10,000 red molecules and 10,000 green molecules in 3D within the spherocylinder. The two random distributions are generated independently, so we expect them to be uncorrelated with each other. We add appropriate localization errors σ R = 50 nm and σ G = 50 nm and then project the "measured" positions into the xy-plane. PCC and MPCC between the two 2D projection matrices (Fig. 3a) will be compared.
The resulting reference matrices and normalized difference matrices for PCC and for MPCC are depicted in Fig. 3b and c respectively. The scatter plots ofΔ R ij vsΔ G ij for MPCC and of their analogues for PCC are shown in Fig. 3d. The data indeed appear uncorrelated for MPCC, but they are strongly positively correlated for PCC. The resulting calculated coefficients are MPCC = + 0.10 and PCC = + 0.98. The cause of the large, positive PCC value between two random 3D distributions was described in the Introduction. The 2D projections have matching regions of systematically positive and systematically negative deviations from the 2D mean values.
Finally, we tested whether the distribution of calculated MPCC outcomes for two independent random distributions is appropriately centered at zero and unbiased towards positive or negative values. For 200 trials, we calculated MPCC values between two 2D projections of 3D independent, random distributions of 10,000 red and 10,000 green molecules using the same 200 nm pixel size. We fit the resulting distribution (Additional file 1: Figure S3) to a Gaussian function. The mean of the best-fit Gaussian distribution is <MPCC> = + 0.0041 and the standard error is σ MPCC = 0.13. The mean is close to zero and the distribution is symmetric about zero, as hoped for. The probability that a particular trial would yield an MPCC of magnitude 0.10 or larger on either side of the Gaussian distribution is p = 0.44. The "measured" example MPCC of + 0.10 (Fig. 3d) lies within 1σ of the mean; it was not a particularly unusual event.
Dependence of MPCC and its uncertainty on pixel size and total number of imaged molecules Before evaluating MPCC between two superresolution images, the pixel size in the 2D localization density maps must be chosen. For a fixed cell size and number of detected molecules, the smaller the pixel size, the greater will be the total number of pixels N p , the better the spatial resolution, and the smaller the mean occupancy per pixel. We have shown in SI (Additional file 1: Figure  S4) that for a fixed number of localizations N R = N G = 10,000 distributed randomly in 3D, as the pixel size decreases (and N p increases) the width of the distribution of MPCC values becomes narrower. All the MPCC distributions for uncorrelated images are symmetric and centered about 0 and well fit by a Gaussian function. For these random, uncorrelated 3D distributions, the standard deviation of the Gaussian MPCC distributions scales as N p -1/2 . This scaling holds even for N R and N G as small as 500.
Narrower widths of the MPCC distribution from random 3D distributions generally provide greater statistical confidence that a non-zero measured value of MPCC is significantly different from zero. This argues for fine pixelation. In practice, we suggest simulating the distribution of MPCC values between the 2D projections of 3D random distributions using the same number of molecules as were imaged in the red and green channels and the same pixel size chosen for R and G. This enables assignment of a probability p that the measured MPCC arose from two random 3D distributions. If p is unacceptably large, finer pixelation of both experimental and simulated locations may decrease p. Finer pixelation also enables detection of correlation or anti-correlation on smaller length scales.
However, for non-random 3D distributions such as the completely anti-correlated distribution of Fig. 2 or the positively correlated distribution of Additional file 1: Figure S2, it is important not to pixelate so finely that the matrices R and G become too sparse. In the case of the anti-correlated model matrices R and G, this leads to false positive linear correlations betweenΔ R ij andΔ G ij . One way to think about this is that the zeroes and small-integer occupancies appearing in the left-hand region of R begin to positively correlate with the zeroes that fill the empty half of G. Similarly, the zeroes and small-integer occupancies arising due to sparseness in the right-hand region of G positively correlate with the zeroes in the empty half of R. These systematically bias the MPCC for truly anti-correlated distributions towards more positive values, underestimating the degree of linear anti-correlation. We explore this effect numerically in Additional file 1: Figure S5. For a given pixel size, the mean MPCC moves closer to the expected value of − 1 for two anti-correlated images as the number of imaged molecules increases. The key controlling parameter seems to be the mean occupancy per pixel.
In practice, we suggest carrying out numerical simulations of perfectly anti-correlated distributions using values of N R and N G that match experiment. The pixel size chosen for analysis of the experimental data should be the smallest pixel size for which the mean MPCC for perfectly anti-correlated distributions is acceptably close to − 1. In the numerical example of Fig. 2, with 10,000 molecules distributed over 75 pixels, the mean occupancy was 133 molecules/pixel, which yielded MPCC = − 0.99. For these images sampled from perfectly anti-correlated model distributions, if the mean occupancy is~7 copies/pixel (~14 copies per pixel in the occupied halves of the case in Fig. 2), then the MPCC will be about − 0.9. MPCC approaches − 1 as the occupancy per pixel increases. For similar reasons, for two perfectly positively correlated distributions we expect that MPCC will systematically underestimate the degree of positive correlation as the red and green matrices become sparse. In the case of positively correlated R and G (Additional file 1: Figure  S2), the zeroes appearing in the images due to sparseness are not positively correlated. The sparseness in number of molecules due to finer pixelation leads to false negative linear correlations betweenΔ R ij andΔ G ij . This leads to systematic negative deviations of the calculated MPCC from the expected value of + 1. We investigated the mean occupancy/pixel that is required for the calculated MPCC between strongly positively correlated images to be~0.9, close to the expected value of + 1. As shown in Fig. 4e and S5, a mean occupancy of~7 copies/pixel (14 copies/pixel in the occupied regions) yields MPCC values of about + 0.9.
While this rule of thumb seems to hold for the perfectly anti-correlated and perfectly correlated model distributions, the pixel occupancy requirement may be more stringent for less strongly anti-correlated or correlated cases. See the experimental example below. In the next section we analyze experimental RNAP and HU distributions and suggest a procedure for assessing the reliability of MPCC values more generally.

Experimental example of MPCC from superresolution images of RNAP and HU in E. coli
To test our MPCC concept on real experimental data, we performed two-color superresolution fluorescence imaging of RNA polymerase and HU in live E. coli cells. RNAP is primarily located in the nucleoid region because of its frequent specific and non-specific interactions with chromosomal DNA [28]. HU is a DNA binding protein that should also localize within the nucleoids [29,30]. We expect significant positive correlation between the spatial distributions of RNAP and HU and therefore a positive value of MPCC.
For superresolution co-imaging of RNAP and HU in live E. coli cells, we constructed a strain where the gene coding for the fluorescent protein YFP (observed in the green channel) [31] is fused to the C terminus of the endogenous rpoC gene in E. coli VH1000. Single copies are imaged using the reversible photobleaching method described earlier [32]. An inducible plasmid that expresses HU labeled with the photoactivatable fluorescent protein PAmcherry [33] (observed in the red channel) was introduced into the same strain. The cells were grown in EZ rich defined medium at 30°C, plated on a glass coverslip, and imaged with 30 ms exposure time. The details of strain construction, growth conditions, and imaging conditions are described in Additional file 1: SI Text S3.
To obtain a useful number of imaged copies without inducing laser damage to the cells, we combine locations of red HU and green RNAP molecules from different cells of essentially the same length. The imaged cells were sorted by tip-to-tip length based on phase contrast images in order to avoid broadening of spatial distribution of molecules due to the range of cell lengths. For the analysis, we chose cells of length 3.6 to 3.8 μm, the bin with the highest number of imaged cells. The resulting composite distribution of spatial localizations of N G = 6570 RNAP-YFP and N R = 8436 HU-PAmcherry molecules from 11 cells pixelated to 105 nm (279 total pixels) is illustrated in Fig. 4a. The mean number of molecules per pixel is~25 and~30 for the RNAP and HU channels respectively. The corresponding 1D projected axial distributions are compared in Fig. 4b. The raw data indeed suggest significant positive correlation between the two distributions.
For evaluation of MPCC we simulated two random distributions of 100,000 molecules each, corresponding to the RNAP (green) and HU (red) channels, using a spherocylinder whose dimensions match those of the chosen cells. The resulting reference images are normalized to have same number of molecules as imaged RNAP and HU. For accurate estimation of the cytoplasmic radius r of the imaged cells in the chosen length bin, we also imaged photoactivable Kaede molecules [34,35], believed to distribute homogenously in the cytoplasmic volume [36]. The detailed procedure is described in Additional file 1: SI Text S4. The resulting cell length is L cell = 3.74 μm; the diameter is 2r = 0.82 μm (Additional file 1: Figure S6). The two simulated 3D random distributions incorporated localization errors σ RNAP = 38 nm and σ HU = 60 nm, determined by the intercepts of MSD plots (Additional file 1: Figure S7). We followed the procedure described above with pixel size of 105 nm to calculate MPCC = + 0.39. The scatter plot ofΔ R ij vsΔ G ij (Fig. 4c) also indicates significant positive correlation. The final step estimates the probability p that a value of MPCC = + 0.39 or larger would be obtained from two random 3D distributions with the same number of imaged molecules and the same pixel size used for the experimental data. In Fig. 4d, we show a histogram of the outcomes of 200 such simulations.  N p = 77). For the experimental data, occupancy/pixel at fixed pixel size was varied by randomly deleting red and green molecules. See Additional file 1: text, Figure S8 and Table S1 for additional information The best-fit Gaussian distribution has a mean value <MPCC> = − 0.0030 and standard error σ MPCC = 0.061. The measured MPCC value lies 6.4σ MPCC away from zero. Under the assumption that the statistics of the simulated MPCC trials are Gaussian, the probability that two random 3D distributions would produce an MPCC value of magnitude 0.39 or larger on either side of the Gaussian curve is p~1.6 × 10 − 10 . Thus, we can reject the null hypothesis that MPCC = + 0.39 arose from two random, uncorrelated 3D distributions and assert significant positive correlation between the RNAP and HU distributions with very high confidence.
The choice of pixel size does affect the calculated MPCC. For 200 nm pixels (N p = 77 total pixels), the experimental MPCC is + 0.51. The corresponding simulations of two random distributions gave <MPCC> = 0.0082 and σ MPCC = 0.12. In this case, the probability that two 3D random distributions would produce an MPCC value of magnitude 0.51 or higher on either side of the mean of the Gaussian curve is p~1.3 × 10 − 4 . For 50 nm pixels (N p = 1178 total pixels), the experimental MPCC is + 0.25. The corresponding simulations of two random distributions gave <MPCC> = 0.0027 and σ MPCC = 0.033. In this case, the probability that two 3D random distributions would produce an MPCC value of magnitude 0.25 or higher on either side of mean of Gaussian curve is p~3.6 × 10 − 14 . The estimated experimental MPCC decreases systematically as N p increases and the same data set is pixelated more finely, but the simulated σ MPCC decreases more rapidly.
The conclusion of significant positive correlation between the RNAP and HU experimental distributions is robust, but what is the best value of MPCC to report? In Fig. 4e and Additional file 1: Figure S8, we explore how the calculated value of MPCC varies with the mean occupancy per pixel. Given a limited number of experimental localizations, there are two ways to vary this parameter: we can keep all the experimental localizations and change the pixel size (50 nm, 105 nm, 200 nm), or we can fix the pixel size and randomly delete red and green copies from each image. MPCC values generated by both procedures fall on the same smooth curve in plots of calculated MPCC vs occupancy per pixel (Fig. 4e, Additional file 1: Figure S8 and Table S1). For the experimental images, the MPCC values are approaching an asymptote of~0.5 as the mean occupancy/pixel approaches 100. Our best estimate is thus MPCC = 0.50 ± 0.05. Because the features of interest in the images are large, 500 nm to 1 μm in size, we feel justified in including pixel sizes in the range 50-200 nm in the analysis.
As suggested by the projected axial distribution of RNAP and HU (Fig. 4b), the two species are not completely correlated in space. There are several factors that may explain why the MPCC is significantly smaller than 1. We have averaged the data over 11 cells whose nucleoids have irregular shapes in 3D that are not axially symmetric and that vary from cell to cell. In addition, while RNAP and HU both bind to the DNA, they have different biological functions and should not be expected to have spatial distributions that correlate perfectly.
As a cautionary note, we observe that for the perfectly correlated or anti-correlated model distributions, MPCC converges towards its asymptotic value vs occupancy/pixel substantially more rapidly than the experimental images (Fig. 4e). In the model images, MPCC reached 90% of its asymptote of ±1 when the occupied side of the image had 14 copies per pixel (7 copies/pixel averaged over the entire cell, which is half empty for both colors). For the experimental data, MPCC reaches 90% of the apparent asymptote of 0.5 only when the occupancy/pixel approaches 30. While mean occupancy/pixel appears to be the controlling parameter, the magnitude required to achieve 10% accuracy evidently depends on the image shape.

Discussion
The Pearson correlation coefficient is one of the statistics commonly used for quantifying the degree of linear correlation in pixel-by-pixel intensity between two different images [14,[37][38][39]. Owing to simplicity of usage and availability in most image analysis software packages (Ima-geJ, Colocalizer Pro), PCC is used increasingly in the literature of two-color fluorescence microscopy. Because it is pixel-based, PCC can in principle be applied to both widefield and superresolution images [3]. The fluorescence intensity of individual pixels in widefield images is proportional to the number of emitted photons incident upon each pixel. The MPCC value can then be calculated using fluorescence intensity per pixel rather than molecules per pixel. Background subtraction to produce zero-based images is important.
For two-color, three-dimensional fluorescence microscopy [40,41], the standard PCC would provide an accurate measure of linear correlation, assuming the 3D image matrices are sufficiently populated. However, by far the more common case of two-color microscopy projects the 3D spatial distributions onto the 2D camera plane. The central point of this work is simple. For most cell shapes, random 3D spatial distributions (no spatial correlations) do not make random 2D projections. In the particular case of spherocylindrical cells, projections of random 3D distributions are skewed to have more molecules/pixel in the central region compared to the edges and the endcap regions (Fig. 1). This renders the standard PCC reference matrices (Eq. 2), whose elements are the constant values R and G, highly inappropriate. As a result, the standard PCC fails both qualitatively and quantitatively to describe the nature and degree of the spatial correlation. A calculated PCC value of + 1 could equally well arise from perfectly correlated 3D distributions (Additional file 1: Figure S2) or from completely random 3D distributions (Fig. 3). For strongly anti-correlated images, the degree of anti-correlation will be systematically underestimated (Fig. 2).
In the special case of spherocylindrical cells, we have described a method for calculating a modified Pearson correlation coefficient (MPCC) that uses the 2D projection matricesŨ R ij andŨ G ij derived from independent 3D random distributions as the reference matrices with which the 2D image matrices R and G are compared (Eq. 3). The resulting MPCC is normalized to lie in the range − 1 to + 1. Within noise limitations, MPCC approaches 0 for the projections of two distributions that are independent and random in 3D, approaches − 1 for two distributions that are perfectly anti-correlated in both 3D and 2D, and approaches + 1 for two distributions that are perfectly positively correlated in both 3D and 2D. Additionally, we have used the new procedure to estimate a positive value MPCC = + 0.50 ± 0.05 between experimentally obtained spatial localizations of individual RNAP and HU molecules in live E. coli cells (Fig. 4). Both RNAP and HU bind the chromosomal DNA, which occupies a subset of the cytoplasmic volume called the nucleoid. As expected, we obtain positive correlation that is significantly outside the range of model MPCC values computed for two uncorrelated distributions using the same pixel and copy number parameters as the experimental data.
While MPCC corrects a significant flaw in the standard PCC, it is important to note that for two images that are correlated or anti-correlated in 3D (i.e., not random), the MPCC applied to the 2D projections will typically underestimate the degree of correlation or anti-correlation in 3D. Projection from 3D to 2D always involves a loss of information. If the two 3D distributions are correlated or anti-correlated, their 2D projections will typically be less so. Our model correlated images (Additional file 1: Figure S2) and anti-correlated images ( Fig. 2 and Additional file 1: Figure S1) are special cases in that they preserve perfect correlation or anti-correlation when projected from 3D to 2D. More irregular, less symmetric 3D distributions generally will not. This means that a 2D MPCC value that is not significantly different from zero does not imply the absence of 3D spatial correlations.
We have also shown how a small average number of molecules per pixel can cause systematic errors in MPCC values (Fig. 4, Additional file 1: Figures S5 and  S8). For images sampled from both perfectly anti-correlated and perfectly correlated distributions, this effect diminishes the magnitude of MPCC (biasing it towards zero). The minimum number of molecules per pixel required to obtain a trustworthy MPCC was 7 for our model images but increased to~30 for our experimental images. The MPCC user needs to measure a sufficient number of localizations and make a knowledgeable choice of pixel size based on the questions being asked. In each situation, by altering the pixelation or by randomly deleting copies, the user can determine how many copies per pixel is sufficient for the desired accuracy. As pixel size increases, spatial correlations on shorter length scales will be lost. It appears to us that MPCC will be most useful in exploring correlations on a length scale of~200 nm or larger, as in our HU/RNAP example.
In earlier work applying PCC to eukaryotic cells, Dunn, et al. [23] warned against inclusion of empty extracellular regions in the image matrices R and G. Such extra zeroes alter the mean value in the references matrices and also artificially inflate the calculated PCC due to positive correlations between the empty regions in both matrices. They suggested carefully outlining only the regions of space that are occupied by the cells of interest. However, the MPCC is impervious to such extra zeroes. The mean pixel intensity over the region of interest does not participate in the calculation of MPCC. The empty regions of the image outside the cell boundary cause corresponding zeroes in the 2D projected reference matrix. They affect neither the normalization condition (Eq. 4 in Methods) nor the calculated MPCC (Eq. 3). In the MPCC procedure, one need not worry about empty regions of the image matrices that lie outside the projected cell boundaries.
The caveats outlined here apply to essentially all types of cells or organelles. In principle, the central concept of MPCC can be generalized to other cell geometries, including irregular eukaryotic shapes. However, the MPCC will probably find its greatest use in bacterial cells, whose shapes are often quite uniform for given growth conditions. It is relatively straightforward to simulate appropriate 2D reference distributions for rod-shaped bacteria like E. coli and B. subtilis, using a spherocylinder as the simplified model. The problem becomes more difficult for other shapes, such as the spiral shaped H. pylori.
One possible purely experimental solution would be to co-image a large population of freely diffusing fluorophores that presumably map out the 2D projection of a 3D random distribution in the cell volume of interest. To test this concept on E. coli, we have imaged Kaede under the same growth conditions used to image the RNAP and HU spatial distributions of Fig. 4. Kaede is a non-native tetrameric fluorescent protein that diffuses freely in E. coli and appears to fill the cytoplasm uniformly [36]. We imaged Kaede in 15 cells of length 3.6 to 3.8 μm, the same length bin used for RNAP and HU. The composite distribution of 54,719 spatial localizations from 8 of the 15

Conclusions
In this work, we have described a method of calculating a modified Pearson Correlation coefficient between two 2D fluorescence images of spherocylindrical cells. Calculation of traditional Pearson correlation coefficient uses a constant mean value of the image as the reference distribution. This leads to incorrect estimation of correlation coefficient both quantitatively and qualitatively. We have proposed a modified Pearson Correlation Coefficient (MPCC) that corrects this problem for spherocylindrical cell geometry by employing the proper reference matrices, 2D projection matrices derived from independent 3D random distributions in spherocylinders, for comparison with the images under analysis. MPCC can be employed for 2D superresolution as well as widefield images, conventionally acquired for wide variety of studies. The application of MPCC to irregularly shaped bacterial cells may be possible by imaging a large population of freely diffusing fluorophores that presumably serve as an experimental reference distribution. We demonstrated the applicability of MPCC to experimentally acquired superresolution images of RNAP and HU in E. coli, using both simulated and experimental reference distributions. MPCC will prove most useful in quantifying spatial correlation between two different fluorophore-labeled molecules on length scales comparable to the shortest cell dimensions.

Methods
As a first step towards generation of the matricesŨ R and U G in Eq. 3, a large number of molecules (here 100,000) are randomly distributed in a spherocylinder whose dimensions match those of the cells being imaged. We wantŨ R andŨ G to have high signal-to-noise in each pixel. For a cell of length 3.5 μm and width of 0.82 μm, the choice of 200 nm for the pixel size results in 75 pixels in the cell. 100,000 molecules makes the mean occupancy 1333 molecules/pixel. An appropriate localization error σ is applied to each particle location in both x and y coordinates by sampling a Gaussian distribution with standard deviation σ, yielding the model "measured" location of each molecule, which is binned appropriately. For generating 3D random distribution of molecules corresponding to the red and green channels, the localization error applied is the same as that measured upon imaging fluorescent molecules in red (σ R ) and green channels (σ G ) respectively. The 2D projections along the z axis of these two 3D random distributions give the matrices U R and U G . The elements U R ij and U G ij are positive integers. Next the counts in individual pixels of U R and U G are normalized so that the total number of red and green molecules is equal to N R and N G , the total number of molecules imaged in each channel. This yields the normalized matrixŨ R : so that P m i¼1 P n j¼1Ũ R ij ¼ N R . Similarly, U G is normalized so that the sum of all elements ofŨ G is N G .
We then subtractedŨ R andŨ G from the corresponding image matrix under analysis, R and G respectively to obtain the unnormalized difference matrices Δ R and Δ G . We normalized Δ R and Δ G so that the sum of the squares of individual pixel values in the difference matrix is 1: where kΔ R k ¼ ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ffi P m i¼1 P n j¼1 Δ R ij 2 q . The resultant normalized 2D difference matrixΔ R has kΔ R k ¼ 1. The difference matrix Δ G in the green channel is similarly normalized to obtainΔ G such that kΔ G k ¼ 1.
MPCC is obtained by taking the Frobenius inner product of the two normalized matricesΔ R andΔ G : Additional file Additional file 1: SI Text S1. Two additional cases of anti-correlation in 3D and in 2D. SI Text S2. Example of positive correlation. SI Text S3. Materials and Methods. SI Text S4. Determining cell width and length. SI Figures (S1-S8) and Captions. Table S1. Variation of MPCC with number of pixels Np and with mean occupancy per pixel for the experimental RNAP (green) and HU (red) image matrices. (DOCX 2165 kb)