Commit 000aeca3 authored by Celine Noirot's avatar Celine Noirot
Browse files

Debug new parameters and add package svglite

parent 80056632
......@@ -4,7 +4,7 @@
##DATE = "03/2016"
##AUTHORS = "Gaëlle Lefort"
##KEYWORDS = "RNAseq differentially expressed genes"
##DESCRIPTION = "DEG.R imports data, converts them into a DGEList object (edgeR), does tests to find differentially expressed genes and produces diagnostic plots."
##DESCRIPTION = "DEG.R imports data, converts them into a DGEList object (edgeR), does tests to find differentially expressed genes and produces diagnostic plots."
......@@ -30,7 +30,7 @@ for(package in packages){
install.packages(package, repos="http://cran.univ-paris1.fr")
}
do.call('library', list(package))
}
}
#Bioconductor package
......@@ -44,7 +44,7 @@ for(package in bioPackages){
biocLite(package)
}
do.call('library', list(package))
}
}
......@@ -54,40 +54,40 @@ for(package in bioPackages){
###### Parameter initialization when the script is launched from command line
############
option_list = list(
make_option(c("-f", "--file"), type = "character", default = NULL,
make_option(c("-f", "--file"), type = "character", default = NULL,
help = "tabulated raw count matrix with library name as header
(e.g. #gene_id lib1 lib2...)", metavar = "character"),
make_option(c("-n", "--norm"), type = "character", default = NULL,
make_option(c("-n", "--norm"), type = "character", default = NULL,
help = "file with normalized factors with library name
(e.g. sample.name lib.size norm.factors). This file is obtained
with script 'Normalization.R'",
(e.g. sample.name lib.size norm.factors). This file is obtained
with script 'Normalization.R'",
metavar = "character"),
make_option(c("-o", "--out"), type = "character", default = NULL,
help = "folder path where results are stored",
make_option(c("-o", "--out"), type = "character", default = NULL,
help = "folder path where results are stored",
metavar = "character"),
make_option(c("--pool1"), type = "character", default = NULL,
help = "library name in pool 1 separeted by ','",
help = "library name in pool 1 separeted by ','",
metavar = "character"),
make_option(c("--pool2"), type = "character", default = NULL,
help = "library name in pool 2 separeted by ','",
help = "library name in pool 2 separeted by ','",
metavar = "character"),
make_option(c("--filter"), type = "logical", default = TRUE,
help = "if TRUE low expressed genes are removed [default=%default]",
help = "if TRUE low expressed genes are removed [default=%default]",
metavar = "character"),
make_option(c("--alpha"), type = "double", default = 0.05,
help = "significance level of the tests (i.e. acceptable rate of
false-positive in the list of differentially expressed genes)
[default=%default]",
help = "significance level of the tests (i.e. acceptable rate of
false-positive in the list of differentially expressed genes)
[default=%default]",
metavar = "character"),
make_option(c("--correct"), type = "character", default = "BH",
help = "method used to adjust p-values for multiple testing
help = "method used to adjust p-values for multiple testing
('BH', 'BY' or 'fdr') [default=%default]", metavar = "character"),
make_option(c("--MAplots"), type = "logical", default = FALSE,
help = "if TRUE all MA plots are saved [default=%default]",
help = "if TRUE all MA plots are saved [default=%default]",
metavar = "character")
);
);
opt_parser = OptionParser(usage="Imports data, converts them into a DGEList object
opt_parser = OptionParser(usage="Imports data, converts them into a DGEList object
(edgeR), does tests to find differentially
expressed genes and produces diagnostic plots.",
option_list = option_list);
......@@ -99,17 +99,17 @@ opt = parse_args(opt_parser);
##file: tabulated raw count matrix with library name as header
#(e.g. #gene_id lib1 lib2...)
##norm: file with normalized factors with library name
#(e.g. sample.name lib.size norm.factors). This file is obtained with script
#(e.g. sample.name lib.size norm.factors). This file is obtained with script
#'Normalization.R'
##out: folder path where results are stored
##pool1: library name in pool 1 separeted by ', '
##pool2: library name in pool 2 separeted by ', '
##filter: if TRUE low expressed genes are removed
##alpha: significance level of the tests (i.e. acceptable rate of
##alpha: significance level of the tests (i.e. acceptable rate of
#false-positive in the list of differentially expressed genes)
##correct: method used to adjust p-values for multiple testing
##correct: method used to adjust p-values for multiple testing
#('BH', 'BY' or 'fdr')
##MAplots: if TRUE all MA plots are saved
##MAplots: if TRUE all MA plots are saved
##############
#opt=list()
......@@ -126,10 +126,10 @@ opt = parse_args(opt_parser);
#Directory, count table file name or conditions are needed to continue
if (is.null(opt$file) || is.null(opt$norm) || is.null(opt$out) ||
if (is.null(opt$file) || is.null(opt$norm) || is.null(opt$out) ||
is.null(opt$pool1) || is.null(opt$pool2)) {
print_help(opt_parser)
stop("count table file name, output directory or conditions missing.\n",
stop("count table file name, output directory or conditions missing.\n",
call. = FALSE)
}
......@@ -143,11 +143,11 @@ if (!(opt$correct %in% c("BH", "bonferroni"))) {
ifelse(!dir.exists(opt$out), dir.create(opt$out), FALSE)
#Stop the script if files doesn't exist
if (!file.exists(normalizePath(opt$file)) |
!file.exists(normalizePath(file.path(opt$norm),
if (!file.exists(normalizePath(opt$file)) |
!file.exists(normalizePath(file.path(opt$norm),
mustWork = FALSE))) {
print_help(opt_parser)
stop("count table file or file with normalization factor doesn't exist.\n",
stop("count table file or file with normalization factor doesn't exist.\n",
call. = FALSE)
}
......@@ -157,10 +157,10 @@ if (!file.exists(normalizePath(opt$file)) |
### ---------------------Input data and preprocessing
#####################################################
#Raw and normalized count
PC_before <- read.table(normalizePath(opt$file), header = TRUE,
PC_before <- read.table(normalizePath(opt$file), header = TRUE,
row.names = 1, comment.char="")
norm_fact <- read.table(normalizePath(file.path(opt$norm),
norm_fact <- read.table(normalizePath(file.path(opt$norm),
mustWork = FALSE), header = TRUE)
#Conditions
......@@ -177,13 +177,13 @@ if (nrow(pool1) < 1 || nrow(pool2) < 1) {
sample_info <- rbind(pool1, pool2)
PC_before <- PC_before[, colnames(PC_before) %in% as.character(sample_info$lib_name)]
PC_before <- PC_before[, match(colnames(PC_before), sample_info$lib_name)]
norm_fact <- norm_fact[as.character(norm_fact$sample.name) %in%
norm_fact <- norm_fact[as.character(norm_fact$sample.name) %in%
as.character(sample_info$lib_name), ]
#DGEList object
dge_before <- DGEList(PC_before, remove.zeros = TRUE,
dge_before <- DGEList(PC_before, remove.zeros = TRUE,
group = sample_info$conditions)
dge_after <- DGEList(PC_before, remove.zeros = TRUE,
dge_after <- DGEList(PC_before, remove.zeros = TRUE,
group = sample_info$conditions,
norm.factors = norm_fact$norm.factors)
......@@ -202,27 +202,27 @@ pdf(file.path(opt$out, "de_images.pdf"), title = "Plots from differential analys
PC_before_log_long <- melt(PC_before_log)
colnames(PC_before_log_long) <- c("name", "lib", "log2CPM")
PC_before_log_long <- merge(PC_before_log_long, sample_info, by.x = "lib",
PC_before_log_long <- merge(PC_before_log_long, sample_info, by.x = "lib",
by.y = "lib_name")
PC_after_log_long <- melt(PC_after_log)
colnames(PC_after_log_long) <- c("name", "lib", "log2CPM")
PC_after_log_long <- merge(PC_after_log_long, sample_info, by.x = "lib",
PC_after_log_long <- merge(PC_after_log_long, sample_info, by.x = "lib",
by.y = "lib_name")
#### boxplot
PC_boxplot <- function(dat, tit, filename) {
p <- ggplot(dat, aes(x=lib, y=log2CPM)) +
geom_boxplot(aes(fill = factor(conditions))) + theme_bw() + xlab(label = "") +
p <- ggplot(dat, aes(x=lib, y=log2CPM)) +
geom_boxplot(aes(fill = factor(conditions))) + theme_bw() + xlab(label = "") +
ylab(label = expression(log[2]*"(counts + 1)")) + ggtitle(tit) +
scale_fill_manual(name = "Conditions", values = c("steelblue3", "springgreen3"))
print(p)
}
PC_boxplot(PC_before_log_long, "Boxplot on raw pseudo-counts",
PC_boxplot(PC_before_log_long, "Boxplot on raw pseudo-counts",
"rawcount_boxplot.png")
PC_boxplot(PC_after_log_long, "Boxplot on pseudo-counts after normalization",
PC_boxplot(PC_after_log_long, "Boxplot on pseudo-counts after normalization",
"normcount_boxplot.png")
......@@ -233,22 +233,22 @@ if (nrow(pool1) > 1 && nrow(pool2) > 1) {
mds <- data.frame(plotMDS(dat)$cmdscale.out)
dev.off()
mds$lib.name <- rownames(mds)
p <- ggplot(mds, aes(x = X1, y = X2, label = lib.name,
color = as.factor(sample_info$conditions))) +
geom_point(size=4) + geom_text(hjust=0.5, vjust=-0.5) + theme_bw() +
xlab(label = "Dimension 1") + ylab(label = "Dimension 2") +
ggtitle(tit) + scale_color_manual(name = "Conditions",
p <- ggplot(mds, aes(x = X1, y = X2, label = lib.name,
color = as.factor(sample_info$conditions))) +
geom_point(size=4) + geom_text(hjust=0.5, vjust=-0.5) + theme_bw() +
xlab(label = "Dimension 1") + ylab(label = "Dimension 2") +
ggtitle(tit) + scale_color_manual(name = "Conditions",
values = c("steelblue3", "springgreen3"))
print(p)
write.table(mds, file = normalizePath(file.path(opt$out,
paste0(filename,".csv")),
mustWork = FALSE), sep = "\t",
write.table(mds, file = normalizePath(file.path(opt$out,
paste0(filename,".csv")),
mustWork = FALSE), sep = "\t",
row.names = TRUE, quote = FALSE)
}
PC_MDS(PC_before_log, "PCA plot on raw pseudo-counts", "rawcount_MDS")
PC_MDS(PC_after_log, "PCA plot on pseudo-counts after normalization",
PC_MDS(PC_after_log, "PCA plot on pseudo-counts after normalization",
"normcount_MDS")
}
......@@ -256,33 +256,33 @@ if (nrow(pool1) > 1 && nrow(pool2) > 1) {
#### density
PC_density <- function(dat, tit, filename) {
p <- ggplot(dat, aes(x=log2CPM, group = lib)) +
geom_density(aes(colour = factor(conditions))) +
theme_bw() + xlab(label = expression(log[2]*"(counts + 1)")) +
ylab(label = "Density") + ggtitle(tit) +
guides(color=guide_legend(title="Conditions")) +
scale_color_manual(name = "Conditions",
p <- ggplot(dat, aes(x=log2CPM, group = lib)) +
geom_density(aes(colour = factor(conditions))) +
theme_bw() + xlab(label = expression(log[2]*"(counts + 1)")) +
ylab(label = "Density") + ggtitle(tit) +
guides(color=guide_legend(title="Conditions")) +
scale_color_manual(name = "Conditions",
values = c("steelblue3", "springgreen3"))
print(p)
}
PC_density(PC_before_log_long, "Density plot on raw pseudo-counts",
PC_density(PC_before_log_long, "Density plot on raw pseudo-counts",
"rawcount_density.png")
PC_density(PC_after_log_long, "Density plot on pseudo-counts after normalization",
PC_density(PC_after_log_long, "Density plot on pseudo-counts after normalization",
"normcount_density.png")
#save data used for boxplots and density plots
#Raw counts
write.table(PC_before_log_long, file = normalizePath(file.path(opt$out,
"raw_boxplot_density.csv"),
mustWork = FALSE), sep = "\t",
write.table(PC_before_log_long, file = normalizePath(file.path(opt$out,
"raw_boxplot_density.csv"),
mustWork = FALSE), sep = "\t",
row.names = TRUE, quote = FALSE)
#Normalized counts
write.table(PC_after_log_long, file = normalizePath(file.path(opt$out,
paste0("norm_boxplot_density.csv")),
mustWork = FALSE), sep = "\t",
write.table(PC_after_log_long, file = normalizePath(file.path(opt$out,
paste0("norm_boxplot_density.csv")),
mustWork = FALSE), sep = "\t",
row.names = TRUE, quote = FALSE)
......@@ -290,104 +290,104 @@ write.table(PC_after_log_long, file = normalizePath(file.path(opt$out,
MAplot_name <- character()
pos <- 1
if (opt$MAplots && nrow(pool1) > 1 && nrow(pool2) > 1) {
ifelse(!dir.exists(file.path(opt$out, "MAplots")),
ifelse(!dir.exists(file.path(opt$out, "MAplots")),
dir.create(file.path(opt$out, "MAplots")), FALSE)
PC_MAplot <- function(lib1, lib2, tit, filename) {
avalues <- (lib1 + lib2)/2
mvalues <- (lib1 - lib2)
MA <- data.frame(avalues = avalues, mvalues = mvalues)
p <- ggplot(MA, aes(x=avalues, y=mvalues)) +
geom_point(size=1) + theme_bw() + ggtitle(tit) + xlab("A") + ylab("M") +
geom_hline(yintercept = 0, col = "red") +
geom_point(size=1) + theme_bw() + ggtitle(tit) + xlab("A") + ylab("M") +
geom_hline(yintercept = 0, col = "red") +
theme(text = element_text(size=5))
#print(p)
return(list(avalues,mvalues,p))
}
a_before <- data.frame(name=rownames(PC_before_log))
m_before <- data.frame(name=rownames(PC_before_log))
a_after <- data.frame(name=rownames(PC_after_log))
m_after <- data.frame(name=rownames(PC_after_log))
for(cond in unique(sample_info$conditions)) {
I <- sum(sample_info$conditions == cond)-1
J <- sum(sample_info$conditions == cond)
grid.newpage()
# Create layout : nrow = 2, ncol = 2
pushViewport(viewport(layout = grid.layout(I, I*2)))
pos_graph <- 1
for(i in 1:I) {
pos_graph <- i*2 - 1
for(j in (i+1):J) {
col_name <- paste0("cond",cond, "_",
sample_info$lib_name[sample_info$conditions == cond][i],
"vs",
col_name <- paste0("cond",cond, "_",
sample_info$lib_name[sample_info$conditions == cond][i],
"vs",
sample_info$lib_name[sample_info$conditions == cond][j])
bef <- PC_MAplot(PC_before_log[, sample_info$conditions == cond][, i],
PC_before_log[, sample_info$conditions == cond][, j],
paste0("MA plot on raw pseudo-counts: \n",
bef <- PC_MAplot(PC_before_log[, sample_info$conditions == cond][, i],
PC_before_log[, sample_info$conditions == cond][, j],
paste0("MA plot on raw pseudo-counts: \n",
sample_info$lib_name[sample_info$conditions == cond][i],
" vs. ",
" vs. ",
sample_info$lib_name[sample_info$conditions == cond][j]),
paste0("raw_MAplot_", cond, "_", i, "vs", j, ".png"))
MAplot_name[pos] <- paste0("raw_MAplot_", cond, "_", i, "vs", j, ".png")
pos <- pos + 1
a_before <- cbind(a_before, bef[[1]])
m_before <- cbind(m_before, bef[[2]])
colnames(a_before)[ncol(a_before)] <- col_name
colnames(m_before)[ncol(m_before)] <- col_name
print(bef[[3]], vp=viewport(layout.pos.row = i, layout.pos.col = pos_graph))
aft <- PC_MAplot(PC_after_log[, sample_info$conditions == cond][, i],
PC_after_log[, sample_info$conditions == cond][, j],
paste0("MA plot on normalized pseudo-counts: \n",
aft <- PC_MAplot(PC_after_log[, sample_info$conditions == cond][, i],
PC_after_log[, sample_info$conditions == cond][, j],
paste0("MA plot on normalized pseudo-counts: \n",
sample_info$lib_name[sample_info$conditions == cond][i],
" vs. ",
" vs. ",
sample_info$lib_name[sample_info$conditions == cond][j]),
paste0("norm_MAplot_", cond, "_", i, "vs", j, ".png"))
MAplot_name[pos] <- paste0("norm_MAplot_", cond, "_", i, "vs", j, ".png")
pos <- pos + 1
a_after <- cbind(a_after, plot_name=aft[[1]])
m_after <- cbind(m_after, plot_name=aft[[2]])
colnames(a_after)[ncol(a_after)] <- col_name
colnames(m_after)[ncol(m_after)] <- col_name
print(aft[[3]], vp=viewport(layout.pos.row = i, layout.pos.col = pos_graph+1))
pos_graph <- pos_graph + 2
}
}
}
write.table(a_before, file = normalizePath(file.path(opt$out, "MAplots",
paste0("raw_MAplot_a.csv")),
mustWork = FALSE), sep = "\t",
paste0("raw_MAplot_a.csv")),
mustWork = FALSE), sep = "\t",
row.names = FALSE, quote = FALSE)
write.table(m_before, file = normalizePath(file.path(opt$out, "MAplots",
paste0("raw_MAplot_m.csv")),
mustWork = FALSE), sep = "\t",
paste0("raw_MAplot_m.csv")),
mustWork = FALSE), sep = "\t",
row.names = FALSE, quote = FALSE)
write.table(a_after, file = normalizePath(file.path(opt$out, "MAplots",
paste0("norm_MAplot_a.csv")),
mustWork = FALSE), sep = "\t",
paste0("norm_MAplot_a.csv")),
mustWork = FALSE), sep = "\t",
row.names = FALSE, quote = FALSE)
write.table(a_after, file = normalizePath(file.path(opt$out, "MAplots",
paste0("norm_MAplot_m.csv")),
mustWork = FALSE), sep = "\t",
paste0("norm_MAplot_m.csv")),
mustWork = FALSE), sep = "\t",
row.names = FALSE, quote = FALSE)
}
......@@ -401,36 +401,36 @@ if (nrow(pool1) > 1 && nrow(pool2) > 1) { # at least TWO replicats by conditions
#Estimate dispersion
dge_after <- estimateCommonDisp(dge_after)
dge_after <- estimateTagwiseDisp(dge_after)
#Independant filtering
dge_after_filt <- dge_after
if (opt$filter && nrow(pool1) > 1 && nrow(pool2) > 1) {
dge_after_filt <- HTSFilter(dge_after, plot = FALSE)$filteredData
}
### ---------------------Test with edgeR
dge_after_res_nofilter <- exactTest(dge_after)
res_nofilter <- topTags(dge_after_res_nofilter,
res_nofilter <- topTags(dge_after_res_nofilter,
n = nrow(dge_after_res_nofilter$table))$table
dge_after_res <- exactTest(dge_after_filt)
res <- topTags(dge_after_res, n = nrow(dge_after_res$table),
res <- topTags(dge_after_res, n = nrow(dge_after_res$table),
adjust.method = opt$correct, sort.by = "none")$table
colnames(res)[4] <- "FDR"
} else { # Less than two replicats for one or two conditions
### ---------------------Fisher exact test
PC_after <- cpm(dge_after)
fisher <- function(gene, dat) {
dat<-t(rowsum(t(dat), group = as.factor(dge_after$samples$group)))
t <- rbind(dat[gene, ], colSums(dat[-gene, ]))
t <- rbind(dat[gene, ], colSums(dat[-gene, ]))
return(fisher.test(t)$p.value)
}
pval_nofilter <- apply(data.frame(1:nrow(PC_after)), 1, fisher, PC_after)
padj_nofilter <- p.adjust(pval_nofilter)
#LFC
if (sum(dge_after$samples$group == 1) > 1){
LFC1 <- log2(rowMeans(PC_after[,dge_after$samples$group == 1]) + 0.125)
......@@ -442,13 +442,13 @@ if (nrow(pool1) > 1 && nrow(pool2) > 1) { # at least TWO replicats by conditions
} else {
LFC2 <- log2(PC_after[,dge_after$samples$group == 2] + 0.125)
}
res_nofilter <- data.frame(logFC = LFC2 - LFC1,
logCPM = aveLogCPM(dge_after), PValue = pval_nofilter,
res_nofilter <- data.frame(logFC = LFC2 - LFC1,
logCPM = aveLogCPM(dge_after), PValue = pval_nofilter,
FDR = padj_nofilter)
rownames(res_nofilter) <- rownames(PC_after)
res <- res_nofilter
}
......@@ -468,9 +468,9 @@ diff$overExpr <- ifelse(diff$logFC > 0, "pool1", "pool2")
diff <- diff[order(diff$padj), ]
# save .csv
write.table(cbind("#name" = rownames(diff), diff),
file = normalizePath(file.path(opt$out, "resDEG.csv"),
mustWork = FALSE), sep = "\t",
write.table(cbind("#name" = rownames(diff), diff),
file = normalizePath(file.path(opt$out, "resDEG.csv"),
mustWork = FALSE), sep = "\t",
row.names = FALSE, quote = FALSE)
# save .json
......@@ -496,19 +496,19 @@ if (opt$filter && nrow(pool1) > 1 && nrow(pool2) > 1){
nbfilt <- -1
}
stat <- list("test" = test,
"overexp_both_pools" = nbtot,
stat <- list("test" = test,
"overexp_both_pools" = nbtot,
"over_expressed_pool1 " = nb1,
"over_expressed_pool2 " = nb2,
"no_count" = nbcount0,
"filtered" = nbfilt)
write(gsub(" ", "", toJSON(list(stat=stat, top20=top20), collapse = "")),
file = normalizePath(file.path(opt$out, "results.json"),
write(gsub(" ", "", toJSON(list(stat=stat, top20=top20), collapse = "")),
file = normalizePath(file.path(opt$out, "results.json"),
mustWork = FALSE))
write.table(t(as.data.frame(stat)),
file = normalizePath(file.path(opt$out, "statistics.txt"),
write.table(t(as.data.frame(stat)),
file = normalizePath(file.path(opt$out, "statistics.txt"),
mustWork = FALSE), quote = FALSE, col.names = FALSE)
####################################
......@@ -516,32 +516,32 @@ write.table(t(as.data.frame(stat)),
####################################
#### histogram
h1 <- ggplot(data=res_nofilter, aes(PValue)) + geom_histogram() +
theme_bw() + xlab(label = "p-value") +
h1 <- ggplot(data=res_nofilter, aes(PValue)) + geom_histogram() +
theme_bw() + xlab(label = "p-value") +
ylab(label = "Count") + ggtitle("Histogram on raw p-value without filter")
h2 <- ggplot(data=res_nofilter, aes(FDR)) + geom_histogram() +
theme_bw() + xlab(label = "p-value") +
h2 <- ggplot(data=res_nofilter, aes(FDR)) + geom_histogram() +
theme_bw() + xlab(label = "p-value") +
ylab(label = "Count") + ggtitle("Histogram on adjust p-value without filter")
write.table(cbind(Pvalue = res_nofilter$PValue, adjPvalue = res_nofilter$FDR),
file = normalizePath(file.path(opt$out, "histogram_nofilter.csv"),
mustWork = FALSE), sep = "\t",
write.table(cbind(Pvalue = res_nofilter$PValue, adjPvalue = res_nofilter$FDR),
file = normalizePath(file.path(opt$out, "histogram_nofilter.csv"),
mustWork = FALSE), sep = "\t",
row.names = FALSE, quote = FALSE)
if (opt$filter) {
h3 <- ggplot(data=res, aes(FDR)) + geom_histogram() +
theme_bw() + xlab(label = "p-value") +
h3 <- ggplot(data=res, aes(FDR)) + geom_histogram() +
theme_bw() + xlab(label = "p-value") +
ylab(label = "Count") + ggtitle("Histogram on adjust p-value with filter")
write.table(cbind(adjPvalue = res$FDR),
file = normalizePath(file.path(opt$out, "histogram_filter.csv"),
mustWork = FALSE), sep = "\t",
write.table(cbind(adjPvalue = res$FDR),
file = normalizePath(file.path(opt$out, "histogram_filter.csv"),
mustWork = FALSE), sep = "\t",
row.names = FALSE, quote = FALSE)
grid.arrange(h1, h2, h3, ncol=3)
} else {
grid.arrange(h1, h2, ncol=2)
}
......@@ -553,27 +553,27 @@ res$DEG <- ifelse(res$FDR < opt$alpha, "Yes", "No")
if (nrow(pool1) > 1 | nrow(pool2) > 1) {
p <- ggplot(res, aes(x=logCPM, y=logFC, group=DEG)) +
geom_point(aes(color=as.factor(DEG)), size=3)+
theme_bw() + scale_color_manual(values=c('#000000','#CC0000')) +
guides(color=guide_legend(title="DEG ?")) +
theme_bw() + scale_color_manual(values=c('#000000','#CC0000')) +
guides(color=guide_legend(title="DEG ?")) +
ggtitle("MA plot on normalized pseudo-counts")
print(p)
write.table(cbind(A = res$logCPM, M = res$logFC, DEG = res$DEG),
file = normalizePath(file.path(opt$out, "DE_MAplot.csv"),
mustWork = FALSE), sep = "\t",
write.table(cbind(A = res$logCPM, M = res$logFC, DEG = res$DEG),
file = normalizePath(file.path(opt$out, "DE_MAplot.csv"),
mustWork = FALSE), sep = "\t",
row.names = FALSE, quote = FALSE)
} else {