Dear all,
Here is the code I am using to calculate PValue which gives significant PValue for the identical counts between treatment and control. My dataframe is called "df", and my PValue list is called "top".
Please let me know if there is anything wrong in a code or reason for getting incorrect significant PValue. Thanks!
# Load library
library(edgeR)
library(RUVSeq)
library(reshape2)
library(DESeq2)
library(dplyr)
library(ggplot2)
library(pheatmap)
control_1 <- c(rep(10, 50), 1000, 2000, 3000, 4000, 5000)
control_2 <- c(rep(10, 50), 1000, 2000, 3000, 4000, 5000)
patient_1 <- c(rep(20, 20),rep(10,10), rep(0,20), 1000, 2000, 3000, 4000, 5000)
patient_2 <- c(rep(20, 20),rep(10,10), rep(0,20), 1000, 2000, 3000, 4000, 5000)
df <- data.frame(Ctl=control_1,
Ctl=control_2,
Trt=patient_1,
Trt=patient_2)
# Store data
x <- as.factor(rep(c("Ctl", "Trt"), each=2))
set <- newSeqExpressionSet(as.matrix(df), phenoData = data.frame(x, row.names =colnames(df)))
## Upper-quartile normalization
set <- betweenLaneNormalization(set, which="upper")
## PValue Calculation using DGEList
design <- model.matrix(~x, data=pData(set))
y <- DGEList(counts=counts(set), group=x)
y <- calcNormFactors(y, method = "upperquartile")
y <- estimateGLMCommonDisp(y, design)
y <- estimateGLMTagwiseDisp(y, design)
fit <- glmFit(y, design)
lrt <- glmLRT(fit, contrast=c(1,-1))
top <- topTags(lrt, n=nrow(set))$table