[BioC] what difference to use edgeR in two different mode?

wang peter wng.peter at gmail.com
Wed Sep 12 22:21:45 CEST 2012


dear ALL:

i have 35 samples to find DE genes between "c0h" vs t0h", i can use
such coding to reach the same
aim, what is the difference? which one is  better?

raw.data <- read.table("expression-table.txt",row.names=1)#第1列是基因长度,后面几列都是基因表达值
lib_size <- read.table("lib_size.txt");
lib_size <- unlist(lib_size) #把数据框类型转换为向量
d <- raw.data[, 2:dim(raw.data)[2]]#第1列是长度不要,只保留样本的基因表达值
length<-raw.data[, 1]

method 1:
group =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'))
d <- DGEList(counts = d, lib.size = lib_size, group = group)
d <- calcNormFactors(d)

#To estimate common dispersion:
d <- estimateCommonDisp(d)
#To estimate tagwise dispersions:
d <- estimateTagwiseDisp(d)

et <- exactTest(d, pair=c("c0h","t0h"), dispersion="tagwise")
sig1<-summary(de <- decideTestsDGE(et, p=0.05, adjust="BH"))
sig1<-as.vector(sig1)
result <- topTags(et, n=dim(d)[1], adjust.method="BH", sort.by="p.value")
write.table(result,file = "t0h_c0h",sep = "\t")

method 2:
#生成DGEList对象
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")
write.table(result,file = "t0_c0",sep = "\t")

-- 
shan gao
Room 231(Dr.Fei lab)
Boyce Thompson Institute
Cornell University
Tower Road, Ithaca, NY 14853-1801
Office phone: 1-607-254-1267(day)
Official email:sg839 at cornell.edu
Facebook:http://www.facebook.com/profile.php?id=100001986532253



More information about the Bioconductor mailing list