Commit 54681b0b authored by Erwan DELAGE's avatar Erwan DELAGE
Browse files

Correct bug in ASV ID order, cosmetic changes

parent d29cc4ca
......@@ -310,7 +310,6 @@ plot_deseq2 <- function(deseq2_res, tss_abundance, context, context_condition,
# Format data frame
deseq2_res <- deseq2_res %>%
arrange(log2FoldChange) %>% # Sort rows according to log fold change
mutate(id=as_factor(rownames(deseq2_res))) %>% # Add an "id" column from rownames, with factors
mutate(pvalPlot=-log10(padj)) %>% # Transform adjusted p-value to reflect it as the node size
mutate(posLabel = case_when(
log2FoldChange < 0 ~ -0.2,
......@@ -319,6 +318,7 @@ plot_deseq2 <- function(deseq2_res, tss_abundance, context, context_condition,
# If info is available at the genus or specie level, we add it on the plot
deseq2_res <- deseq2_res %>%
mutate(id=as_factor(rownames(deseq2_res))) %>% # Add an "id" column from rownames, with factors
mutate(lastTaxo = getLastTaxo(deseq2_res)) # Get last taxonomic assignation
# Fold change plot
......@@ -328,8 +328,11 @@ plot_deseq2 <- function(deseq2_res, tss_abundance, context, context_condition,
geom_vline(xintercept=0, linetype="dotted", size=0.5) + # Add vertical bar at null fold change
scale_y_discrete(position = "right") + # Put features labels on the right side of the plot
geom_text(aes(label=lastTaxo),hjust=deseq2_res$posLabel, vjust=0.3, size=4) +
theme_light() +
theme(
legend.position = c(.15, .75) # Set legend to the uper left part of the figure
legend.position = c(.15, .75), # Set legend to the uper left part of the figure
axis.title.y=element_blank(),
text = element_text(size=13)
) +
labs(size="-log10 padj", y="Feature ID") # Rename legend title for node size, and y axis
......@@ -350,8 +353,11 @@ plot_deseq2 <- function(deseq2_res, tss_abundance, context, context_condition,
heatmap <- abundance_df %>% ggplot(aes_string(context_condition, "id", fill="Proportion")) +
geom_tile() +
scale_fill_viridis_d() +
theme_light() +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank())
axis.text.y=element_blank(),
text = element_text(size=13)
)
# Combine the two plots into one
p <- grid.arrange(foldChangePlot,heatmap,ncol=2, widths=c(10,2), top = textGrob(paste("DESeq2 :",cond2,"vs",cond1) ,gp=gpar(fontsize=20,font=3)))
......@@ -545,7 +551,7 @@ for(i in 1:(length(category)-1)){
# Log fold change + heatmap plot
if (taxoProvided){
p <- plot_deseq2(resSig, tss_abundance, context, deseq2_params[["condition"]], category[i], category[j])
ggsave(file=paste0(outdir,"/deseq2_results.svg"), plot = p, width = 20, height = 13)
ggsave(file=paste0(outdir,"/deseq2_results.svg"), plot = p, width = 18, height = 10)
}
# Put boxplot in subdirectory
......
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