Nested measurements · Choose a method

Immunofluorescence intensity statistics: CTCF, background, cells within images and experiments as n

Subtract background per cell (CTCF), image with identical settings, average cells per image and images per experiment, and compare conditions per experiment. Cells as n gave 22.6% false positives in a simulated design. Python and R code.

By Licklider · Published · Last reviewed · How this page was made · Markdown

On this page
  1. Which analysis for your question
  2. Worked example: a knockdown with no real effect
  3. Before you analyse
  4. Check what an AI assistant ran
  5. Report it
  6. References

Quick answer. For immunofluorescence intensity per cell, image every condition with identical acquisition settings and no saturated pixels, measure each cell’s corrected total cell fluorescence (CTCF) = integrated density − (cell area × mean background), take natural logs, average cells within each image and images within each independent experiment (a coverslip, culture or animal processed on a separate occasion), and compare conditions per experiment, tested across experiments. Cells are not n, unless the treatment was applied to individual cells at random (for example by microinjection). In a simulation of 4 experiments with 5 images and about 10 cells each, treating the roughly 190 cells per condition as n gave false positives in 22.6% of studies with no real effect, against 4.9% with experiments as n; skipping background subtraction made a real 30% drop look like 21%.

Terms used below. Integrated density: the sum of pixel values inside a cell’s outline; in ImageJ use “RawIntDen” (IntDen equals it only for uncalibrated images), with area in pixels. Background: the signal in cell-free regions, from autofluorescence, stray light and camera offset; here the mean of 3 regions per image. CTCF (corrected total cell fluorescence): not the CTCF protein (CCCTC-binding factor); also published as TCCF; integrated density minus the cell’s area times the mean background. Saturation: pixels at the camera’s maximum value, which no longer increase with more signal. Independent experiment: cells stained and imaged on a separate occasion (or a separate animal). Holm correction: a p-value adjustment when several conditions are each compared with the same control (p.adjust(p, "holm") in R). Log ratio: the logarithm of knockdown ÷ control; results are converted back to a ratio. One-sample t-test: tests whether the mean of the per-experiment log ratios differs from 0, the same as a paired t-test when each experiment contains both conditions. Welch t-test: a two-group t-test that does not assume equal spread. 95% confidence interval (CI): the range of values compatible with the data. Power: the chance of detecting an effect that is really there. False positive: a “significant” result when there is no real effect.

Which analysis for your question

Question Analysis Report
Does a treatment change protein level per cell? log CTCF per cell, mean per image, mean of images per condition per experiment; log ratio per experiment, one-sample t-test Ratio with 95% CI, n experiments (images, cells)
Conditions stained in different experiments (not side by side) Mean log CTCF per experiment, Welch t-test between conditions; only valid if acquisition settings were identical across sessions, and even then condition is confounded with staining batch, so pair conditions in future experiments Ratio with 95% CI
Three or more conditions Log ratio of each condition vs control per experiment; one-sample t-tests with a Holm correction Ratios with adjusted p
Only 2 experiments Describe both experiments’ ratios; a test with 1 degree of freedom says almost nothing Ratios per experiment
Tissue sections from animals The animal is the unit: average cells and sections per animal, compare animals Ratio with 95% CI, n animals
Intensity in one compartment (nucleus, membrane) Outline the compartment in place of the whole cell, and take background from pixels next to it, as Waters recommends for intracellular structures Ratio with 95% CI
Show the spread of cells A SuperPlot: cells coloured by experiment, experiment means on top (SuperPlots) Figure with n experiments

McCloy and colleagues define the measure: “The total corrected cellular fluorescence (TCCF) = integrated density – (area of selected cell × mean fluorescence of background readings)” (McCloy et al. 2014); the same quantity is widely called CTCF. Waters notes that “any background that remains in a fluorescence microscopy digital image must be subtracted from intensity value measurements to reveal the signal”, and that once pixels saturate “the linearity of the detector is therefore lost, and saturated images cannot be used for quantitation of fluorescence intensity values” (Waters 2009). Lord and colleagues write that “neighboring cells within one flask or well treated with a drug are not separate tests of the hypothesis, because the treatment was only applied once”, and that “counting each cell as a separate n can easily result in false-positive rates of >50%” (Lord et al. 2020). Lee and Kitaoka advise “targeting a predetermined number of locations randomly within a well” and that researchers “can blind themselves by labeling samples with codes” (Lee and Kitaoka 2018).

Worked example: a knockdown with no real effect

Constructed data: 4 independent experiments, each with one control and one knockdown coverslip imaged at 5 random fields with identical settings; every cell was outlined (381 cells). For each cell the data hold the area and integrated density, and for each image the mean of 3 background regions. Cell signal varies between experiments (standard deviation 0.3 on the log scale), between the two coverslips of an experiment (0.10), between images (0.10) and between cells (0.45); background adds about a quarter of the raw integrated density. By design, the knockdown does not change the signal. The data’s random seed was the first one tried and was not chosen for its result. Stored code and data: cells.csv, model.py, make_data.py, analysis.py, analysis.R and the analysis output; analysis.py and analysis.R print the same output.

For example, the first control cell has an area of 1,786 pixels and an integrated density of 1,268,651, and its image’s background is 126.1 per pixel, so CTCF = 1,268,651 − 1,786 × 126.1 = 1,043,436.

Analysis, knockdown vs control Result
A. (Not valid: cells share coverslips) Cells as n (185 vs 196), Welch t-test on log CTCF ratio 0.96, p = 0.47
B. (Ignores pairing by experiment) Images as n (20 vs 20), Welch t-test on mean log CTCF ratio 0.97, p = 0.79
C. Experiments as n, log CTCF, log ratio per experiment (n = 4) 0.97 (95% CI 0.77 to 1.23), p = 0.74
D. (Not recommended: background left in) Experiments as n, integrated density without background subtraction 0.97 (95% CI 0.82 to 1.14), p = 0.58

With this data set no analysis found a difference; the simulation shows how often the cell-level test does. Across 5,000 simulated studies of this design (simulation.py, the simulation output):

Scenario A. Cells as n (invalid) B. Images as n (ignores pairing) C. Experiments, CTCF D. Experiments, no background subtraction Average ratio, C Average ratio, D
No knockdown effect (false positives) 22.6% 5.1% 4.9% 5.1% 1.01 1.00
Knockdown lowers signal by 30% (power) 99.1% 89.7% 69.7% 61.4% 0.70 0.79

These percentages describe this simulated design (4 experiments, 5 images, about 10 cells, the variation in model.py), not every imaging study. Cells as n found a “difference” in 22.6% of null studies, because cells on one coverslip share its staining. Images as n happened to stay near 5% here because two errors offset each other: it ignores the pairing, so differences between experiments make it cautious, and it treats images on one coverslip as independent, which makes it liberal; with more coverslip-to-coverslip variation it would be expected to give false positives (not simulated here). The 22.6% for cells as n is for this design; with more cells per coverslip or larger coverslip differences it is higher, as in the more than 50% that Lord and colleagues mention. Experiments as n with CTCF kept false positives at 5% and estimated the 30% drop correctly. Without background subtraction the estimate shrank to a 21% drop and power fell, because the background, which the knockdown does not change, was counted as signal; in the null worked example both happened to give 0.97, which says nothing in favour of skipping it. With 4 experiments a 30% drop was detected about 70% of the time, so plan more experiments for smaller effects.

To get these numbers in ImageJ/Fiji: set Analyze > Set Measurements to Area, Integrated density and Mean (and copy the RawIntDen column into int_den); outline each cell (ROI Manager) and measure; measure 3 cell-free regions per image and average their Mean as the background; export one row per cell (measure the background regions separately, not in the cell table), then add columns for experiment, condition and image and copy each image’s mean background onto every cell row of that image as bg_mean. Re-imaging the same coverslip is not a new experiment. The code expects one row per cell with columns experiment, condition (labels exactly control and knockdown), image, cell, area_px, int_den (raw integrated density) and bg_mean (mean background per pixel for that image). Rename your columns and labels to match, and run the code in the folder that holds the CSV file. Python needs NumPy, pandas and SciPy 1.10 or later; the R code uses base R only.

import numpy as np, pandas as pd
from scipy import stats

d = pd.read_csv("cells.csv")
d["log_ctcf"] = np.log(d.int_den - d.area_px * d.bg_mean)                 # CTCF per cell, logged
img = d.groupby(["experiment", "condition", "image"]).log_ctcf.mean()      # mean per image
ex = img.groupby(["experiment", "condition"]).mean().unstack()            # mean of images per experiment
r = ex.knockdown - ex.control; t = stats.ttest_1samp(r, 0); ci = t.confidence_interval()
print(f"knockdown / control {np.exp(r.mean()):.2f} (95% CI {np.exp(ci.low):.2f} to {np.exp(ci.high):.2f}), p = {t.pvalue:.2g}")
# knockdown / control 0.97 (95% CI 0.77 to 1.23), p = 0.74
d <- read.csv("cells.csv"); d$log_ctcf <- log(d$int_den - d$area_px * d$bg_mean)   # CTCF per cell, logged
img <- aggregate(log_ctcf ~ experiment + condition + image, data = d, FUN = mean)  # mean per image
ex <- tapply(img$log_ctcf, list(img$experiment, img$condition), mean)              # mean of images per experiment
t <- t.test(ex[, "knockdown"] - ex[, "control"])
round(exp(c(ratio = unname(t$estimate), t$conf.int)), 2); round(t$p.value, 2)      # 0.97 0.77 1.23, then 0.74

Before you analyse

  1. Use identical acquisition settings (objective, exposure, gain, laser power, binning) for every condition in an experiment, and check that no pixel in a cell is saturated.
  2. Choose fields by a fixed rule, blind to condition: a set number of random or grid positions (for example 5 or more fields and every cell in them), with slides coded until analysis is finished, and exclusion rules (cells touching the edge, out of focus, saturated) written down in advance.
  3. Measure background in cell-free regions of each image and subtract it per cell (CTCF); a CTCF at or below 0 means the background region was badly placed or the cell is unstained, so recheck it rather than dropping it silently (logs of values ≤ 0 do not exist).
  4. Average cells within images and images within experiments before testing; a mixed model is an alternative only if it includes an experiment-by-condition term and uses small-sample degrees of freedom (nested data).
  5. Repeat staining and imaging on separate occasions (or in separate animals); those repeats are n.

Check what an AI assistant ran

  1. The assistant ran a t-test on all cells. Ask for one value per condition per experiment.
  2. The assistant used mean intensity or integrated density without background subtraction. Ask for CTCF or another background-corrected measure.
  3. The assistant compared images taken with different exposure or gain. Ask for identical settings, or for the conditions to be re-imaged.
  4. The assistant analysed untransformed intensities. Ask for log CTCF and ratios.

Report it

Cells were imaged at [5] random fields per coverslip with identical settings ([objective, exposure, gain]) and no saturated pixels, blind to condition, in [4] independent experiments. Corrected total cell fluorescence (integrated density − cell area × mean background of [3] cell-free regions per image) was log-transformed, averaged per image and per condition within each experiment, and the log ratio knockdown ÷ control was compared with 0 by a one-sample t-test across experiments (R [4.3.3]).

In the constructed example, which has no effect built in, the knockdown did not clearly change the signal (ratio [0.97], 95% CI [0.77] to [1.23]; p = [0.74]; n = [4] experiments, [381] cells).

Replace the bracketed values with your own.

References

  • McCloy RA, Rogers S, Caldon CE, Lorca T, Castro A, Burgess A (2014). Partial inhibition of Cdk1 in G2 phase overrides the SAC and decouples mitotic events. Cell Cycle 13:1400–1412. doi:10.4161/cc.28401
  • Waters JC (2009). Accuracy and precision in quantitative fluorescence microscopy. Journal of Cell Biology 185:1135–1148. doi:10.1083/jcb.200903097
  • Lord SJ, Velle KB, Mullins RD, Fritz-Laylin LK (2020). SuperPlots: communicating reproducibility and variability in cell biology. Journal of Cell Biology 219:e202001064. doi:10.1083/jcb.202001064
  • Lee JY, Kitaoka M (2018). A beginner’s guide to rigor and reproducibility in fluorescence imaging experiments. Molecular Biology of the Cell 29:1519–1525. doi:10.1091/mbc.E17-05-0276

How this page was made

  • Written and published by Licklider. Recommendations cite peer-reviewed methods papers listed under References; cited passages were checked against the source text.
  • The worked example uses constructed data. Its numbers were produced by stored code (Python 3.13 with SciPy 1.18.1; R 4.3.3, base R), and the two languages print identical output; the simulation was run in Python.
  • Separate review passes checked the statistics, the citations and readability before publication.