alpha_plot.R and beta_plot.R - juanravm/MicroSeqProfiler GitHub Wiki
Alpha and beta diversity plot and statistical analysis (alpha_plot.R and beta_plot.R)
After calculating diversity metrics, this two scripts performs Kruskal-Wallis statistical test in alpha diversity metrics and PERMANOVA statistical test in beta diversity metrics to determine if there are significant differences between metadata groups. This script returns a .csv format file with a table of the pairwise comparisons between groups and their significance. Finally, they make a boxplot for alpha diversity metrics and a PCoA plot for beta diversity metrics with ggplot2 R package.
It is necesary to deactivate qiime2 conda enviroment prior to execute these scripts with the following command, as the R packages instalation must be performed in the base enviroment:
conda deactivate
alpha_plot.R
You can run the alpha_plot.R as shown below:
Rscript /file_path/alpha_plot.R \
--shannon_fp /file_path/diversity/alpha/shannon.tsv \
--evenness_fp /file_path/diversity/alpha/evenness_pd.tsv \
--faith_fp /file_path/diversity/alpha/faith_pd.tsv \
--metadata_fp /file_path/metadata.tsv \
--col Comparison \
--output_dir /directory_path/diversity/alpha/Visualizations
Specifying the variables:
--shannon_fp- shannon.tsv file path. It should be automatically generated indiversity/alphadirectory by diversity.sh script--evenness_fp- evenness_pd.tsv file path. It should be automatically generated indiversity/alphadirectory by diversity.sh script--faith_fp- faith_pd.tsv file path. It should be automatically generated indiversity/alphadirectory by diversity.sh script--metadata_fp- metadata.tsv file path--col- Metadata column with the groups to compare their alpha diversity--output_dir- Visualizations directory path generated automatically indiversity/alphaby diversity.sh script
This script returns:
evenness_pval.csvandpielou_evenness.png- Pielou Evenness boxplot comparing groups and their Kruskal-Wallis statistical analysis in .csv formatfaith_pval.csvandfaith_pd.png- Faith Phylogenetic Diversity boxplot comparing groups and their Kruskal-Wallis statistical analysis in .csv formatshannon_pval.csvandshannon.png- Shannon Index boxplot comparing groups and their Kruskal-Wallis statistical analysis in .csv format
beta_plot.R
Also, you can run the beta_plot.R script as shown below:
Rscript /file_path/beta_plot.R \
--metadata_fp /file_path/metadata.tsv \
--col Comparison \
--bray_fp /file_path/diversity/beta/bray_curtis.tsv \
--unweighted_fp /file_path/diversity/beta/unweighted.tsv \
--weigthed_fp /file_path/diversity/beta/weighted.tsv \
--jaccard_fp /file_path/diversity/beta/jaccard.tsv \
--output_dir /file_path/diversity/beta/Visualizations
Specifying the variables:
--metadata_fp- metadata.tsv file path--col- Metadata column with the groups to compare their beta diversity--bray_fp- bray_curtis.tsv file path. It should be automatically generated indiversity/betadirectory by diversity.sh script--unweighted_fp- unweighted.tsv file path. It should be automatically generated indiversity/betadirectory by diversity.sh script--weigthed_fp- weighted.tsv file path. It should be automatically generated indiversity/betadirectory by diversity.sh script--jaccard_fp- jaccard.tsv file path. It should be automatically generated indiversity/betadirectory by diversity.sh script--output_dir- Visualizations directory path generated automatically indiversity/betaby diversity.sh script
This script returns:
bray_pval.csvandbray_curtis.png- Bray-Curtis PCoA plot comparing groups and their PERMANOVA statistical analysis in .csv formatunweighted.csvandunweighted.png- Unweighted UniFrac PCoA plot comparing groups and their PERMANOVA statistical analysis in .csv formatweighted.csvandweighted.png- Weighted UniFrac PCoA plot comparing groups and their PERMANOVA statistical analysis in .csv formatjaccard.csvandjaccard.png- Jaccard Index PCoA plot comparing groups and their PERMANOVA statistical analysis in .csv format