Commit 9b6303c6 authored by Erwan DELAGE's avatar Erwan DELAGE
Browse files

Amelioration de l'affichage des features sur les boxplot d'abondance différentielle

parent 19966210
......@@ -1199,7 +1199,7 @@ if "denoiser" in config["global"]:
directory(getOutput("deseq2/{taxorank}", config["deseq2"]["condition"]))
conda: "conda/deseq2.yml"
shell: """
Rscript scripts/deseq2_microSysMics.R {input[0]} {input[1]} {input[2]} {output} --taxo {input[3]}
Rscript scripts/deseq2_microSysMics.R {input[0]} {input[1]} {input[2]} {output}
"""
......
......@@ -116,7 +116,7 @@ enhanced_volcano_deseq2 <- function(deseq2_res, title="", outfile=""){
}
boxplot_significant_features <- function(feature_id, abundance_table, context_table, context_condition, outfile="") {
boxplot_significant_features <- function(feature_id, abundance_table, context_table, context_condition, taxon, outfile="") {
#' Create boxplot of raw abundance for a givean feature
#'
#' @description Create boxplot of raw abundance for a givean feature
......@@ -136,14 +136,22 @@ boxplot_significant_features <- function(feature_id, abundance_table, context_ta
# Prepare data frame for plotting
df <- merge(feature_abundance, min_context, by="row.names")
colnames(df) <- c("SampleID", "Feature_TSS_abundance", context_condition)
# Format title and subtitle if necessary
if (taxon == "")
{
taxon <- feature_id
feature_id <- strsplit(feature_id,";")[[1]][length(strsplit(feature_id,";")[[1]])]
}
# Create boxplot
p <- ggplot(df, aes_string(x=context_condition, y="Feature_TSS_abundance", fill=context_condition)) +
geom_boxplot(alpha=0.9) + # Create boxplot
scale_fill_brewer(palette="Dark2") + # Set color palette
ggtitle(feature_id) +
labs(title=feature_id, subtitle=taxon) +
theme_ipsum() +
theme(legend.position="none") # No legend
theme(legend.position="none",
plot.subtitle=element_text(size=8)) # No legend
# Plot graph if no outfile specified (testing mode)
if (outfile == "")
......@@ -195,7 +203,7 @@ if (is.null(deseq2_params[["sftype"]])) deseq2_params[["sftype"]] <- "poscounts"
dir.create(arguments[["<outdir>"]], showWarnings = FALSE)
# Load taxo file (if provided)
if ("taxo" %in% names(arguments)){
if (!is.null(arguments["taxo"][[1]])){
taxo <- read.csv(toString(arguments["taxo"]), sep="\t", check.names = FALSE, row.names = 1)
}
......@@ -264,7 +272,7 @@ for(i in 1:(length(category)-1)){
resSig <- resSig[,c(ncol(resSig),1:(ncol(resSig)-1))]
# Add taxo info if provided
if ("taxo" %in% names(arguments)){
if (!is.null(arguments["taxo"][[1]])){
resSig <- merge(as.data.frame(resSig), taxo, by="row.names",all.x=TRUE)
rownames(resSig) <- resSig$Row.names
resSig <- resSig[2:length(resSig)]
......@@ -286,7 +294,15 @@ for(i in 1:(length(category)-1)){
# TSS abundance boxplot for each significant genes
for (feature_id in rownames(resSig)){
boxplot_significant_features(feature_id, tss_abundance, context, deseq2_params[["condition"]], outfile=paste0(outdir,"/",feature_id,".svg"))
# Get taxo info if provided
if (!is.null(arguments["taxo"][[1]])){
taxon <- resSig[feature_id,"Taxon"]
}
else{
taxon <- ""
}
boxplot_significant_features(feature_id, tss_abundance, context, deseq2_params[["condition"]], taxon, outfile=paste0(outdir,"/",feature_id,".svg"))
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment