1 The output of preprocessing is part of the analysis
An analysis of log-normalized expression estimates a quantity involving log-normalized expression. It does not automatically estimate a difference in absolute molecules per cell. Writing the target after choosing a pipeline can hide this change of question.
Distinguish three operations. A fixed transformation, such as a prespecified logarithm with a fixed offset, defines a new measured variable. A normalization learned from the dataset uses estimated reference quantities and brings additional sampling dependence. An adjustment for biological covariates specifies which population association or contrast is being isolated. The operations can coexist, but they require different justifications.
For each operation, finish the sentence “After this step, one value represents …”. Dividing a signal by specimen volume gives a different unit from dividing by a sum of feature signals. Taking a log changes the summary being averaged. Regressing out a biological covariate changes the comparison. A clean-looking matrix is not a sufficient description of any of these choices.
2 Relative measurements cannot answer every absolute question
The toy example has two molecular features. Feature A has the same absolute abundance in both specimens; B increases ninefold. Both specimens receive the same sequencing budget. Predict what happens to the expected reads for A.
Code
abundance <-rbind(A =c(100, 100), B =c(100, 900))colnames(abundance) <-c("Specimen 1", "Specimen 2")shares <-sweep(abundance, 2, colSums(abundance), "/")par(mfrow =c(1, 2), mar =c(4, 4, 2, 1))barplot(abundance, col =c("#2F80C8", "#D55E00"),ylab ="Absolute molecules", main ="Biological quantities")barplot(1000* shares, col =c("#2F80C8", "#D55E00"),ylab ="Expected reads out of 1,000", main ="Relative measurement",legend.text =rownames(abundance))
Figure 1: A synthetic fixed read budget: A stays at 100 molecules but falls from half to one tenth of the expected reads as B rises.
In specimen 1, A’s share is 100/(100+100)=1/2, giving 500 expected reads out of 1,000. In specimen 2, it is 100/(100+900)=1/10, giving 100 expected reads. Its expected measured count falls fivefold while its absolute amount stays fixed. The denominator changed because B increased.
More generally, a composition p_g=x_g/\sum_hx_h is unchanged when every x_g is multiplied by the same positive constant. Consequently relative observations alone cannot distinguish all absolute-abundance worlds, even with arbitrarily many reads. Equal library sizes do not supply the missing scale.
Normalization can recover useful comparisons under a stated reference or stability assumption. For example, estimating a specimen’s multiplicative factor from reference features assumes their joint behavior can anchor that factor. An increase shared by every feature can be absorbed into the estimated reference. External calibration tied to specimen amount, cell number, or another defined unit may be needed for an absolute target. The two-feature toy illustrates an identification issue; it does not evaluate a particular normalization algorithm under its own assumptions.
3 Transformation changes the target
Let L=\log_2(Y+c) with a prespecified offset c>0 and Y+c>0. Define the group contrast \Delta_L=E[L\mid A=1]-E[L\mid A=0]. Then
Each term is the population geometric mean of Y+c. This is generally different from E[Y\mid A=1]/E[Y\mid A=0], the arithmetic-mean ratio. The log is nonlinear, so transforming and averaging do not commute. The offset also forms part of the variable being summarized, particularly near zero.
The following positive-valued example needs no offset. Predict both mean ratios before running it.
Both arithmetic means are 5, so their ratio is 1. Group A’s geometric mean is 17^{1/4}\approx2.03, whereas group B’s is 5, giving ratio about 2.46. The contrast is sensitive to distributional shape as well as the largest values. Select the summary that answers the biological question, and report its scale.
An offset has units too. Adding one to a read count differs from adding one CPM after depth normalization. At small values the offset can determine much of the transformed difference. Report where it was added, its numerical value, and the logarithm base; another offset defines another observed-scale target.
4 Filtering changes the family and sometimes the population
Feature filtering defines which features are analyzed. Removing 5,000 low-count genes leaves conclusions about the retained family; it does not establish no change in the excluded genes. With a relative representation, removing features and recomputing its reference can also change the remaining features’ values. Keep the filtering and reference rules explicit.
Sample exclusion can change the target population, especially if failed measurements are related to disease severity or the outcome. If only specimens passing QC are averaged, the immediate target is a mean among included specimens. Extending it to everyone eligible needs an argument about the observation process or an adjusted estimator. This is different from reducing the number of tested genes. Keep both feature-flow and person/specimen-flow records.
A filter used before testing still needs an inferential justification. Being applied “before” the test in code is not the same as being independent of the null test statistic. Filtering on a group contrast and then testing that same contrast generally changes calibration. See Multiple testing when the tests are not independent.
5 Batch and cell composition are not interchangeable nuisances
A batch variable records a technical process. Cell composition may represent biological differences as well as variation one wants to adjust for. Removing a composition-associated signal can change the scientific question rather than simply clean the data. Define whether the desired target is a bulk-tissue contrast, a contrast at common composition, or a cell-type-specific quantity.
For example, if Y=\alpha+\tau A+\gamma B+\varepsilon describes a measured outcome, A is group and B is batch. When every case is in batch 1 and every control in batch 0, B=A and the mean becomes \alpha+(\tau+\gamma)A. The data identify only the combined coefficient, not its biological and technical parts separately. Including both columns in software does not fix the missing within-batch comparison.
When groups overlap across batches, adjustment can use those comparisons under the chosen model. Inspect how much overlap exists: a formally estimable coefficient can still depend heavily on a small subset of the data. Independent technical controls may supply additional calibration information, but their applicability needs a measurement model. Adjusting for a covariate also does not establish causality; that requires its own identification argument.
For composition, the bulk group difference includes whatever mixture changes occurred in that population. A standardized target instead averages conditional group means over one chosen composition distribution. Adding estimated composition to a regression does not automatically identify expression within a particular cell type; that requires a model and information separating the cell-type contributions.
6 Learned preprocessing belongs in the fitting argument
For held-out prediction or cross-fitted nuisance estimation, fit outcome-dependent selection, imputation, tuning, and other learned operations on training units, then apply the fitted operations to validation units. Keep all records from one independent unit in the same fold. Fixed, independently specified transformations can be applied consistently throughout.
Some unsupervised normalization procedures use the whole cohort by design. If changing another person’s specimen changes my normalized value, the derived observations share an estimated reference. An inference argument that treats the resulting values as independent, fixed outcomes must account for that construction. A deterministic transform using only one person’s recorded measurements is a different case.
Whether cohort-wide fitting is appropriate depends on the target and analysis, not on the word “unsupervised.” For prospective prediction, an incoming specimen must be processed using the reference available at deployment. For cross-fitted nuisance estimation, a learned preprocessing step belongs in the fold-specific procedure unless another argument justifies the dependency. Validate the complete fitting procedure, including its reference and tuning.
7 Make preprocessing auditable
For every operation, record the input version, parameters, reference set, fitting data, output scale, and reason. Inspect before/after distributions, missingness, and group–batch tables. Evaluate the operation against the target rather than choosing it because it maximizes apparent group separation.
In edgeR, normalization factors modify effective library sizes. This illustrates a model-based correction, rather than a requirement to overwrite the raw count matrix. Preserve raw measurements and document the derived representation used by each analysis.
The checkpoint is this page’s completion target. Additional practice is optional. Try the checkpoint before opening its hint or solution.
Checkpoint · PRE-01 — Name the target after each processing decision
Task type: Interpretation and diagnosis.
A workflow logs counts with an offset, selects genes by the case–control contrast, adjusts for cell composition, and compares the resulting group means. For each step, identify the target or inferential issue. Explain what must be justified before calling the result a disease effect on absolute expression.
Ready to continue when: you can separate a scale definition, selection, biological adjustment, and causal/measurement assumptions.
Transfer: If the target is the total bulk-tissue disease-associated difference, could removing all composition-associated variation remove part of that target?
Hint
Ask what random variable is being averaged, which family was selected, and what comparison remains after adjustment.
Solution outline — open after trying
Logging defines a mean log-scale target involving the offset. Selecting by the same contrast being tested can invalidate ordinary null calibration. Composition adjustment changes a bulk comparison to a composition-adjusted one under the chosen model. Neither the transform nor adjustment establishes an absolute-abundance or causal interpretation; those need calibration and identification assumptions. A defensible analysis specifies the target first, uses justified selection/inference, documents the fitting pipeline, and reports the scale and adjustment.
Additional practice (optional)
Repeat the log-scale example with offsets 0.1, 1, and 5 and explain the resulting targets.
Design a group–batch table that is perfectly confounded and one that supports a within-batch group comparison.
List which steps in your own pipeline learn information from outcomes or from validation units.
9 Reading
edgeR workflow: filtering, normalization factors, and weighted comparisons.
Love, Huber, and Anders (2014), DESeq2: a count-model framework with explicit normalization assumptions.
---title: "Preprocessing and the quantity being estimated"subtitle: "Which changes are technical, which change the question?"guide-status: "Available"---**Before reading:** [Understanding an omics dataset](understanding-omics-data.qmd), means, logarithms, and basic regression.## The output of preprocessing is part of the analysisAn analysis of log-normalized expression estimates a quantity involving log-normalized expression. It does not automatically estimate a difference in absolute molecules per cell. Writing the target after choosing a pipeline can hide this change of question.Distinguish three operations. A fixed transformation, such as a prespecified logarithm with a fixed offset, defines a new measured variable. A normalization learned from the dataset uses estimated reference quantities and brings additional sampling dependence. An adjustment for biological covariates specifies which population association or contrast is being isolated. The operations can coexist, but they require different justifications.For each operation, finish the sentence “After this step, one value represents …”. Dividing a signal by specimen volume gives a different unit from dividing by a sum of feature signals. Taking a log changes the summary being averaged. Regressing out a biological covariate changes the comparison. A clean-looking matrix is not a sufficient description of any of these choices.## Relative measurements cannot answer every absolute questionThe toy example has two molecular features. Feature A has the same absolute abundance in both specimens; B increases ninefold. Both specimens receive the same sequencing budget. Predict what happens to the expected reads for A.```{r}#| label: fig-relative-budget#| fig-width: 8#| fig-height: 3.8#| fig-cap: "A synthetic fixed read budget: A stays at 100 molecules but falls from half to one tenth of the expected reads as B rises."#| fig-alt: "Two panels show constant absolute abundance of A and increased abundance of B; with a fixed read budget, the expected read share of A falls."abundance <-rbind(A =c(100, 100), B =c(100, 900))colnames(abundance) <-c("Specimen 1", "Specimen 2")shares <-sweep(abundance, 2, colSums(abundance), "/")par(mfrow =c(1, 2), mar =c(4, 4, 2, 1))barplot(abundance, col =c("#2F80C8", "#D55E00"),ylab ="Absolute molecules", main ="Biological quantities")barplot(1000* shares, col =c("#2F80C8", "#D55E00"),ylab ="Expected reads out of 1,000", main ="Relative measurement",legend.text =rownames(abundance))```In specimen 1, A's share is $100/(100+100)=1/2$, giving 500 expected reads out of 1,000. In specimen 2, it is $100/(100+900)=1/10$, giving 100 expected reads. Its expected measured count falls fivefold while its absolute amount stays fixed. The denominator changed because B increased.More generally, a composition $p_g=x_g/\sum_hx_h$ is unchanged when every $x_g$ is multiplied by the same positive constant. Consequently relative observations alone cannot distinguish all absolute-abundance worlds, even with arbitrarily many reads. Equal library sizes do not supply the missing scale.Normalization can recover useful comparisons under a stated reference or stability assumption. For example, estimating a specimen's multiplicative factor from reference features assumes their joint behavior can anchor that factor. An increase shared by every feature can be absorbed into the estimated reference. External calibration tied to specimen amount, cell number, or another defined unit may be needed for an absolute target. The two-feature toy illustrates an identification issue; it does not evaluate a particular normalization algorithm under its own assumptions.## Transformation changes the targetLet $L=\log_2(Y+c)$ with a prespecified offset $c>0$ and $Y+c>0$. Define the group contrast $\Delta_L=E[L\mid A=1]-E[L\mid A=0]$. Then$$2^{\Delta_L}=\frac{2^{E[\log_2(Y+c)\mid A=1]}} {2^{E[\log_2(Y+c)\mid A=0]}}.$$Each term is the population geometric mean of $Y+c$. This is generally different from $E[Y\mid A=1]/E[Y\mid A=0]$, the arithmetic-mean ratio. The log is nonlinear, so transforming and averaging do not commute. The offset also forms part of the variable being summarized, particularly near zero.The following positive-valued example needs no offset. Predict both mean ratios before running it.```{r}a <-c(1, 1, 1, 17)b <-c(5, 5, 5, 5)c(arithmetic_ratio =mean(b) /mean(a),geometric_ratio =2^(mean(log2(b)) -mean(log2(a))))```Both arithmetic means are 5, so their ratio is 1. Group A's geometric mean is $17^{1/4}\approx2.03$, whereas group B's is 5, giving ratio about 2.46. The contrast is sensitive to distributional shape as well as the largest values. Select the summary that answers the biological question, and report its scale.An offset has units too. Adding one to a read count differs from adding one CPM after depth normalization. At small values the offset can determine much of the transformed difference. Report where it was added, its numerical value, and the logarithm base; another offset defines another observed-scale target.## Filtering changes the family and sometimes the populationFeature filtering defines which features are analyzed. Removing 5,000 low-count genes leaves conclusions about the retained family; it does not establish no change in the excluded genes. With a relative representation, removing features and recomputing its reference can also change the remaining features' values. Keep the filtering and reference rules explicit.Sample exclusion can change the target population, especially if failed measurements are related to disease severity or the outcome. If only specimens passing QC are averaged, the immediate target is a mean among included specimens. Extending it to everyone eligible needs an argument about the observation process or an adjusted estimator. This is different from reducing the number of tested genes. Keep both feature-flow and person/specimen-flow records.A filter used before testing still needs an inferential justification. Being applied “before” the test in code is not the same as being independent of the null test statistic. Filtering on a group contrast and then testing that same contrast generally changes calibration. See [Multiple testing when the tests are not independent](../analysis-problems/multiple-testing.qmd).## Batch and cell composition are not interchangeable nuisancesA batch variable records a technical process. Cell composition may represent biological differences as well as variation one wants to adjust for. Removing a composition-associated signal can change the scientific question rather than simply clean the data. Define whether the desired target is a bulk-tissue contrast, a contrast at common composition, or a cell-type-specific quantity.For example, if $Y=\alpha+\tau A+\gamma B+\varepsilon$ describes a measured outcome, $A$ is group and $B$ is batch. When every case is in batch 1 and every control in batch 0, $B=A$ and the mean becomes $\alpha+(\tau+\gamma)A$. The data identify only the combined coefficient, not its biological and technical parts separately. Including both columns in software does not fix the missing within-batch comparison.When groups overlap across batches, adjustment can use those comparisons under the chosen model. Inspect how much overlap exists: a formally estimable coefficient can still depend heavily on a small subset of the data. Independent technical controls may supply additional calibration information, but their applicability needs a measurement model. Adjusting for a covariate also does not establish causality; that requires its own identification argument.For composition, the bulk group difference includes whatever mixture changes occurred in that population. A standardized target instead averages conditional group means over one chosen composition distribution. Adding estimated composition to a regression does not automatically identify expression within a particular cell type; that requires a model and information separating the cell-type contributions.## Learned preprocessing belongs in the fitting argumentFor held-out prediction or cross-fitted nuisance estimation, fit outcome-dependent selection, imputation, tuning, and other learned operations on training units, then apply the fitted operations to validation units. Keep all records from one independent unit in the same fold. Fixed, independently specified transformations can be applied consistently throughout.Some unsupervised normalization procedures use the whole cohort by design. If changing another person's specimen changes my normalized value, the derived observations share an estimated reference. An inference argument that treats the resulting values as independent, fixed outcomes must account for that construction. A deterministic transform using only one person's recorded measurements is a different case.Whether cohort-wide fitting is appropriate depends on the target and analysis, not on the word “unsupervised.” For prospective prediction, an incoming specimen must be processed using the reference available at deployment. For cross-fitted nuisance estimation, a learned preprocessing step belongs in the fold-specific procedure unless another argument justifies the dependency. Validate the complete fitting procedure, including its reference and tuning.## Make preprocessing auditableFor every operation, record the input version, parameters, reference set, fitting data, output scale, and reason. Inspect before/after distributions, missingness, and group–batch tables. Evaluate the operation against the target rather than choosing it because it maximizes apparent group separation.In edgeR, [normalization factors modify effective library sizes](https://www.bioconductor.org/packages/release/workflows/vignettes/RnaSeqGeneEdgeRQL/inst/doc/edgeRQL.html). This illustrates a model-based correction, rather than a requirement to overwrite the raw count matrix. Preserve raw measurements and document the derived representation used by each analysis.The [Sensitivity analysis for assumptions and research decisions](../method-development/sensitivity-analysis.qmd) page gives a framework for labeling preprocessing changes, estimator changes, and identification departures.## ExercisesThe checkpoint is this page's completion target. Additional practice is optional. Try the checkpoint before opening its hint or solution.::: {#checkpoint-pre-01 .checkpoint}### Checkpoint · PRE-01 — Name the target after each processing decision {.unnumbered}**Task type:** Interpretation and diagnosis.A workflow logs counts with an offset, selects genes by the case–control contrast, adjusts for cell composition, and compares the resulting group means. For each step, identify the target or inferential issue. Explain what must be justified before calling the result a disease effect on absolute expression.**Ready to continue when:** you can separate a scale definition, selection, biological adjustment, and causal/measurement assumptions.**Transfer:** If the target is the total bulk-tissue disease-associated difference, could removing all composition-associated variation remove part of that target?<details class="checkpoint-help"><summary>Hint</summary>Ask what random variable is being averaged, which family was selected, and what comparison remains after adjustment.</details><details class="checkpoint-help"><summary>Solution outline — open after trying</summary>Logging defines a mean log-scale target involving the offset. Selecting by the same contrast being tested can invalidate ordinary null calibration. Composition adjustment changes a bulk comparison to a composition-adjusted one under the chosen model. Neither the transform nor adjustment establishes an absolute-abundance or causal interpretation; those need calibration and identification assumptions. A defensible analysis specifies the target first, uses justified selection/inference, documents the fitting pipeline, and reports the scale and adjustment.</details>:::### Additional practice (optional) {.unnumbered}1. Repeat the log-scale example with offsets 0.1, 1, and 5 and explain the resulting targets.2. Design a group–batch table that is perfectly confounded and one that supports a within-batch group comparison.3. List which steps in your own pipeline learn information from outcomes or from validation units.## Reading- [edgeR workflow](https://www.bioconductor.org/packages/release/workflows/vignettes/RnaSeqGeneEdgeRQL/inst/doc/edgeRQL.html): filtering, normalization factors, and weighted comparisons.- Love, Huber, and Anders (2014), [DESeq2](https://doi.org/10.1186/s13059-014-0550-8): a count-model framework with explicit normalization assumptions.<span id="continue-through-the-collection"></span>