Created
April 29, 2015 16:02
-
-
Save nachocab/4931cc20084472941e85 to your computer and use it in GitHub Desktop.
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
targets <- read.table("targets.txt", header = TRUE) | |
counts <- read.delim("counts.txt", row.names = "gene_id") | |
counts <- counts[, targets$sample_name] # important, the ordering of the columns in the counts file must match the sample_name in the targets file | |
group <- factor(targets$virus_dpi, levels = unique(targets$virus_dpi)) | |
library(edgeR) | |
y <- DGEList(counts = counts, group = group) | |
y <- calcNormFactors(y) | |
design <- model.matrix( ~ 0 + group, data = y$samples) | |
colnames(design) <- levels(group) | |
y <- estimateGLMCommonDisp(y, design) | |
y <- estimateGLMTrendedDisp(y, design) | |
y <- estimateGLMTagwiseDisp(y, design) | |
fit <- glmFit(y, design) | |
contrasts <- makeContrasts( | |
lassa_d3 = (lassa_3 - lassa_0), | |
marburg_d3 = (marburg_3 - marburg_0), | |
ebola_k_d4 = (ebola_k_4 - ebola_k_0), | |
common_early = (marburg_3 + lassa_3 + ebola_k_4)/3 - (marburg_0 + lassa_0 + ebola_k_0)/3, | |
# you can add more contrasts here | |
levels = design) | |
contrast_name <- "lassa_d3" # or "ebola_k_d4", etc. | |
lrt <- glmLRT(fit, contrast = contrasts[,contrast_name]) | |
topTags(lrt) | |
# I recommend you add a gene_name column to lrt$table so you don't have to work with gene ids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment