Skip to content

Instantly share code, notes, and snippets.

@mikelove
Created September 24, 2025 18:45
Show Gist options
  • Select an option

  • Save mikelove/8c731198e44b18c05636bc783a83900a to your computer and use it in GitHub Desktop.

Select an option

Save mikelove/8c731198e44b18c05636bc783a83900a to your computer and use it in GitHub Desktop.
DESeq2 on second set of rows using fixed priors
library(DESeq2)
dds <- makeExampleDESeqDataSet()
dds_leaf <- dds[1:500,]
dds_inner <- dds[501:1000,]
dds_leaf <- DESeq(dds_leaf)
res_leaf <- lfcShrink(dds_leaf, coef="condition_B_vs_A", type="apeglm")
# this runs DESeq2 on inner nodes but using priors from leaves
sizeFactors(dds_inner) <- sizeFactors(dds_leaf)
dds_inner <- estimateDispersionsGeneEst(dds_inner)
dispersionFunction(dds_inner) <- dispersionFunction(dds_leaf) # skipping prior estimation
dds_inner <- estimateDispersionsMAP(dds_inner)
dds_inner <- nbinomWaldTest(dds_inner)
# this runs lfcShrink on inner nodes but using priors from leaves
pc <- attr(res_leaf, "priorInfo")$prior.control
res_inner <- lfcShrink(dds_inner, coef="condition_B_vs_A",
type="apeglm", apeAdapt=FALSE, prior.control=pc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment