The Computational Biologist's Guide to Gene Expression Data
By Dr. Zubair Khalid, DVM, MS, PhD ·

Quick Answer
- Gene expression analyses fail most often from biological confounders, especially cell type composition shifts and batch effects, not from the statistical test itself.
- Account for tissue heterogeneity by measuring cell type fractions and include batch as a covariate in every differential expression model.
- No computational correction can fully replace careful experimental design, so record sample collection times, tissue handling, and processing runs before analysis begins.
Understanding Biological Confounders in Gene Expression Data
Gene expression studies measure RNA abundance across conditions, but the signal of interest is easily obscured by systematic biological variation. Two confounders dominate practical analysis problems: cell type composition and batch effects. Cell type composition refers to the proportion of different cell types within a tissue sample. Batch effects are technical variations introduced when samples are processed in different groups, at different times, or by different operators. Both alter measured expression levels in ways that can mimic or mask true biological differences.
A typical experiment compares diseased and healthy tissue. If the diseased tissue contains more immune cells than the healthy tissue, the expression differences you detect may reflect the immune cell presence instead of the disease mechanism. Similarly, if all diseased samples are processed in one batch and healthy samples in another, the batch difference becomes indistinguishable from the disease effect. These problems are not solved by larger sample sizes or more sophisticated statistics alone.
Why Cell Type Composition Distorts Results
Tissue samples are mixtures. Blood contains red cells, white cells, and platelets. Tumor biopsies contain cancer cells, fibroblasts, endothelial cells, and infiltrating immune cells. Liver contains hepatocytes, Kupffer cells, stellate cells, and endothelial cells. Each cell type has a distinct transcriptome, so the measured expression in a bulk sample is a weighted average of the cell types present.
When the composition differs between comparison groups, the expression differences you observe reflect composition shifts. For example, a tumor with heavy immune infiltration will show elevated immune cell markers. If you interpret this as a cancer-specific change, you will miss the real biology. The same problem appears in blood studies where white blood cell counts vary between patients or between time points.
The practical consequence is that differential expression results can be entirely driven by composition. This matters for any study comparing tissues, blood, or biopsies across conditions. It also matters for longitudinal studies where the same animal or patient is sampled at different times, because immune status and tissue remodeling change composition over time.
Batch Effects and Their Sources
Batch effects arise from any systematic difference in how samples are collected, stored, or processed. Common sources include RNA extraction on different days, different reagent lots, different sequencing runs, different operators, and even seasonal or circadian variation in the animals themselves. The key feature is that the effect is systematic, meaning it affects all samples in a batch in a similar way.
The danger is that batch often correlates with the biological variable of interest. If you collect all control samples in January and all treated samples in February, the month is a batch. If you process all control samples on one day and all treated samples on the next, the day is a batch. If you run all control samples on one sequencing lane and all treated samples on another, the lane is a batch. In each case, the batch effect is completely confounded with the treatment effect, and no computational method can separate them.
The solution is to randomize sample collection and processing across batches. This means collecting and processing control and treated samples on the same days, in the same runs, and in interleaved order. When randomization is impossible, you must record the batch structure and include it in the statistical model.
At a Glance
| Confounder | How It Distorts Results | Detection Method | Practical Control |
|---|---|---|---|
| Cell type composition | Expression differences reflect cell proportions, not cell biology | Estimate cell type fractions from marker genes or reference profiles | Record histology, cell counts, or flow cytometry data, adjust statistically |
| Batch effects | Systematic processing differences mimic or mask treatment effects | Principal component analysis, clustering by processing date | Randomize processing order, include batch as a covariate |
| Circadian rhythm | Time of day changes expression in many tissues | Record collection time for every sample | Collect all samples within a narrow time window or model time as a covariate |
Core Principles for Reliable Gene Expression Analysis
Design Experiments to Prevent Confounds
The most important decisions happen before any RNA is extracted. Define the comparison groups, the sample size, and the tissue collection protocol. Randomize the order of sample collection and processing across groups. Record every detail that could vary systematically, including the date, time, operator, reagent lot, and equipment used.
For animal studies, consider the circadian rhythm. Many genes show strong daily expression patterns, so collecting all control samples in the morning and all treated samples in the afternoon will create a time-of-day effect that is indistinguishable from the treatment effect. Collect samples from both groups at the same time of day, or record the time and include it in the model.
For tissue studies, record the exact anatomical location and the method of dissection. Different regions of the same organ can have very different expression profiles. If you compare a tumor sample from one location to a normal sample from another location, the location difference will be part of the expression difference.
Record Metadata as Part of the Data
Metadata is the information about each sample that is not the expression measurement itself. This includes the animal identifier, the treatment group, the collection date and time, the tissue type, the extraction batch, the sequencing batch, and any other processing details. Metadata must be recorded in a structured format that can be imported into your analysis software.
The failure pattern is to record metadata in a lab notebook or a spreadsheet that is not linked to the expression data. When the analysis begins, the metadata is incomplete or inconsistent, and the batch structure cannot be reconstructed. The solution is to create a sample manifest before the experiment starts and update it as samples are collected and processed.
Use Cell Type Composition Estimates
When tissue composition is expected to vary between groups, you can estimate the cell type proportions from the expression data itself. This is done using reference profiles of purified cell types or marker genes. The estimated proportions are then included in the differential expression model as covariates.
This approach has limitations. The estimates are only as good as the reference profiles, and the reference profiles may not match the species, tissue, or cell types in your study. The estimates also assume that the reference profiles are accurate for your samples. When the reference profiles are not available, you can use histology or cell counts to measure composition directly.
Practical Workflow for Accounting for Confounders
Step 1: Record Sample Metadata
Create a metadata table with one row per sample. Include the sample identifier, the group, the collection time, the tissue site, the extraction batch, the sequencing batch, and any other processing detail. Verify the table against the physical samples before the analysis begins.
Step 2: Assess the Batch Structure
After the expression data is generated, examine the data for batch structure. A principal component analysis plot is a useful first check. If samples cluster by processing date, extraction batch, or sequencing run, the batch structure is present. If the clustering matches the treatment groups, the batch is confounded with the treatment.
Step 3: Estimate Cell Composition
If the tissue composition is expected to vary, estimate the cell type proportions. Use a reference-based method when reference profiles are available. When reference profiles are not available, use histology or cell counts to assess composition directly. Record the composition estimates in the metadata table.
Step 4: Include Confounders in the Model
Fit the differential expression model with the treatment group as the variable of interest and the batch and composition as covariates. The model will then estimate the treatment effect while adjusting for the batch and composition differences. This is the standard approach for accounting for known confounders.
Step 5: Validate the Results
Check that the results are stable. Repeat the analysis without the covariates and compare the results. If the results change substantially, the confounders are driving the findings. If the results are stable, the findings are more likely to reflect the biological variable of interest.
Records and Measurements
What to Record
| Record Type | Specific Data | Why It Matters |
|---|---|---|
| Sample collection | Date, time, animal, tissue site | Identifies circadian and anatomical confounds |
| Processing | Extraction date, reagent lot, operator | Identifies batch effects |
| Sequencing | Run date, lane, instrument | Identifies technical batch effects |
| Composition | Histology, cell counts, or estimated proportions | Identifies composition confounds |
| Analysis | Model formula, software version, parameters | Ensures reproducibility |
How to Use the Records
The records are used at every stage of the analysis. The metadata table is the input for the statistical model. The batch structure is identified from the processing records. The composition estimates are used as covariates. The analysis records are used to reproduce the results and to report the methods.
Common Failure Patterns
Failure Pattern 1: Confounded Batch and Treatment
The most common failure is when the batch is completely confounded with the treatment. This happens when all control samples are processed in one batch and all treated samples in another. No statistical method can separate the batch effect from the treatment effect. The only solution is to redesign the experiment and randomize the processing order.
Failure Pattern 2: Ignoring Cell Composition
The second common failure is ignoring cell composition. This happens when the tissue composition varies between groups and the composition is not measured or adjusted. The results show expression differences that are driven by composition, and the biological interpretation is wrong.
Failure Pattern 3: Incomplete Metadata
The third common failure is incomplete metadata. The analysis cannot adjust for a batch if the batch is not recorded. The analysis cannot adjust for collection time if the time is not recorded. The solution is to create the metadata table before the analysis begins and to update it as samples are collected.
Failure Pattern 4: Overcorrecting the Data
The fourth failure is overcorrecting. When you include too many covariates in the model, you can remove the biological signal along with the confound. This happens when the covariate is correlated with the treatment. The solution is to include only the covariates that are known to be confounded and to check the results without the covariates.
Welfare and Safety Context
Animal Welfare in Sample Collection
The collection of tissue samples from animals must follow the approved protocols and the institutional animal care guidelines. The collection time and the tissue site must be recorded to ensure the biological validity of the study. The welfare of the animal is the primary consideration, and the sample collection must not cause unnecessary pain or distress.
Laboratory Safety in Sample Processing
The processing of tissue samples involves the use of chemical reagents and biological materials. The laboratory staff must follow the safety protocols for the handling of these materials. The processing records must include the operator and the date to ensure the traceability of the samples.
Professional Escalation Criteria
When the analysis results are inconsistent with the biological expectations, the results should be reviewed by a senior investigator or a biostatistician. When the batch structure is confounded with the treatment, the experiment should be redesigned. When the cell composition estimates are unreliable, the composition should be measured directly. The escalation criteria are based on the evidence and the professional judgment of the investigator.
Career Context for Computational Biologists
The Role of the Computational Biologist
The computational biologist is the person who analyzes the gene expression data and interprets the results. The role requires a combination of biological knowledge and computational skills. The computational biologist must understand the biological sources of variation and the statistical methods for adjusting for them. The role is found in academic laboratories, government agencies, and private companies.
Skills and Training
The computational biologist needs training in statistics, programming, and biology. The training can come from a degree in bioinformatics, computational biology, or a related field. The U.S. Bureau of Labor Statistics provides information on the education pathways and the work settings for these roles. The National Institutes of Health provides training and career development opportunities for research scientists.
Work Settings
The computational biologist works in a variety of settings. The work can be in a university laboratory, a government research agency, or a private company. The U.S. National Science Foundation and the National Institutes of Health employ computational biologists for research and program work. The American Society for Microbiology provides career development resources for the microbiology and bioinformatics community.
Career Development
The computational biologist can develop a career through training, networking, and professional development. The National Institutes of Health provides mentoring and training programs for the research career. The American Society for Microbiology provides networking and career resources. The Association of American Veterinary Medical Colleges provides career resources for the veterinary research field.
Decision Framework for Choosing Confounder Adjustment Methods
Selecting the wrong adjustment method can distort results as severely as ignoring the confounder entirely. A practical decision framework helps you match the method to the data structure you actually have, instead of defaulting to the most popular tool. The framework below uses three diagnostic questions to guide method selection, and it applies to both cell type composition and batch effects.
Question 1: Is the Confounder Measured or Unmeasured?
The first decision point is whether you have direct measurements of the confounder. For cell type composition, direct measurements include flow cytometry cell counts, complete blood counts, or histology-based cell proportions. For batch effects, the measurement is the batch assignment itself, which you record during sample processing.
When the confounder is measured, use the direct measurement as a covariate in the differential expression model. This is the simplest and most interpretable approach. When the confounder is unmeasured, you must estimate it from the expression data or use a method that does not require the measurement.
For cell type composition without direct measurements, reference-based deconvolution estimates the proportions from marker gene expression. This method requires a reference profile of purified cell types that matches your species and tissue. When no reference profile exists, you can use marker gene sets without a full reference, but the estimates are less reliable.
For batch effects without recorded batch assignments, surrogate variable analysis can estimate hidden factors that capture the technical variation. This approach is useful when the batch structure was not recorded, but it is less interpretable than using the recorded batch as a covariate.
Decision Question 2: Is the Confounder Confounded with the Treatment?
The second question is whether the confounder is correlated with the treatment group. This is the most dangerous situation because the confounder and the treatment effect are entangled. The answer determines whether adjustment is possible at all.
If the confounder is completely confounded, meaning all control samples are in one batch and all treated samples in another, no adjustment method can separate the effects. The same applies to cell type composition if all control samples come from one tissue region and all treated samples from another. In this case, the only valid action is to redesign the experiment.
If the confounder is partially confounded, meaning the batches or composition overlap between groups, adjustment is possible. The model can estimate the treatment effect while accounting for the confounder because the data contains information about both.
The practical test is to cross-tabulate the treatment groups against the batch assignments or the composition ranges. If every treatment group appears in every batch, the confound is partial. If the groups are separated, the confound is complete.
Decision Question 3: What Is the Sample Size and Model Complexity?
The third question is whether the sample size supports the adjustment method. Every covariate added to a model consumes degrees of freedom. With small sample sizes, adding many covariates can overfit the model and produce unstable estimates.
For a study with fewer than ten samples per group, limit the model to the treatment variable and one or two confounders. Adding cell type composition estimates and batch as separate covariates may be too many for the data to support.
For a study with more than twenty samples per group, the model can accommodate multiple confounders. The composition estimates can be included as continuous covariates, and the batch can be included as a categorical covariate.
The sample size also affects the choice of composition estimation method. Reference-based methods require enough samples to estimate the proportions reliably. With very small sample sizes, direct measurement of composition through histology or cell counts is more reliable than computational estimation.
Method Selection Table
| Data Situation | Recommended Method | Key Limitation |
|---|---|---|
| Composition measured directly | Include composition as a covariate in the model | Requires the measurement to be accurate and complete |
| Composition not measured, reference available | Reference-based deconvolution, include estimates as covariates | Estimates depend on reference profile quality |
| Composition not measured, no reference | Use marker gene sets or measure composition directly | Less reliable than reference-based methods |
| Batch recorded and partially confounded | Include batch as a covariate in the model | Cannot fix complete confounding |
| Batch not recorded | Surrogate variable analysis or principal component adjustment | Less interpretable than direct batch adjustment |
| Small sample size | Limit covariates to the most important confounder | Risk of overfitting with too many covariates |
Troubleshooting Method Failures
When the Adjustment Does Not Change the Results
If the results are identical with and without the adjustment, the confounder may not be present, or the adjustment may not be capturing the variation. Check the composition estimates or the batch structure to confirm the confounder exists. If the confounder is present but the adjustment does not change the results, the confounder may not be correlated with the treatment, and the adjustment is unnecessary.
When the Adjustment Changes the Results Too Much
If the adjustment removes the treatment effect entirely, the confounder may be correlated with the treatment, and the adjustment may be removing the biological signal. This is the overcorrection failure pattern. The solution is to examine the correlation between the confounder and the treatment. If the correlation is high, the experiment may need to be redesigned.
When the Composition Estimates Are Unreliable
If the composition estimates vary widely between similar samples, the reference profile may not match the data. Check the reference profile against the known biology of the tissue. If the reference profile is not appropriate, measure the composition directly with histology or cell counts.
Implementation Steps for the Decision Framework
Step 1: Document the Confounder Status
Create a table that lists each potential confounder and its measurement status. For cell type composition, record whether direct measurements exist, whether a reference profile is available, and whether the composition is expected to vary between groups. For batch effects, record the batch assignments and whether the batches overlap with the treatment groups.
Step 2: Apply the Decision Questions
For each confounder, answer the three questions. Record the answers in the table. The answers determine the adjustment method.
Step 3: Select the Method and Fit the Model
Select the adjustment method based on the answers. Fit the model with the treatment variable and the selected confounder adjustment. Record the model formula and the software version.
Step 4: Compare the Adjusted and Unadjusted Results
Fit the model without the confounder adjustment and compare the results. If the results change substantially, the confounder is driving the findings. If the results are stable, the findings are more likely to reflect the biological variable of interest.
Step 5: Document the Decision
Record the decision framework answers and the selected method in the analysis records. This documentation is essential for reproducibility and for the review by a senior investigator or a biostatistician.
Records for the Decision Framework
| Record Type | Specific Data | Why It Matters |
|---|---|---|
| Confounder status | Measured or unmeasured for each confounder | Determines the adjustment method |
| Batch structure | Batch assignments and overlap with treatment | Determines whether adjustment is possible |
| Composition estimates | Method used and reference profile | Determines the reliability of the estimates |
| Model selection | Decision framework answers and method chosen | Ensures reproducibility |
| Validation results | Adjusted and unadjusted comparison | Identifies whether the confounder drives the results |
Common Failure Patterns in Method Selection
Failure Pattern 1: Using the Wrong Method for the Data
The most common failure is using a reference-based deconvolution method when no reference profile is available for the tissue or species. The estimates are unreliable, and the adjustment produces misleading results. The solution is to check the reference profile availability before selecting the method.
Failure Pattern 2: Adjusting for a Confounder That Is Not Present
The second failure is including a confounder in the model when the confounder does not vary between groups. The adjustment consumes degrees of freedom and can reduce the power to detect the treatment effect. The solution is to check the confounder variation before including it in the model.
Failure Pattern 3: Ignoring the Sample Size
The third failure is including too many confounders in the model when the sample size is small. The model overfits the data, and the results are unstable. The solution is to limit the model to the most important confounder when the sample size is small.
Failure Pattern 4: Not Documenting the Method Selection
The fourth failure is not recording the decision framework answers and the selected method. The analysis cannot be reproduced, and the review by a senior investigator is difficult. The solution is to document the method selection in the analysis records.
Professional Escalation Criteria
The decision framework results should be reviewed by a senior investigator or a biostatistician when the adjusted and unadjusted results differ substantially, when the composition estimates are unreliable, or when the batch structure is completely confounded with the treatment. The escalation is a professional judgment based on the quality of the data and the stability of the results. The review should include the decision framework answers, the model formula, and the comparison of the adjusted and unadjusted results.
Frequently Asked Questions
What is the most common cause of misleading gene expression results?
The most common cause is a confound between the biological variable of interest and a technical or biological source of variation. The two most frequent confounds are the cell type composition and the batch effects. Both can produce expression differences that are not related to the biological question.
How do I know if my data has a batch effect?
You can examine the data with a principal component analysis. If the samples cluster by the processing batch instead of by the treatment group, the batch effect is present. You can also compare the expression of the known control genes across the batches.
Can I correct for a batch effect after the data is collected?
You can correct for a batch effect if the batch is recorded and the batch is not completely confounded with the treatment. The correction is done by including the batch as a covariate in the model. If the batch is completely confounded, no correction is possible.
What is cell type composition and why does it matter?
Cell type composition is the proportion of different cell types in a tissue sample. It matters because each cell type has a distinct expression profile. When the composition varies between groups, the expression differences reflect the composition changes.
How do I estimate the cell type composition?
You can estimate the composition with a reference-based method that uses the expression profiles of the known cell types. You can also measure the composition directly with histology or cell counts. The choice depends on the availability of the reference profiles.
What is the difference between a batch effect and a biological effect?
A batch effect is a technical variation that is introduced by the processing of the samples. A biological effect is a variation that is caused by the biology of the samples. The two are often confounded, and the goal of the analysis is to separate them.
When should I escalate the analysis to a senior investigator?
You should escalate the analysis when the results are inconsistent with the biological expectations, when the batch is confounded with the treatment, or when the composition estimates are not supported by the data. The escalation is a professional judgment based on the quality of the data.
What training is available for a career in computational biology?
The training is available through degree programs in bioinformatics and computational biology. The National Institutes of Health and the American Society for Microbiology provide training and career development resources. The U.S. Bureau of Labor Statistics provides information about the education pathways and the work settings.
Related Articles
- Computational Biologist Job Description: Skills, Deliverables, and Team Context
- Vertex Pharmaceuticals Careers: A Guide to Roles in CF, Sickle Cell, and Gene Editing
- Common Mistakes in Meta-Analysis and How to Avoid Them
- Ethical Concerns in Research: Common Pitfalls and How to Avoid Them
- Ethical Issues in Informed Consent: Common Pitfalls and How to Avoid Them
References and Further Reading
- Occupational Outlook Handbook. U.S. Bureau of Labor Statistics.
- O*NET OnLine. U.S. Department of Labor.
- Office of Intramural Training and Education. National Institutes of Health.
- Careers at NSF. U.S. National Science Foundation.
- Career Services. American Society for Microbiology.
- AAVMC Career Resources. Association of American Veterinary Medical Colleges.
- NCBI Literature Resources. National Center for Biotechnology Information.
- PubMed. National Library of Medicine.
This article is educational and does not replace institutional policy, professional advice, or applicable safety and regulatory requirements.