[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ET147WE2N69DGCP4KXVQA3":3,"skill-same:01M7ET147WE2N69DGCP4KXVQA3":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7ET147WE2N69DGCP4KXVQA3","bio-experimental-design-randomization-blocking",null,"Structures biological experiments so inference is valid by construction, covering Fisher's principles (randomization, replication, local control), the experimental-vs-observational unit distinction and pseudoreplication (Hurlbert 1984; Lazic 2018), randomization mechanics (complete, restricted, stratified, rerandomization, run-order), blocking layouts (randomized complete block, Latin square, incomplete block), factorial designs and interactions, and the split-plot\u002Fnested error strata hidden inside multi-batch genomics. Use when deciding the experimental unit and what counts as a replicate, planning randomization and run order, choosing a blocked\u002Ffactorial\u002Fsplit-plot\u002Fnested layout, avoiding pseudoreplication in cell-culture or animal studies, or specifying the random-effects structure of the analysis model. For assigning samples to sequencing batches\u002Flanes\u002Fplates and batch-effect correction see experimental-design\u002Fbatch-design; for regulated clinical-trial randomization see clinical-biostatistics.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fdesign\u002Fbio-experimental-design-randomization-blocking\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-experimental-design-randomization-blocking\ndescription: Structures biological experiments so inference is valid by construction, covering Fisher's principles (randomization, replication, local control), the experimental-vs-observational unit distinction and pseudoreplication (Hurlbert 1984; Lazic 2018), randomization mechanics (complete, restricted, stratified, rerandomization, run-order), blocking layouts (randomized complete block, Latin square, incomplete block), factorial designs and interactions, and the split-plot\u002Fnested error strata hidden inside multi-batch genomics. Use when deciding the experimental unit and what counts as a replicate, planning randomization and run order, choosing a blocked\u002Ffactorial\u002Fsplit-plot\u002Fnested layout, avoiding pseudoreplication in cell-culture or animal studies, or specifying the random-effects structure of the analysis model. For assigning samples to sequencing batches\u002Flanes\u002Fplates and batch-effect correction see experimental-design\u002Fbatch-design; for regulated clinical-trial randomization see clinical-biostatistics.\ntool_type: r\nprimary_tool: designit\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"experimental-design\u002Frandomization-blocking\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: designit 0.5+, lme4 1.1-35+, lmerTest 3.1+, pwr 1.3+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- R: `packageVersion('\u003Cpkg>')` then `?function_name` to verify parameters\n\nIf code throws an error, introspect the installed package and adapt the example to the actual API rather than retrying. designit is an R6 package whose `BatchContainer$new()`, `optimize_design()`, and `*_score_generator()` signatures evolve between releases; confirm against the installed vignette (`vignette(package = 'designit')`) before relying on argument names.\n\n# Randomization and Blocking\n\n**\"Design the experiment so the statistics will be valid\"** -> Decide what the experimental unit is, randomize treatments to those units, replicate the unit (not the measurement), and remove known nuisance variation by blocking — so that the analysis model mirrors how the experiment was actually run.\n- R: `designit::optimize_design()` for constrained randomization; `lme4::lmer()` \u002F `lmerTest` for the matching mixed model\n- The design and the analysis are one decision: \"analyze as randomized\"\n\n## The Single Most Important Modern Insight -- The Experimental Unit, Not the Measurement, Is the n\n\nThe most consequential and most violated idea in biological design: the **experimental unit (EU)** is the smallest entity *independently assigned to a treatment* — and it, not the number of measurements, is the sample size for inference. Lazic 2018 *PLoS Biol* 16:e2005282 separates three entities: the **biological unit** (what conclusions are about), the **experimental unit** (what randomization acts on, = the n), and the **observational unit** (what is measured). When observational units are counted as independent replicates, the standard error shrinks illegitimately and p-values become meaningless — **pseudoreplication** (Hurlbert 1984 *Ecol Monogr* 54:187). Ten thousand cells from three mice are n = 3, not n = 10,000, for a between-mouse question; mice co-housed in a cage dosed through the chow make the *cage* the EU, not the mouse. Lazic et al. found ~46% of surveyed animal studies pseudoreplicated. The fix is structural: model the design's hierarchy (random effects) or aggregate to the EU before testing — pseudoreplication is, formally, an omitted random effect.\n\nA second, deeper point (Fisher): **randomization is what licenses the p-value.** It supplies the physical basis for the error term and converts systematic lurking-variable bias into random error balanced *in expectation*. Model-based tests are approximations to the randomization distribution. Skip randomization and the causal claim rests entirely on assumptions.\n\n## Algorithmic Taxonomy\n\n| Design | Controls \u002F estimates | When to use | Fails \u002F costs when |\n|--------|----------------------|-------------|--------------------|\n| Completely randomized (CRD) | error variance only | units homogeneous; no known nuisance | inefficient if real nuisance structure exists |\n| Randomized complete block (RCBD) | one known nuisance (day, litter, chip, donor) | nuisance factor identifiable and blockable | costs error df; harmful if block variance is ~0 (\"blocking on noise\") |\n| Latin square | two orthogonal nuisances (day x technician) | n² runs affordable for n treatments | assumes no interaction among row\u002Fcol\u002Ftreatment |\n| (Balanced) incomplete block | one nuisance, block smaller than #treatments | plate\u002Fchip holds fewer samples than treatments | analysis more complex; needs balance for efficiency |\n| Factorial | main effects + interactions, \"hidden replication\" | >1 factor; interaction is of interest | #runs grows multiplicatively |\n| Fractional factorial \u002F screening | main effects under sparsity-of-effects | many factors, few runs (Plackett-Burman) | aliases effects; cannot resolve all interactions |\n| Split-plot | two EU sizes, two error strata | one factor hard to randomize finely (lane, incubator, batch) | wrong error term if analyzed as a flat factorial -> anti-conservative |\n| Nested \u002F hierarchical | variance components across levels | sub-sampling within units (cells in mice in cages) | pseudoreplication if the nesting is ignored |\n| Repeated measures | within-unit change over time | longitudinal sampling of the same EU | a split-plot in time; needs the within-unit error term |\n\n## Decision Tree by Scenario\n\n| Scenario | Recommended structure | Why |\n|----------|----------------------|-----|\n| Treatment given per animal, one tissue measured each | CRD or RCBD; n = animals | EU = animal |\n| Many cells measured per animal, between-animal question | nested; aggregate to per-animal (pseudobulk) before testing | EU = animal, cells are observational units |\n| Treatment delivered per cage (chow\u002Fwater), several mice\u002Fcage | EU = cage; block or model cage as random | randomization acted on the cage |\n| Two factors of interest (genotype x drug) | factorial; estimate the interaction | main effects uninterpretable if interaction is large |\n| One factor fixed per run (incubator temp, sequencing lane) | split-plot; whole-plot = run, sub-plot = sample | two error strata; test whole-plot against whole-plot error |\n| Known batch\u002Fday nuisance, all conditions fit per block | RCBD; include block in the model | removes nuisance from error; \"analyze as randomized\" |\n| Plate holds fewer samples than conditions | incomplete block + include block term | balance preserves estimability |\n| Assigning samples to sequencing batches\u002Flanes | -> experimental-design\u002Fbatch-design | constrained sample-to-batch allocation lives there |\n| Regulated clinical trial randomization | -> clinical-biostatistics | confirmatory\u002Fregulated regime out of scope |\n\n## Choosing and Counting the Experimental Unit\n\n**Goal:** Identify the EU and therefore the true n before any power or analysis decision.\n\n**Approach:** Trace the randomization: the EU is the smallest entity to which a treatment level was independently assigned. Anything measured below that level is an observational unit and is summarized (mean\u002Fsum) up to the EU, or modeled as a nested random effect — never counted as an independent replicate.\n\n```r\n# Between-condition question with multiple cells per donor:\n# the donor is the experimental unit, NOT the cell.\n# Correct: aggregate observational units to the EU, then test on EU-level values.\nlibrary(dplyr)\neu_level \u003C- cells |>\n  group_by(donor, condition) |>\n  summarise(value = mean(measurement), .groups = 'drop')   # one row per experimental unit\n# n for inference = number of donors per condition, not number of cells\n```\n\n## Randomization Mechanics\n\n**Goal:** Assign treatments to units with a documented random mechanism, optionally restricted to guarantee balance on known factors.\n\n**Approach:** Use a seeded pseudo-random generator (never \"haphazard\" order, which aliases treatment with processing position\u002Ftime). For known prognostic factors, restrict the randomization (block\u002Fstratify) and then *include those factors in the model*. When finite-sample imbalance matters, rerandomize against a pre-specified balance criterion (Morgan & Rubin 2012 *Ann Stat* 40:1263) or use minimization for sequential enrollment (Pocock & Simon 1975 *Biometrics* 31:103).\n\n```r\nset.seed(20260528)                      # record the seed for reproducibility\nunits \u003C- data.frame(id = sprintf('S%02d', 1:24),\n                    block = rep(c('day1','day2','day3'), each = 8))\n\n# Restricted (block) randomization: randomize treatment WITHIN each block\nunits$treatment \u003C- ave(units$id, units$block,\n                       FUN = function(ids) sample(rep(c('ctrl','treat'),\n                                                      length.out = length(ids))))\n# Also randomize RUN ORDER so processing position is not confounded with treatment\nunits$run_order \u003C- sample(nrow(units))\n```\n\n## Blocking and Local Control\n\n**Goal:** Remove a known nuisance source from the error term to sharpen the treatment comparison.\n\n**Approach:** Group units into homogeneous blocks (day, litter, chip, donor), randomize treatments within block, and add the block as a term in the model. The paired t-test is the special case of an RCBD with block size 2. Block only on factors with real between-block variation; blocking on a noise factor spends error df for nothing.\n\n```r\nlibrary(designit)                        # constrained assignment; verify API vs installed vignette\nbc \u003C- BatchContainer$new(dimensions = list(block = 3, position = 8))\nbc \u003C- assign_in_order(bc, samples = units)\nbc \u003C- optimize_design(\n  bc,\n  scoring = osat_score_generator(batch_vars = 'block',\n                                 feature_vars = c('treatment')))  # balance treatment across blocks\n```\n\n## Split-Plot and Nested Designs -- the Genomics Trap\n\nA **split-plot** has two experimental-unit sizes and therefore two error strata: a *whole-plot* factor that is hard to randomize finely (incubator temperature, the sequencing run\u002Flane, the 10x chip, the staining batch) and a *sub-plot* factor randomized within each whole plot (the individual sample, the genotype). Analyzing a split-plot as a flat factorial uses the wrong, too-small error term for the whole-plot factor and gives **anti-conservative** tests for exactly the factor that was hardest to replicate. In genomics the lane\u002Frun\u002Fchip is almost always a whole plot; \"batch effects\" are frequently a split-plot structure to be modeled, not a nuisance to scrub.\n\n**Goal:** Match the model's random-effects structure to the design's randomization structure.\n\n**Approach:** Encode each randomization level as a random effect; fixed effects carry the questions. Crossed vs nested structure determines the denominator for each fixed effect; with few EUs use Satterthwaite or Kenward-Roger degrees of freedom (lmerTest \u002F pbkrtest).\n\n```r\nlibrary(lme4); library(lmerTest)\n# Whole plot = run (random); sub-plot factor = condition (fixed); cells nested in sample\nfit \u003C- lmer(expression ~ condition + (1 | run\u002Fsample), data = df)   # run, and sample within run\nanova(fit)                               # Satterthwaite df via lmerTest\n```\n\n## Factorial Designs and Interactions\n\nA factorial design crosses factors so every observation informs every main effect (\"hidden replication\") and, uniquely, estimates **interactions** — the joint action one-factor-at-a-time (OFAT) cannot see. When an interaction is large, main effects are not interpretable alone; reporting a main effect while ignoring a strong interaction is the most common misreading of a 2x2 design. OFAT is less efficient and silently assumes additivity.\n\n## Per-Method Failure Modes\n\n### Pseudoreplication (observational units counted as n)\n- **Trigger:** treating cells\u002Fwells\u002Fsections\u002Ftechnical aliquots as independent replicates.\n- **Mechanism:** units within an EU are correlated; the SE is computed as if they were independent (Hurlbert 1984; Lazic 2018).\n- **Symptom:** implausibly small p-values that fail to replicate; reviewers ask \"what is n?\".\n- **Fix:** aggregate to the EU (pseudobulk) or add the EU as a random effect; the n is the number of EUs.\n\n### Split-plot analyzed as a flat factorial\n- **Trigger:** lane\u002Frun\u002Fincubator factor crossed with a within-run factor, fit with one error term.\n- **Mechanism:** whole-plot factor tested against sub-plot error (too small).\n- **Symptom:** the hard-to-randomize factor looks significant on thin evidence.\n- **Fix:** two-stratum model; whole-plot factor uses whole-plot error (`(1 | run)`).\n\n### Haphazard assignment mistaken for randomization\n- **Trigger:** processing units \"in the order they arrived\".\n- **Mechanism:** order aliases treatment with time\u002Fposition\u002Ftemperature gradients.\n- **Symptom:** apparent treatment effect tracks run order.\n- **Fix:** seeded PRNG assignment; randomize run order too; record the seed.\n\n### Blocking on a noise factor\n- **Trigger:** adding a block term with negligible between-block variance.\n- **Mechanism:** spends error df without removing variance.\n- **Symptom:** power lower than the unblocked design.\n- **Fix:** block only on factors with documented between-block variation.\n\n### Over-\u002Funder-specified random effects\n- **Trigger:** maximal random structure that will not converge, or a structure missing a randomization level.\n- **Mechanism:** maximal protects Type-I but may be singular (Barr 2013); too-lean inflates Type-I (pseudoreplication).\n- **Symptom:** singular-fit warnings, or anti-conservative tests.\n- **Fix:** keep the structure justified by the design; for small EU counts prune by a selection criterion (Matuschek 2017) and report the choice.\n\n## Quantitative Thresholds\n\n| Threshold | Source | Rationale |\n|-----------|--------|-----------|\n| EU = level of independent treatment assignment | Hurlbert 1984; Lazic 2018 | defines the n for inference |\n| Paired design = RCBD with block size 2 | Fisher; standard | pairing is blocking |\n| Latin square needs n² runs for n treatments | standard design theory | controls two nuisances orthogonally |\n| Use Kenward-Roger\u002FSatterthwaite df when EU count is small (roughly \u003C ~10\u002Fgroup) | Kenward & Roger 1997 *Biometrics* 53:983 | naive F df are anti-conservative with few units |\n| Maximal random effects for confirmatory; prune for small samples | Barr 2013; Matuschek 2017 | Type-I protection vs convergence\u002Fpower tradeoff |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Significant result that will not replicate | pseudoreplication (cells as n) | aggregate to EU or add EU random effect |\n| Whole-plot factor over-significant | split-plot analyzed flat | two-stratum mixed model |\n| Treatment effect tracks processing order | no run-order randomization | seeded randomization of run order |\n| Blocked design analyzed without block term | \"design but don't analyze\" | include block in the model; analyze as randomized |\n| Main effect reported despite strong interaction | factorial misread | interpret simple effects within the interaction |\n| Mixed model singular fit | over-specified random effects | prune to the design-justified structure (Matuschek 2017) |\n\n## References\n\n- Hurlbert SH. 1984. Pseudoreplication and the design of ecological field experiments. *Ecol Monogr* 54:187-211.\n- Lazic SE, Clarke-Williams CJ, Munafò MR. 2018. What exactly is 'N' in cell culture and animal experiments? *PLoS Biol* 16:e2005282.\n- Blainey P, Krzywinski M, Altman N. 2014. Points of significance: replication. *Nat Methods* 11:879-880.\n- Krzywinski M, Altman N. 2014. Points of significance: designing comparative experiments. *Nat Methods* 11:597-598.\n- Krzywinski M, Altman N. 2014. Points of significance: analysis of variance and blocking. *Nat Methods* 11:699-700.\n- Morgan KL, Rubin DB. 2012. Rerandomization to improve covariate balance in experiments. *Ann Stat* 40:1263-1282.\n- Pocock SJ, Simon R. 1975. Sequential treatment assignment with balancing for prognostic factors in the controlled clinical trial. *Biometrics* 31:103-115.\n- Barr DJ, Levy R, Scheepers C, Tily HJ. 2013. Random effects structure for confirmatory hypothesis testing: keep it maximal. *J Mem Lang* 68:255-278.\n- Matuschek H, Kliegl R, Vasishth S, Baayen H, Bates D. 2017. Balancing Type I error and power in linear mixed models. *J Mem Lang* 94:305-315.\n- Kenward MG, Roger JH. 1997. Small sample inference for fixed effects from restricted maximum likelihood. *Biometrics* 53:983-997.\n- Auer PL, Doerge RW. 2010. Statistical design and analysis of RNA sequencing data. *Genetics* 185:405-416.\n\n## Related Skills\n\n- batch-design - Assigning samples to sequencing batches\u002Flanes and batch-effect correction\n- sample-size - The experimental unit defines what is replicated and counted\n- power-analysis - Blocking and nesting change the effective error variance\n- multiple-testing - The design fixes what counts as a family of tests\n- single-cell\u002Fpreprocessing - Pseudobulk aggregation to the donor (experimental unit) for scRNA-seq\n- differential-expression\u002Fdeseq2-basics - The DE model that consumes the design's structure\n- clinical-biostatistics\u002Fpower-and-sample-size - Randomization and design in the regulated-trial regime\n","## Version Compatibility\n\nReference examples tested with: designit 0.5+, lme4 1.1-35+, lmerTest 3.1+, pwr 1.3+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- R: `packageVersion('\u003Cpkg>')` then `?function_name` to verify parameters\n\nIf code throws an error, introspect the installed package and adapt the example to the actual API rather than retrying. designit is an R6 package whose `BatchContainer$new()`, `optimize_design()`, and `*_score_generator()` signatures evolve between releases; confirm against the installed vignette (`vignette(package = 'designit')`) before relying on argument names.\n\n# Randomization and Blocking\n\n**\"Design the experiment so the statistics will be valid\"** -> Decide what the experimental unit is, randomize treatments to those units, replicate the unit (not the measurement), and remove known nuisance variation by blocking — so that the analysis model mirrors how the experiment was actually run.\n- R: `designit::optimize_design()` for constrained randomization; `lme4::lmer()` \u002F `lmerTest` for the matching mixed model\n- The design and the analysis are one decision: \"analyze as randomized\"\n\n## The Single Most Important Modern Insight -- The Experimental Unit, Not the Measurement, Is the n\n\nThe most consequential and most violated idea in biological design: the **experimental unit (EU)** is the smallest entity *independently assigned to a treatment* — and it, not the number of measurements, is the sample size for inference. Lazic 2018 *PLoS Biol* 16:e2005282 separates three entities: the **biological unit** (what conclusions are about), the **experimental unit** (what randomization acts on, = the n), and the **observational unit** (what is measured). When observational units are counted as independent replicates, the standard error shrinks illegitimately and p-values become meaningless — **pseudoreplication** (Hurlbert 1984 *Ecol Monogr* 54:187). Ten thousand cells from three mice are n = 3, not n = 10,000, for a between-mouse question; mice co-housed in a cage dosed through the chow make the *cage* the EU, not the mouse. Lazic et al. found ~46% of surveyed animal studies pseudoreplicated. The fix is structural: model the design's hierarchy (random effects) or aggregate to the EU before testing — pseudoreplication is, formally, an omitted random effect.\n\nA second, deeper point (Fisher): **randomization is what licenses the p-value.** It supplies the physical basis for the error term and converts systematic lurking-variable bias into random error balanced *in expectation*. Model-based tests are approximations to the randomization distribution. Skip randomization and the causal claim rests entirely on assumptions.\n\n## Algorithmic Taxonomy\n\n| Design | Controls \u002F estimates | When to use | Fails \u002F costs when |\n|--------|----------------------|-------------|--------------------|\n| Completely randomized (CRD) | error variance only | units homogeneous; no known nuisance | inefficient if real nuisance structure exists |\n| Randomized complete block (RCBD) | one known nuisance (day, litter, chip, donor) | nuisance factor identifiable and blockable | costs error df; harmful if block variance is ~0 (\"blocking on noise\") |\n| Latin square | two orthogonal nuisances (day x technician) | n² runs affordable for n treatments | assumes no interaction among row\u002Fcol\u002Ftreatment |\n| (Balanced) incomplete block | one nuisance, block smaller than #treatments | plate\u002Fchip holds fewer samples than treatments | analysis more complex; needs balance for efficiency |\n| Factorial | main effects + interactions, \"hidden replication\" | >1 factor; interaction is of interest | #runs grows multiplicatively |\n| Fractional factorial \u002F screening | main effects under sparsity-of-effects | many factors, few runs (Plackett-Burman) | aliases effects; cannot resolve all interactions |\n| Split-plot | two EU sizes, two error strata | one factor hard to randomize finely (lane, incubator, batch) | wrong error term if analyzed as a flat factorial -> anti-conservative |\n| Nested \u002F hierarchical | variance components across levels | sub-sampling within units (cells in mice in cages) | pseudoreplication if the nesting is ignored |\n| Repeated measures | within-unit change over time | longitudinal sampling of the same EU | a split-plot in time; needs the within-unit error term |\n\n## Decision Tree by Scenario\n\n| Scenario | Recommended structure | Why |\n|----------|----------------------|-----|\n| Treatment given per animal, one tissue measured each | CRD or RCBD; n = animals | EU = animal |\n| Many cells measured per animal, between-animal question | nested; aggregate to per-animal (pseudobulk) before testing | EU = animal, cells are observational units |\n| Treatment delivered per cage (chow\u002Fwater), several mice\u002Fcage | EU = cage; block or model cage as random | randomization acted on the cage |\n| Two factors of interest (genotype x drug) | factorial; estimate the interaction | main effects uninterpretable if interaction is large |\n| One factor fixed per run (incubator temp, sequencing lane) | split-plot; whole-plot = run, sub-plot = sample | two error strata; test whole-plot against whole-plot error |\n| Known batch\u002Fday nuisance, all conditions fit per block | RCBD; include block in the model | removes nuisance from error; \"analyze as randomized\" |\n| Plate holds fewer samples than conditions | incomplete block + include block term | balance preserves estimability |\n| Assigning samples to sequencing batches\u002Flanes | -> experimental-design\u002Fbatch-design | constrained sample-to-batch allocation lives there |\n| Regulated clinical trial randomization | -> clinical-biostatistics | confirmatory\u002Fregulated regime out of scope |\n\n## Choosing and Counting the Experimental Unit\n\n**Goal:** Identify the EU and therefore the true n before any power or analysis decision.\n\n**Approach:** Trace the randomization: the EU is the smallest entity to which a treatment level was independently assigned. Anything measured below that level is an observational unit and is summarized (mean\u002Fsum) up to the EU, or modeled as a nested random effect — never counted as an independent replicate.\n\n```r\n# Between-condition question with multiple cells per donor:\n# the donor is the experimental unit, NOT the cell.\n# Correct: aggregate observational units to the EU, then test on EU-level values.\nlibrary(dplyr)\neu_level \u003C- cells |>\n  group_by(donor, condition) |>\n  summarise(value = mean(measurement), .groups = 'drop')   # one row per experimental unit\n# n for inference = number of donors per condition, not number of cells\n```\n\n## Randomization Mechanics\n\n**Goal:** Assign treatments to units with a documented random mechanism, optionally restricted to guarantee balance on known factors.\n\n**Approach:** Use a seeded pseudo-random generator (never \"haphazard\" order, which aliases treatment with processing position\u002Ftime). For known prognostic factors, restrict the randomization (block\u002Fstratify) and then *include those factors in the model*. When finite-sample imbalance matters, rerandomize against a pre-specified balance criterion (Morgan & Rubin 2012 *Ann Stat* 40:1263) or use minimization for sequential enrollment (Pocock & Simon 1975 *Biometrics* 31:103).\n\n```r\nset.seed(20260528)                      # record the seed for reproducibility\nunits \u003C- data.frame(id = sprintf('S%02d', 1:24),\n                    block = rep(c('day1','day2','day3'), each = 8))\n\n# Restricted (block) randomization: randomize treatment WITHIN each block\nunits$treatment \u003C- ave(units$id, units$block,\n                       FUN = function(ids) sample(rep(c('ctrl','treat'),\n                                                      length.out = length(ids))))\n# Also randomize RUN ORDER so processing position is not confounded with treatment\nunits$run_order \u003C- sample(nrow(units))\n```\n\n## Blocking and Local Control\n\n**Goal:** Remove a known nuisance source from the error term to sharpen the treatment comparison.\n\n**Approach:** Group units into homogeneous blocks (day, litter, chip, donor), randomize treatments within block, and add the block as a term in the model. The paired t-test is the special case of an RCBD with block size 2. Block only on factors with real between-block variation; blocking on a noise factor spends error df for nothing.\n\n```r\nlibrary(designit)                        # constrained assignment; verify API vs installed vignette\nbc \u003C- BatchContainer$new(dimensions = list(block = 3, position = 8))\nbc \u003C- assign_in_order(bc, samples = units)\nbc \u003C- optimize_design(\n  bc,\n  scoring = osat_score_generator(batch_vars = 'block',\n                                 feature_vars = c('treatment')))  # balance treatment across blocks\n```\n\n## Split-Plot and Nested Designs -- the Genomics Trap\n\nA **split-plot** has two experimental-unit sizes and therefore two error strata: a *whole-plot* factor that is hard to randomize finely (incubator temperature, the sequencing run\u002Flane, the 10x chip, the staining batch) and a *sub-plot* factor randomized within each whole plot (the individual sample, the genotype). Analyzing a split-plot as a flat factorial uses the wrong, too-small error term for the whole-plot factor and gives **anti-conservative** tests for exactly the factor that was hardest to replicate. In genomics the lane\u002Frun\u002Fchip is almost always a whole plot; \"batch effects\" are frequently a split-plot structure to be modeled, not a nuisance to scrub.\n\n**Goal:** Match the model's random-effects structure to the design's randomization structure.\n\n**Approach:** Encode each randomization level as a random effect; fixed effects carry the questions. Crossed vs nested structure determines the denominator for each fixed effect; with few EUs use Satterthwaite or Kenward-Roger degrees of freedom (lmerTest \u002F pbkrtest).\n\n```r\nlibrary(lme4); library(lmerTest)\n# Whole plot = run (random); sub-plot factor = condition (fixed); cells nested in sample\nfit \u003C- lmer(expression ~ condition + (1 | run\u002Fsample), data = df)   # run, and sample within run\nanova(fit)                               # Satterthwaite df via lmerTest\n```\n\n## Factorial Designs and Interactions\n\nA factorial design crosses factors so every observation informs every main effect (\"hidden replication\") and, uniquely, estimates **interactions** — the joint action one-factor-at-a-time (OFAT) cannot see. When an interaction is large, main effects are not interpretable alone; reporting a main effect while ignoring a strong interaction is the most common misreading of a 2x2 design. OFAT is less efficient and silently assumes additivity.\n\n## Per-Method Failure Modes\n\n### Pseudoreplication (observational units counted as n)\n- **Trigger:** treating cells\u002Fwells\u002Fsections\u002Ftechnical aliquots as independent replicates.\n- **Mechanism:** units within an EU are correlated; the SE is computed as if they were independent (Hurlbert 1984; Lazic 2018).\n- **Symptom:** implausibly small p-values that fail to replicate; reviewers ask \"what is n?\".\n- **Fix:** aggregate to the EU (pseudobulk) or add the EU as a random effect; the n is the number of EUs.\n\n### Split-plot analyzed as a flat factorial\n- **Trigger:** lane\u002Frun\u002Fincubator factor crossed with a within-run factor, fit with one error term.\n- **Mechanism:** whole-plot factor tested against sub-plot error (too small).\n- **Symptom:** the hard-to-randomize factor looks significant on thin evidence.\n- **Fix:** two-stratum model; whole-plot factor uses whole-plot error (`(1 | run)`).\n\n### Haphazard assignment mistaken for randomization\n- **Trigger:** processing units \"in the order they arrived\".\n- **Mechanism:** order aliases treatment with time\u002Fposition\u002Ftemperature gradients.\n- **Symptom:** apparent treatment effect tracks run order.\n- **Fix:** seeded PRNG assignment; randomize run order too; record the seed.\n\n### Blocking on a noise factor\n- **Trigger:** adding a block term with negligible between-block variance.\n- **Mechanism:** spends error df without removing variance.\n- **Symptom:** power lower than the unblocked design.\n- **Fix:** block only on factors with documented between-block variation.\n\n### Over-\u002Funder-specified random effects\n- **Trigger:** maximal random structure that will not converge, or a structure missing a randomization level.\n- **Mechanism:** maximal protects Type-I but may be singular (Barr 2013); too-lean inflates Type-I (pseudoreplication).\n- **Symptom:** singular-fit warnings, or anti-conservative tests.\n- **Fix:** keep the structure justified by the design; for small EU counts prune by a selection criterion (Matuschek 2017) and report the choice.\n\n## Quantitative Thresholds\n\n| Threshold | Source | Rationale |\n|-----------|--------|-----------|\n| EU = level of independent treatment assignment | Hurlbert 1984; Lazic 2018 | defines the n for inference |\n| Paired design = RCBD with block size 2 | Fisher; standard | pairing is blocking |\n| Latin square needs n² runs for n treatments | standard design theory | controls two nuisances orthogonally |\n| Use Kenward-Roger\u002FSatterthwaite df when EU count is small (roughly \u003C ~10\u002Fgroup) | Kenward & Roger 1997 *Biometrics* 53:983 | naive F df are anti-conservative with few units |\n| Maximal random effects for confirmatory; prune for small samples | Barr 2013; Matuschek 2017 | Type-I protection vs convergence\u002Fpower tradeoff |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Significant result that will not replicate | pseudoreplication (cells as n) | aggregate to EU or add EU random effect |\n| Whole-plot factor over-significant | split-plot analyzed flat | two-stratum mixed model |\n| Treatment effect tracks processing order | no run-order randomization | seeded randomization of run order |\n| Blocked design analyzed without block term | \"design but don't analyze\" | include block in the model; analyze as randomized |\n| Main effect reported despite strong interaction | factorial misread | interpret simple effects within the interaction |\n| Mixed model singular fit | over-specified random effects | prune to the design-justified structure (Matuschek 2017) |\n\n## References\n\n- Hurlbert SH. 1984. Pseudoreplication and the design of ecological field experiments. *Ecol Monogr* 54:187-211.\n- Lazic SE, Clarke-Williams CJ, Munafò MR. 2018. What exactly is 'N' in cell culture and animal experiments? *PLoS Biol* 16:e2005282.\n- Blainey P, Krzywinski M, Altman N. 2014. Points of significance: replication. *Nat Methods* 11:879-880.\n- Krzywinski M, Altman N. 2014. Points of significance: designing comparative experiments. *Nat Methods* 11:597-598.\n- Krzywinski M, Altman N. 2014. Points of significance: analysis of variance and blocking. *Nat Methods* 11:699-700.\n- Morgan KL, Rubin DB. 2012. Rerandomization to improve covariate balance in experiments. *Ann Stat* 40:1263-1282.\n- Pocock SJ, Simon R. 1975. Sequential treatment assignment with balancing for prognostic factors in the controlled clinical trial. *Biometrics* 31:103-115.\n- Barr DJ, Levy R, Scheepers C, Tily HJ. 2013. Random effects structure for confirmatory hypothesis testing: keep it maximal. *J Mem Lang* 68:255-278.\n- Matuschek H, Kliegl R, Vasishth S, Baayen H, Bates D. 2017. Balancing Type I error and power in linear mixed models. *J Mem Lang* 94:305-315.\n- Kenward MG, Roger JH. 1997. Small sample inference for fixed effects from restricted maximum likelihood. *Biometrics* 53:983-997.\n- Auer PL, Doerge RW. 2010. Statistical design and analysis of RNA sequencing data. *Genetics* 185:405-416.\n\n## Related Skills\n\n- batch-design - Assigning samples to sequencing batches\u002Flanes and batch-effect correction\n- sample-size - The experimental unit defines what is replicated and counted\n- power-analysis - Blocking and nesting change the effective error variance\n- multiple-testing - The design fixes what counts as a family of tests\n- single-cell\u002Fpreprocessing - Pseudobulk aggregation to the donor (experimental unit) for scRNA-seq\n- differential-expression\u002Fdeseq2-basics - The DE model that consumes the design's structure\n- clinical-biostatistics\u002Fpower-and-sample-size - Randomization and design in the regulated-trial regime\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","r","2026-09-20","experimental-design\u002Frandomization-blocking\u002FSKILL.md","designit","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fdesign\u002Fbio-experimental-design-randomization-blocking","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-experimental-design-randomization-blocking",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-experimental-design-randomization-blocking",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-experimental-design-randomization-blocking","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fdesign\u002Fbio-experimental-design-randomization-blocking\u002FSKILL.md",true,[50,56],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Frandomization_blocking.R","OTHER","其他",3297,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fdesign\u002Fbio-experimental-design-randomization-blocking\u002Fexamples\u002Frandomization_blocking.R",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"usage-guide.md","REFERENCE","参考文档",3996,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fdesign\u002Fbio-experimental-design-randomization-blocking\u002Fusage-guide.md",[63,71,78,85,92,99],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":70},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":70},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":70},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":70},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":70},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":70},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]