Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Mean, Median, and Robust Donor Summaries

Biological Replication and Donor-Level Inference · Tutorial 439 of 700

Mean, Median, and Robust Donor Summaries

Compare the mean, median, and trimmed mean as summaries of a donor’s cell measurements, and learn how skew, outliers, and the chosen measurement scale affect their interpretation.

Advanced 12 min read

What You'll Learn

  • Calculate a donor-level mean, median, and symmetric trimmed mean from cell measurements.
  • Specify a valid trimming fraction and determine which ordered observations are averaged.
  • Explain why extreme values affect the mean, median, and trimmed mean differently.
  • Compare donor summaries while keeping the measurement scale and target quantity clear.
  • Diagnose when a robust summary may hide meaningful variation or reflect too few cells.

Why Compare Several Donor Summaries?

For a given donor, a single-cell analysis may produce many cell-level measurements of a feature, such as a normalized expression value or a cell-state score. A summary reduces those measurements to one number for that donor. The choice of summary matters: a few unusually large values can pull the mean upward, while the median and a trimmed mean emphasize the center of the observed distribution differently.

These are not interchangeable calculations of one universal “typical” value. The mean describes the arithmetic average, the median describes the middle of the ordered values, and a trimmed mean averages the central portion after removing a specified number of values from each tail. Each answers a different descriptive question. The biological target and the measurement scale should guide the choice, not a search for whichever number looks most favorable.

Definition: For donor \(i\), let \(y_{ij}\) be the measured value for cell \(j\), with \(n_i\geq 1\) observed cells. The donor-level mean is the arithmetic average of the \(n_i\) values. The donor-level median is their middle value, or the average of the two middle values when \(n_i\) is even. A symmetric \(\alpha\)-trimmed mean orders the values, removes \(k_i=\lfloor\alpha n_i\rfloor\) observations from each tail, and averages the remaining values, where \(0\leq\alpha<1/2\).

The restriction on \(\alpha\) ensures that at least one value remains. In fact, \(k_i=\lfloor\alpha n_i\rfloor<n_i/2\), so \(n_i-2k_i\geq1\). The floor function means rounding down to the nearest integer; consequently, the actual fraction removed can differ from \(\alpha\) in a small sample. For example, choosing \(\alpha=0.20\) does not guarantee that exactly 20% of the cells are removed from each tail.

These summaries describe the distribution of the measured cells for a donor. If the scientific interpretation is about a donor’s broader cell population, the observed cells must provide a reasonable representation of that population. The calculation itself does not establish representativeness. Nor does having many cells from one donor create many biological replicates: the donor remains the biological unit for donor-level comparisons.

Worked Calculations

Worked Example: One Extreme Measurement

Suppose a hypothetical donor has seven cell-level values, in arbitrary measurement units: \(1, 2, 2, 3, 4, 5, 30\). Calculate the mean, median, and 20% symmetric trimmed mean.

The mean uses every value:

$$ \bar{y}=\frac{1+2+2+3+4+5+30}{7}=\frac{47}{7}=6.714. $$

With seven ordered values, the fourth value is the median, so the median is \(3\). For the trimmed mean, \(k=\lfloor0.20(7)\rfloor=\lfloor1.4\rfloor=1\). Remove the smallest and largest values, \(1\) and \(30\), and average the five remaining values:

$$ \bar{y}_{\mathrm{trim}}=\frac{2+2+3+4+5}{5}=\frac{16}{5}=3.200. $$

The mean is much larger than the median and trimmed mean because the value \(30\) contributes directly to the mean. The robust summaries reduce that value’s influence, but they do not show that it is an error. It may be a genuine cell measurement, and its biological meaning should be investigated.

Worked Example: Comparing Two Donors’ Within-Donor Distributions

Consider hypothetical measurements from two donors. Donor A has \(0, 0, 0, 1, 1, 2, 12, 20\); donor B has \(1, 1, 2, 2, 2, 3, 4, 5\). Calculate each donor’s mean and median, then compare the summaries.

For donor A, the sum is \(36\), giving a mean of \(36/8=4.500\). The two middle ordered values are \(1\) and \(1\), so the median is \((1+1)/2=1.000\).

For donor B, the sum is \(20\), giving a mean of \(20/8=2.500\). Its two middle values are \(2\) and \(2\), so the median is \((2+2)/2=2.000\).

The means place donor A above donor B, while the medians place donor A below donor B. The difference in ordering follows from the distributions: donor A has two large values, \(12\) and \(20\), that raise its mean. This example shows why a comparison should identify which donor-level quantity is being described. It does not, by itself, establish a population difference or provide an inferential test.

Worked Example: Trimming in a Small Sample

A hypothetical donor has four ordered cell measurements, \(1, 2, 8, 100\). Find the mean, median, and 25% trimmed mean, and check that the trimmed mean is defined.

The mean is \((1+2+8+100)/4=111/4=27.75\). The median is the average of the two middle values: \((2+8)/2=5\). For a trimmed mean with \(\alpha=0.25\), \(k=\lfloor0.25(4)\rfloor=1\). After removing \(1\) and \(100\), the remaining values are \(2\) and \(8\), so the trimmed mean is \((2+8)/2=5\). Two values remain, which is consistent with \(n-2k=4-2=2\).

A trimming fraction of \(\alpha=1/2\) is not valid under this definition: for \(n=4\), it gives \(k=\lfloor2\rfloor=2\), leaving \(4-2(2)=0\) values to average. Restricting the definition to \(0\leq\alpha<1/2\) avoids this problem.

What the Summaries Respond To

The mean uses all observed values and preserves their magnitudes. This is useful when the arithmetic average is the intended scientific quantity, but it also makes the mean sensitive to large or small observations. A single value can move the mean substantially, especially when there are few cells. Formally, replacing one observation by a value larger by \(c\) changes the mean by \(c/n_i\); because \(c\) can be arbitrarily large, that change has no fixed upper bound.

The median depends on the central rank or ranks rather than the magnitudes of the most extreme values. It can therefore remain unchanged when an extreme observation becomes even more extreme, provided the ordering around the middle does not change. This resistance is valuable under strong skew or contamination, but the median discards information about distances from the center. Two donors can have the same median and very different spreads or tail behavior.

The trimmed mean is a compromise: it averages more of the distribution than the median does, while excluding a specified number of observations at both extremes. For a fixed sample, an extreme observation that remains among the \(k_i\) trimmed values has no direct contribution to the trimmed average. However, if more extreme observations occur than the trimming rule removes, some can remain in the average and exert influence. Trimming can also discard valid tail behavior that is biologically important.

Interpretation: The mean is an average on the recorded measurement scale. The median is the center by rank. The symmetric \(\alpha\)-trimmed mean is the average of the central \(n_i-2k_i\) observed values under a specified trimming rule. A difference between these summaries can indicate skew or influential tail values; it does not by itself identify their cause.

Choosing and Checking a Summary

Start by specifying the target quantity. If the scientific question concerns average expression on a chosen scale, the mean may be most directly aligned with it, even when it is sensitive to the tail. If the question concerns a typical cell by rank, the median may be appropriate. A trimmed mean can be useful when a central average is desired and a prespecified amount of tail influence is not part of the target. The intended summary should be selected with the question in mind rather than chosen after inspecting which result is preferred.

The measurement scale also matters. For example, averaging values after a transformation generally does not produce the same quantity as averaging first and then transforming. A mean of log-scale measurements is a mean on the log scale; it is not automatically the arithmetic mean of the original-scale measurements. State the scale and any transformation when reporting a donor summary.

Useful checks include inspecting the ordered values or a within-donor distribution plot, comparing summaries across donors, and checking whether a result changes materially under a scientifically defensible alternative summary. Look for a long tail, isolated extreme measurements, a large mean–median gap, or a trimmed mean that changes sharply as \(\alpha\) changes. Also check cell counts and measurement quality: a small number of cells makes each order statistic and the effective trimming rule more discrete. These checks diagnose sensitivity; they do not justify deleting values automatically.

SummaryUses of cell valuesPotential strengthImportant limitation
MeanAll values, with their magnitudesDirectly represents the arithmetic average on the measurement scaleCan be strongly affected by extreme values
MedianMiddle rank or two middle ranksResists changes in the magnitudes of tail observationsDoes not describe distances from the center or tail magnitude
Trimmed meanAverage after removing \(k_i\) values from each tailRetains a central average while limiting the influence of a specified number of extremesDepends on the trimming fraction and can remove meaningful tail values

No summary is universally best. If the distribution is nearly symmetric and has no influential extremes, the three values may be similar. If they differ, report the choice and consider showing more than one as a sensitivity analysis. Agreement across summaries can support the view that the descriptive pattern is not driven solely by a few extreme values; disagreement is a reason to examine the distribution and the scientific meaning of its tails.

Deriving the Trimming Rule and Its Limits

Let the ordered measurements for one donor be \(y_{(1)}\leq y_{(2)}\leq\cdots\leq y_{(n)}\). With \(k=\lfloor\alpha n\rfloor\), trimming removes the first \(k\) and last \(k\) order statistics. The remaining ranks run from \(k+1\) through \(n-k\), inclusive. The number retained is therefore

$$ (n-k)-(k+1)+1=n-2k. $$

Since \(0\leq\alpha<1/2\), \(\alpha n<n/2\), and hence \(k=\lfloor\alpha n\rfloor<n/2\). Thus \(n-2k>0\), and because it is an integer, at least one observation remains. The trimmed mean is

$$ \bar{y}_{\mathrm{trim}}= \frac{1}{n-2k}\sum_{r=k+1}^{n-k}y_{(r)}. $$

This derivation establishes that the stated rule produces a defined average; it does not establish that trimming is suitable for every scientific question. In small samples, several nearby values of \(\alpha\) may yield the same \(k\), while a slight change in \(n\) can change which observations are retained. Report the chosen \(\alpha\), the number removed from each tail, and the number retained so readers can understand the calculation.

Common Pitfalls

  • Calling the median the average. The median is a middle rank, not generally an arithmetic average of all cells. Describe it as the within-donor median.
  • Treating every extreme value as an error. An unusual measurement may be biologically real. Investigate quality and context before any exclusion; robust summaries reduce sensitivity but do not diagnose data errors.
  • Using an invalid trimming fraction. A symmetric trimmed mean under this definition requires \(0\leq\alpha<1/2\). At or above one half, the rule can leave no values to average.
  • Changing the summary after seeing the result. Choosing the statistic because it gives a preferred comparison can distort interpretation. Define the target and summary in advance when possible, and label any sensitivity analysis clearly.
  • Assuming a robust summary removes all concerns about cells. The median and trimmed mean still depend on which cells were observed and how measurements were generated. They do not turn cells into independent biological replicates.
Key takeaway: A donor-level mean, median, or trimmed mean summarizes a different feature of that donor’s cell measurements. State the measurement scale and trimming rule, inspect skew and influential values, and choose the summary to match the scientific target.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. For the ordered values \(2, 3, 3, 4, 10\), calculate the mean and median. Which is more affected by the value \(10\)?
  2. For \(n=9\) and \(\alpha=0.20\), how many observations are removed from each tail, and how many remain?
  3. Why is a symmetric trimming fraction of \(\alpha=0.50\) invalid for an even sample size under the definition in this tutorial?
  4. Two donors have the same median expression value but different means. Give one plausible distributional explanation and one caution about interpreting the difference.

Solutions. (1) The mean is \((2+3+3+4+10)/5=22/5=4.400\); the median is the third ordered value, \(3\). The mean is more affected by \(10\), since that value contributes its full magnitude to the sum. (2) \(k=\lfloor0.20(9)\rfloor=\lfloor1.8\rfloor=1\), so one value is removed from each tail and \(9-2=7\) remain. (3) For even \(n\), \(k=\lfloor n/2\rfloor=n/2\), leaving \(n-2k=0\) observations, so there is no average to calculate. (4) One donor may have a longer or more extreme upper tail that raises its mean while leaving the central rank unchanged. The difference could reflect real tail biology, measurement issues, or sampling variation; summaries alone do not determine which explanation applies.

Clinical Biostats