Skip to content

Commit 86b2db5

Browse files
committed
SW_AmpIllumina-B: Rscript execution readme updates
1 parent daaf1a0 commit 86b2db5

File tree

4 files changed

+24
-50
lines changed

4 files changed

+24
-50
lines changed

Amplicon/Illumina/Workflow_Documentation/SW_AmpIllumina-B/workflow_code/Snakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ if config["data_type"] == "SE":
635635
rule r_visualizations:
636636
""" This rule generates R visualizations using trimmed read data and grouping info from the runsheet"""
637637
conda:
638-
"envs/R_visualizations.yaml"
638+
"visualizations/R_visualizations.yaml"
639639
input:
640640
runsheet = config["runsheet"],
641641
sample_info = config["sample_info_file"],

Amplicon/Illumina/Workflow_Documentation/SW_AmpIllumina-B/workflow_code/visualizations/Illumina-R-visualizations.R

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,18 @@ library(grid)
1313
## R visualization script for Illumina paired-end amplicon data ##
1414
##################################################################################
1515
# This script is automatically executed as part of the Snakemake workflow when the run_workflow.py --visualizations TRUE argument is used.
16-
# This script can also be manually executed using processed data from the workflow by using the 'Manual Configuration' section below.
16+
# This script can also be manually executed using processed data from the workflow
1717

18-
####### Manual Configuration ########
19-
# To run the script manually:
20-
# 1. Uncomment and populate lines 23-30
21-
# 2. Comment out the Snakemake configuration section (lines 35-42).
22-
23-
# runsheet_file <- "/path/to/SW_AmpIllumina-B/runsheet.csv"
24-
# sample_info <- "/path/to/SW_AmpIllumina-B/unique-sample-IDs.txt"
25-
# counts <- "/path/to/SW_AmpIllumina-B/workflow_output/Final_Outputs/counts_GLAmpSeq.tsv"
26-
# taxonomy <- "/path/to/SW_AmpIllumina-B/workflow_output/Final_Outputs/taxonomy_GLAmpSeq.tsv"
27-
# final_outputs_dir <- "/path/to/SW_AmpIllumina-B/workflow_output/Final_Outputs/" # Where visualization script outputs will be saved to
28-
29-
# assay_suffix <- "_GLAmpSeq" # Suffix appended to the end of output file names (Default: "_GLAmpSeq")
30-
# output_prefix <- "" # Prefix appended to the start of output file names (Default: "")
31-
#####################################
32-
33-
###### Snakemake Configuration ######
34-
# Assigns arguments to variables based on the snakemake run command
18+
# Store command line args as variables #
3519
args <- commandArgs(trailingOnly = TRUE)
3620
runsheet_file <- paste0(args[1])
3721
sample_info <- paste0(args[2])
3822
counts <- paste0(args[3])
3923
taxonomy <- paste0(args[4])
4024
assay_suffix <- paste(args[5])
41-
final_outputs_dir <- paste0(args[6])
25+
plots_dir <- paste0(args[6])
4226
output_prefix <- paste0(args[7])
43-
#####################################
27+
########################################
4428

4529
RColorBrewer_Palette <- "Set1"
4630

@@ -106,16 +90,16 @@ g_legend <- function(a.gplot){
10690
###########################################
10791

10892
# Assign the directory paths to variables
109-
beta_diversity_out_dir <- paste0(final_outputs_dir, "beta_diversity", .Platform$file.sep)
110-
alpha_diversity_out_dir <- paste0(final_outputs_dir, "alpha_diversity", .Platform$file.sep)
111-
taxonomy_out_dir <- paste0(final_outputs_dir, "taxonomy", .Platform$file.sep)
112-
de_out_dir <- paste0(final_outputs_dir, "da", .Platform$file.sep)
93+
beta_diversity_out_dir <- paste0(plots_dir, "beta_diversity", .Platform$file.sep)
94+
alpha_diversity_out_dir <- paste0(plots_dir, "alpha_diversity", .Platform$file.sep)
95+
taxonomy_out_dir <- paste0(plots_dir, "taxonomy", .Platform$file.sep)
96+
de_out_dir <- paste0(plots_dir, "da", .Platform$file.sep)
11397

11498
abundance_out_dir <- paste0(de_out_dir, "differential_abundance", .Platform$file.sep)
11599
volcano_out_dir <- paste0(de_out_dir, "volcano", .Platform$file.sep)
116100

117101
# List of all directory variables
118-
out_dirs <- list(final_outputs_dir, beta_diversity_out_dir, alpha_diversity_out_dir, taxonomy_out_dir, de_out_dir, abundance_out_dir, volcano_out_dir)
102+
out_dirs <- list(plots_dir, beta_diversity_out_dir, alpha_diversity_out_dir, taxonomy_out_dir, de_out_dir, abundance_out_dir, volcano_out_dir)
119103

120104
# Loop through each directory path to check and create if necessary
121105
for (dir_path in out_dirs) {
@@ -471,7 +455,7 @@ ggsave(filename = paste0(alpha_diversity_out_dir, output_prefix, "richness_and_d
471455
legend <- g_legend(ordination_plot)
472456
grid.newpage()
473457
grid.draw(legend)
474-
legend_filename <- paste0(final_outputs_dir, output_prefix, "color_legend_", assay_suffix, ".png")
458+
legend_filename <- paste0(plots_dir, output_prefix, "color_legend_", assay_suffix, ".png")
475459
increment <- ifelse(length(unique(sample_info_tab$groups)) > 9, ceiling((length(unique(sample_info_tab$groups)) - 9) / 3), 0)
476460
legend_height <- 3 + increment
477461
ggsave(legend_filename, plot = legend, device = "png", width = 11.1, height = legend_height, dpi = 300)

Amplicon/Illumina/Workflow_Documentation/SW_AmpIllumina-B/workflow_code/visualizations/README.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,39 @@ ___
2121

2222
### 1. Set up the execution environment
2323

24-
To ensure that manual execution outputs that are consistent with those of the Snakemake workflow, the script should be executed from a Conda environment created using the [R_visualizations.yaml](/Amplicon/Illumina/Workflow_Documentation/SW_AmpIllumina-B/workflow_code/envs/R_visualizations.yaml/) environment file.
24+
The script should be executed from a Conda environment created using the [R_visualizations.yaml](/Amplicon/Illumina/Workflow_Documentation/SW_AmpIllumina-B/workflow_code/visualizations/R_visualizations.yaml) environment file.
2525

2626
<br>
2727

2828
___
2929

3030
### 2. Run the visualization script manually
3131

32-
To manually execute the script, the following variables: `runsheet_file`, `sample_info`, `counts`, `taxonomy`, `final_outputs_dir`, `assay_suffix`, and `output_prefix`, must be explicitly assigned with appropriate values. For manual execution, the lines within the Snakemake Configuration section should be commented out or removed. These lines are used for capturing variables during execution as part of the Snakemake workflow.
32+
To run the script, the variables `runsheet_file`, `sample_info`, `counts`, `taxonomy`, `assay_suffix`, `plots_dir`, and `output_prefix` must be specified. The script can be manually executed via the command line by providing positional arguments.
3333

34-
Additionally, the `RColorBrewer_Palette` variable can be modified. This variable determines the color palette from the RColorBrewer package that is applied to the plots.
34+
Additionally, the `RColorBrewer_Palette` variable can be modified in the script. This variable determines the color palette from the RColorBrewer package that is applied to the plots.
3535

3636
```R
37-
####### Manual Configuration ########
38-
# To run the script manually:
39-
# 1. Uncomment and populate lines 23-30
40-
# 2. Comment out the Snakemake configuration section (lines 35-42).
41-
42-
# runsheet_file <- "/path/to/SW_AmpIllumina-B/runsheet.csv"
43-
# sample_info <- "/path/to/SW_AmpIllumina-B/unique-sample-IDs.txt"
44-
# counts <- "/path/to/SW_AmpIllumina-B/workflow_output/Final_Outputs/counts_GLAmpSeq.tsv"
45-
# taxonomy <- "/path/to/SW_AmpIllumina-B/workflow_output/Final_Outputs/taxonomy_GLAmpSeq.tsv"
46-
# final_outputs_dir <- "/path/to/SW_AmpIllumina-B/workflow_output/Final_Outputs/" # Where visualization script outputs will be saved to
47-
48-
# assay_suffix <- "_GLAmpSeq" # Suffix appended to the end of output file names (Default: "_GLAmpSeq")
49-
# output_prefix <- "" # Prefix appended to the start of output file names (Default: "")
50-
#####################################
51-
52-
###### Snakemake Configuration ######
53-
# Assigns arguments to variables based on the snakemake run command
37+
# Store command line args as variables #
5438
args <- commandArgs(trailingOnly = TRUE)
5539
runsheet_file <- paste0(args[1])
5640
sample_info <- paste0(args[2])
5741
counts <- paste0(args[3])
5842
taxonomy <- paste0(args[4])
5943
assay_suffix <- paste(args[5])
60-
final_outputs_dir <- paste0(args[6])
44+
plots_dir <- paste0(args[6])
6145
output_prefix <- paste0(args[7])
62-
#####################################
46+
########################################
6347

6448
RColorBrewer_Palette <- "Set1"
6549

6650
```
51+
52+
Example run command:
53+
```bash
54+
Rscript /path/to/visualizations/Illumina-R-visualizations.R "{runsheet_file}" "{sample_info}" "{counts}" "{taxonomy}" "{assay_suffix}" "{plots_dir}" "{output_prefix}"
55+
```
56+
6757
<br>
6858

6959
___
@@ -75,7 +65,7 @@ ___
7565
* `sample_info` – specifies the text file containing the IDs of each sample used, required for running the SW_AmpIllumina workflow (output from [run_workflow.py](/Amplicon/Illumina/Workflow_Documentation/SW_AmpIllumina-B/README.md#5-additional-output-files))
7666
* `counts` – specifies the ASV counts table (output from [GL-DPPD-7104-B step 5g](/Amplicon/Illumina/Pipeline_GL-DPPD-7104_Versions/GL-DPPD-7104-B.md#5g-generating-and-writing-standard-outputs))
7767
* `taxonomy` – specifies the taxonomy table (output from [GL-DPPD-7104-B step 5g](/Amplicon/Illumina/Pipeline_GL-DPPD-7104_Versions/GL-DPPD-7104-B.md#5g-generating-and-writing-standard-outputs))
78-
* `final_outputs_dir` – specifies the path where output files will be saved
68+
* `plots_dir` – specifies the path where output files will be saved
7969
* `assay_suffix` – specifies a string that is prepended to the start of the output file names. Default: ""
8070
* `output_prefix` – specifies a string that is appended to the end of the output file names. Default: "_GLAmpSeq"
8171
* `RColorBrewer_Palette` – specifies the RColorBrewer palette that will be used for coloring in the plots. Options include "Set1", "Accent", "Dark2", "Paired", "Pastel1", "Pastel2", "Set2", and "Set3". Default: "Set1"

0 commit comments

Comments
 (0)