[BioC] how to make makeContrast in edgeR?

KJ Lim jinkeanlim at gmail.com
Mon Aug 27 08:47:29 CEST 2012


Dear Gao Shan,

Kindly please spare time to read through the Chapter 3 from beginning
till the end in the latest edgeR User's guide. The guides in that
Chapter are useful to your analysis.

  > design = model.matrix(~fac)

This design matrix will include an intercept column in your design
matrix. If you would like to utilize the makeContrasts function for
glmLRT analysis and to avoid confusion,  you could modify your design
matrix:

  > design = model.matrix(~0+fac)

 The contrast vector could be contracted:

  > t0_c0 = makeContrasts(t0h-c0h,levels=design) ## assuming label of
design matrix column is right
  > lrt.dge <- glmLRT(dge, glmfit.dge, contrast = t0_c0)

There is a poster worth for a read either:
https://www.stat.math.ethz.ch/pipermail/bioconductor/2012-May/045700.html

Best regards,
KJ Lim



On 26 August 2012 22:53, wang peter <wng.peter at gmail.com> wrote:
>
> thank you lim,
> i read the manual and write such coding
> but meet an error
>
> > d <- DGEList(counts = d, lib.size = lib_size)
> > #normalization
> > dge <- calcNormFactors(d)
> > rm(d)
> >
> > fac=factor(c('c0h','c0h','c0h','c24h','c24h','c24h','t0h','t0h','t0h','t6h','t6h','t6h','t6h','t12h','t12h','t12h','t12h','t18h','t18h','t18h','t18h',
> +              't24h','t24h','t24h','t36h','t36h','t36h','t48h','t48h','t48h','c6h','c12h','c18h','c36h','c48h'))
> > design = model.matrix(~fac)
> > colnames(design) <- levels(fac)
> > dge <- estimateGLMCommonDisp(dge, design)#
> > dge <- estimateGLMTagwiseDisp(dge, design)
> > glmfit.dge <- glmFit(dge, design, dispersion=dge$tagwise.dispersion)#
> > t0_c0 = makeContrasts("t0h-c0h",levels=design)
> > lrt.dge <- glmLRT(dge, glmfit.dge, contrast = t0_c0)
> > result <- topTags(lrt.dge, n=dim(dge)[1], adjust.method="BH", sort.by="p.value")
>
> Error in abs(object$table$logFC) :
>   Non-numeric argument to mathematical function
>
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936
> [2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936
> [3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
> [4] LC_NUMERIC=C
> [5] LC_TIME=Chinese (Simplified)_People's Republic of China.936
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] edgeR_2.6.10 limma_3.12.1



More information about the Bioconductor mailing list