Mercurial > repos > iuc > phyloseq_plot_richness
comparison phyloseq_plot_bar.R @ 7:4faa9c663b38 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 53ece29ec3f7e3c2c51d0ff9849e6193863cca71
| author | iuc |
|---|---|
| date | Sat, 25 Jan 2025 17:12:03 +0000 |
| parents | a20bc31f2821 |
| children | d6cbeb48294d |
comparison
equal
deleted
inserted
replaced
| 6:a20bc31f2821 | 7:4faa9c663b38 |
|---|---|
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 # Generate bar plot | 128 # Generate bar plot |
| 129 if (!is.null(opt$x) && opt$x != "") { | 129 if (!is.null(opt$x) && opt$x != "") { |
| 130 p <- plot_bar(physeq, x = opt$x, fill = opt$fill) | 130 p <- plot_bar(physeq, x = opt$x, fill = opt$fill) + |
| 131 geom_bar(aes(color = NULL, fill = !!sym(opt$fill)), stat = "identity", position = "stack") | |
| 131 } else { | 132 } else { |
| 132 p <- plot_bar(physeq, fill = opt$fill) # If no x is provided, don't include x | 133 p <- plot_bar(physeq, fill = opt$fill) + |
| 134 geom_bar(aes(color = NULL, fill = !!sym(opt$fill)), stat = "identity", position = "stack") | |
| 133 } | 135 } |
| 134 | 136 |
| 135 # Only facet if the facet variable is provided and exists in the sample data | 137 # Only facet if the facet variable is provided and exists in the sample data |
| 136 if (!is.null(opt$facet) && opt$facet != "") { | 138 if (!is.null(opt$facet) && opt$facet != "") { |
| 137 if (opt$facet %in% sample_vars) { | 139 if (opt$facet %in% sample_vars) { |
| 139 } else { | 141 } else { |
| 140 warning(paste("Facet variable", opt$facet, "does not exist in the sample data. Faceting will be skipped.")) | 142 warning(paste("Facet variable", opt$facet, "does not exist in the sample data. Faceting will be skipped.")) |
| 141 } | 143 } |
| 142 } | 144 } |
| 143 | 145 |
| 146 | |
| 144 # Save to output file | 147 # Save to output file |
| 145 ggsave( | 148 ggsave( |
| 146 filename = opt$output, | 149 filename = opt$output, |
| 147 plot = p, | 150 plot = p, |
| 148 width = opt$width, | 151 width = opt$width, |
