Alpha_div.R Tutorial - sciencesharon/MicrobialSeq GitHub Wiki
Alpha_div.R Tutorial
This is the tutorial for how to use the Alpha_div.R script which has the alpha_div_auto function. This function is for downstream use of either Merged_Abundance_Processing.R or process_abundance_data.py. It takes the input of the read count table along with sample metadata and outputs Alpha Diversity calculations for the Chao1 index, Evenness, Richness, and Shannon Diversity Index. It outputs box plots - either four separate box plots or one stacked box plot - along with statistical comparisons between your given groups using Wilcoxon Rank Sum test and adds the p-value (as stars) for the comparisons to the plots. The alpha diversity calculations are saved as a .csv file and the results of the Wilcoxon Rank Sum test are also each saved as .csv files.
Example Input Files
Read Count Table: readcount_example.csv
Metadata: metadata_example.csv
Function usage
Load the read count data and metadata
read.count <- read.csv("/path/to/readcount_example.csv") metadata <- read.csv("/path/to/metadata_example.csv")
Utilize the alpha_div_auto function:
count_data is the read count table, samples must be in columns and taxa in rows
met is the metadata file - the metadata must have samples in rows which match exactly the samples in the columns of the read count table
comparison_var is the grouping variable (one of the columns in your metadata) by which the data will be compared
stack_plots = TRUE outputs the stacked version of the plot
pdf_height and pdf_width change the dimensions of the output pdf files
output_dir is the destination for the files
alpha_div_auto(count_data = read.count, met = metadata, comparison_var = "Timepoint", stack_plots = FALSE, pdf_height = 5, pdf_width = 5, output_dir = "/path/to/file/destination")