Class PairedDesignFitTest

java.lang.Object
ubic.gemma.core.util.math.linearmodels.PairedDesignFitTest

public class PairedDesignFitTest extends Object
Paired design: a subject factor as a fixed block, treatment effect adjusted for it.

The R reference fits live in data/stat-tests/paired-golden-gen.R (run with Rscript; limma lmFit + eBayes on model.matrix(~ subject + treatment)), and the fixture data are paired-test-data.txt with paired-design.txt. The fixture is 100 probes over 12 samples (6 subjects, ctrl/treat per subject), with per-probe subject shifts and a treatment effect on the last 40 probes.

Gemma must reproduce the R treatment coefficient, its unscaled standard error, the moderated t and p, and sigma for every probe asserted below. The subject columns are exactly the nuisance term limma adjusts for: if this test passes with them in the design, a paired analysis in the analyzer differs from an unpaired one only by which factors get reported.

  • Constructor Details

    • PairedDesignFitTest

      public PairedDesignFitTest()
  • Method Details

    • treatmentCoefficientMatchesLimmaForAFlatProbe

      @Test public void treatmentCoefficientMatchesLimmaForAFlatProbe() throws Exception
      probe_0: treatment coefficient -0.178524952015744 (unmoderated; the t/p below are the eBayes-moderated ones, which is what Gemma reports by default). Contrast maps are keyed by coefficient name, which the design matrix builds as factorName + level ("treatment" + "treat" -> "treatmenttreat").
      Throws:
      Exception
    • moderatedTreatmentStatisticsMatchLimmaForADeProbe

      @Test public void moderatedTreatmentStatisticsMatchLimmaForADeProbe() throws Exception
      The eBayes-moderated treatment t and p on a DE probe (true effect 1.2): R gives t = 5.4699580709098, p = 7.1248077534004e-08 for probe_98. With a subject factor in the design the residual dof is 5 (12 samples - 7 coefficients) -- an unpaired fit would have had 10 and given a different answer.
      Throws:
      Exception
    • residualDofAccountsForTheSubjectColumns

      @Test public void residualDofAccountsForTheSubjectColumns() throws Exception
      Residual dof: 12 samples, 7 estimated coefficients (intercept, 5 subject, 1 treatment), so 5 -- and sigma matches the R fit through that dof (R sigma for probe_0 = 0.445584101416172).
      Throws:
      Exception
    • unpairedFitOfTheSameDataGivesADifferentTreatmentT

      @Test public void unpairedFitOfTheSameDataGivesADifferentTreatmentT() throws Exception
      The pairing actually changes the answer: fitting the same data WITHOUT the subject factor must give a different treatment t for the DE probe. This is what distinguishes a paired from an unpaired analysis and it is the regression guard against a refactor that silently drops the block.
      Throws:
      Exception