-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limma-Voom differential expression can now fit mixed linear models co…
…ntaining a random effect (e.g. nested design).
- Loading branch information
1 parent
6acb871
commit 3adf0a7
Showing
10 changed files
with
89 additions
and
24 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
pgks <- list("statmod") | ||
for (pkg in pgks) { | ||
tryCatch( | ||
tryCatch( | ||
{install.packages(pkg) | ||
require(pkg)}, | ||
warning = function(e) { | ||
install.packages(pkg, type = "binary")}, | ||
error = function(e) { | ||
install.packages(pkg, type = "binary")}), | ||
error = function(e) {} | ||
) | ||
} | ||
if (("limma" %in% rownames(installed.packages()) == FALSE) || (!require("limma", quietly = TRUE))) { | ||
if (!require("BiocManager", quietly = TRUE)) { | ||
install.packages("BiocManager") | ||
} | ||
BiocManager::install("limma",update=TRUE, ask=FALSE, force=TRUE) | ||
} | ||
|
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
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
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
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
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
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
23 changes: 23 additions & 0 deletions
23
tests/test_files/limma_tests/case3/expected_limma_script_3.R
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require("limma") | ||
|
||
design_matrix <- read.table("tests/test_files/test_design_matrix.csv", header=TRUE, sep= ",") | ||
condition <- factor(design_matrix$condition, levels=c("cond1", "cond2", "cond3")) | ||
replicate <- factor(design_matrix$replicate, levels=c("rep1", "rep2", "rep3")) | ||
|
||
design <- model.matrix(~ condition) | ||
colnames(design)[1] <- "Intercept" | ||
|
||
count_data <- read.table("tests/test_files/big_counted.csv", header=TRUE, sep= ",", row.names = 1) | ||
voom_object <- voom(count_data, design, plot=FALSE, save.plot=TRUE) | ||
|
||
cor <- duplicateCorrelation(voom_object, design, block=replicate) | ||
if (cor$consensus.correlation > 0) { #only include random effect if the correlation is positive | ||
fit <- lmFit(voom_object, design, block=replicate, correlation=cor$consensus.correlation) | ||
}else { fit <- lmFit(voom_object, design)} | ||
|
||
contrast <- makeContrasts("conditioncond2", levels = design) | ||
contrast_fit <- contrasts.fit(fit, contrast) | ||
contrast_bayes <- eBayes(contrast_fit) | ||
res <- topTable(contrast_bayes, n=Inf) | ||
res_ordered <- res[order(res$adj.P.Val),] | ||
write.csv(as.data.frame(res_ordered),file="*PLACEHOLDERPATH*/LimmaVoom_condition_cond2_vs_cond1.csv") |
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