Hi, I am using limma and EdgR to compare two groups. not sure which test I should use? Which test should be used to compare to variables? when we could use fdr, treat, glmQLFT or any other for unpaired comparison? Please correct me if I am using the wrong coding.
type <-factor(pheno_frame$Name)
design <- model.matrix(~ 0 + type, data=pheno_frame)
# Filtering, normalization, and transformation
keep <- rowSums(cpm(counts)>1.19) >= 8 #filter cpm>1 (50% of the samples)
x <- DGEList(counts = counts)
x <- x[keep, , keep.lib.sizes=FALSE]
dim(x)
cpmCutoff <- round(1e7/mean(colSums(counts)), 2)
grpNum <- 2
x <- x[rowSums(edgeR::cpm(x) > cpmCutoff) >= grpNum, ]
dim(x)
x <- calcNormFactors(x)
range(x$samples$norm.factors)
logcpm <- edgeR::cpm(x, log = TRUE, prior.count = 0.2)
boxplot(logcpm, las = 2)
x <- calcNormFactors(x,method="TMM")
range(x$samples$norm.factors)
logcpm <- edgeR::cpm(x, log = TRUE, prior.count = 0.2)
boxplot(logcpm, las = 2)
# Differential miRNA between Test and Con
contrasts <-makeContrasts(Test_Con=typeTest-typecon,levels=design)
type <- c("Test","con")[as.factor(pheno_frame$Name)]
combo <- interaction(pheno_frame$HTG.EdgeSeq.Run.ID, type)
samp = pheno_frame$HTG.EdgeSeq.Run.ID
design <- model.matrix(~0+type )
pheno_frame$Name <- paste(pheno_frame$Name,sep = "_")
v <- voomWithQualityWeights(counts,plot=TRUE,normalize="none", design=design)
cpm <- 2^(v$E)
fit <- lmFit(v,design)
fit2 <-contrasts.fit(fit,contrasts)
fit2 <- eBayes(fit2)
Results <-topTable(fit2, coef="Test_Con",number=Inf, adjust="fdr",sort.by="P")
par(mfrow=c(1,2))
#v <- voom(d, design, plot=TRUE)
#v
array.weights <- arrayWeights(v, design)
fitw <- lmFit(v, design)#, weights = array.weights)
fit2 <- contrasts.fit(fitw, contrasts)
fit2 <- eBayes(fit2)
vfit <- lmFit(v, design)
vfit <- contrasts.fit(vfit, contrasts)
efit <- eBayes(vfit)
plotSA(fit2, main="Final model: Mean-variance trend")
#summary(decideTests(fit2))
#tfit <- treat(fit2, lfc=1)
#dt <- decideTests(tfit)
#summary(dt)
Results <- topTreat(fit2, coef="Test_Con", n=Inf, adjust="fdr",sort.by="P")