Entering edit mode
wang peter
★
2.0k
@wang-peter-4647
Last seen 10.2 years ago
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','t0
h','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','t18
h','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