Created
March 19, 2020 14:12
-
-
Save yuifu/ad58bf1638450098979bf3d2210636a0 to your computer and use it in GitHub Desktop.
EdgeR, strange case (too many DEGs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############### | |
# mat_count: 60668 x 28 matrix, gene expression levels | |
# mat_count_rmlow: 18186 x 28 matrix | |
# group: A vector of factor: factor(rep(1:7, each=4)) | |
############### | |
### Remove low-count genes and round count | |
is_lowgenes = rowMeans(mat_count) < 5 | |
mat_count_rmlow <- mat_count[!is_lowgenes,] | |
dim(mat_count_rmlow) | |
x <- mat_count_rmlow | |
x <- round(x) | |
### Run EdgeR | |
y <- DGEList(counts=x, group=group) | |
y <- calcNormFactors(y) | |
design <- model.matrix(~0+group) | |
y <- estimateDisp(y, design) # To estimate common dispersion and tagwise dispersions in one run (recommended) | |
fit <- glmQLFit(y, design) | |
################### | |
list_deg_comb <- list() | |
# 1: 1-3 vs. 4-5 | |
vec = numeric(length(levels(group))) | |
vec[1:3] = 1 | |
vec[4:5] = -1 | |
res_comb1 <- glmQLFTest(fit, contrast = vec) | |
list_deg_comb[["1-3vs4-5"]] <- res_comb1 | |
> nrow(topTags(list_deg_comb[["1-3vs4-5"]], n = Inf, p.value = 0.01)) | |
[1] 18181 | |
> nrow(topTags(list_deg_comb[["1-3vs4-5"]], n = Inf, p.value = 0.0001)) | |
[1] 18181 | |
> nrow(topTags(list_deg_comb[["1-3vs4-5"]], n = Inf, p.value = 0.000000001)) | |
[1] 18180 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment