Skip to content

Commit

Permalink
Merge pull request nf-core#47 from Eco-Flow/Better_tree_plots
Browse files Browse the repository at this point in the history
new plots organisation
  • Loading branch information
FernandoDuarteF authored Oct 24, 2024
2 parents b6f060e + 0cf0dd0 commit 63065f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions bin/plot_tree_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,18 @@ for (i in 2:length(column_headers)) {
if (plot_type == "bar") {
bar_plot <- ggplot(data, aes(x = as.numeric(!!sym(column_name)), y = factor(species, levels = rev(tree$tip.label)))) +
geom_bar(stat = "identity", fill = "darkblue") +
geom_text(aes(label = !!sym(column_name)), hjust = -0.1, size = args$text_size) + # Add text labels
geom_text(aes(label = as.numeric(!!sym(column_name)), x = 0), hjust = -0.1, color = "white", size = args$text_size) + # Place text at the base of the bar
theme_minimal() +
theme(axis.title.y = element_blank(),
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
panel.grid.major.y = element_blank(), # Remove horizontal grid lines
panel.grid.minor.y = element_blank(),
panel.grid.major = element_blank(), # Remove vertical grid lines
panel.grid.minor = element_blank(), # Remove minor grid lines
panel.background = element_blank(), # Remove grey background
plot.background = element_blank(), # Remove any outer plot background
plot.margin = margin(0, 0, 0, 0)) +
labs(x = column_name) +
ggtitle(column_name)
Expand Down
2 changes: 1 addition & 1 deletion bin/plot_tree_summary2.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ tree_plot <- ggtree(tree) +
geom_tiplab() +
coord_cartesian(clip="off") +
ggtitle("Phylogenetic Tree") +
theme(plot.margin = margin(10, 150, 10, 10)) # Increase margins
theme(plot.margin = margin(10, 70, 10, 10)) # Increase margins

pdf ("Tree_only.pdf")
tree_plot
Expand Down
4 changes: 2 additions & 2 deletions modules/local/tree_summary.nf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ process TREE_SUMMARY {
sed \'s/.prot.fa.largestIsoform.fa//g\' Quast_to_plot.tsv > Quast_to_plot_final.tsv
# Run summary plot
/usr/bin/Rscript ${projectDir}/bin/plot_tree_summary2.R tree.nw Busco_to_plot_final.tsv
/usr/bin/Rscript ${projectDir}/bin/plot_tree_summary.R tree.nw Quast_to_plot_final.tsv
/usr/bin/Rscript ${projectDir}/bin/plot_tree_summary2.R tree.nw Busco_to_plot_final.tsv --tree_size 0.6
/usr/bin/Rscript ${projectDir}/bin/plot_tree_summary.R tree.nw Quast_to_plot_final.tsv --tree_size 0.6
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down

0 comments on commit 63065f3

Please sign in to comment.