Beta Diversity Analysis


A. Beta Diversity Through Plots

http:\/\/qiime.org\/scripts\/beta_diversity_through_plots.html

Description

Now that you have a primer on beta diversity, we can perform some analysis on our data. There exist a work flow script that performs the necessary commands to generate alpha rarefaction plots. The work flow script called beta_diversity_through_plots.py which performs all the necessary steps for calculating, processing and plotting the data. The script is actually composed of 3 different steps\/scripts. (a parameters file can be used to customize each one of the steps) :

  1. beta_diversity.py (http:\/\/qiime.org\/scripts\/beta_diversity.html)
  2. principal_coordinates.py (http:\/\/qiime.org\/scripts\/principal_coordinates.html)
  3. make_emperor.py (http:\/\/biocore.github.io\/emperor\/build\/html\/scripts\/make_emperor.html)

Parameters

--otu_table_fp | -i

Input OTU table in .biom format

--output_dir | -o

The name and location of the output folder. The folder will contain a (.html) file which is an interactive document for viewing your data.

--mapping_fp | -m

The mapping file that corresponds to the input OTU table.

--tree_fp | -t

The phylogenetic tree file. This will end in (.tre) and if you do not include it, you will get an error, unless you customized a parameters file to not include PD whole Tree.

--parameter_fp | -p (optional)

Set of parameters to use for beta diversity analysis. The most common for this commands is the addition of beta diversity metrics such as bray-curtis or euclidean.

Note: You can add --seqs_per_sample | -e if you want to rarefy the data before generating and ploting the distances.

Command

beta_diversity_through_plots.py \
-i otu_table.biom \
-o bdiv_plots/ \
-m mapping_file.txt \
-t rep_set.tre \
-p parameters.txt

Output

The output folder generate from this work flow can be used for further analyses. Below is a breakdown:

Distance matrix files for calculating significance.
bdiv_plots/unweighted_unifrac_dm.txt  
bdiv_plots/weighted_unifrac_dm.txt
Principle coordinate files for remaking PCoA plots
bdiv_plots/unweighted_unifrac_pc.txt   
bdiv_plots/weighted_unifrac_pc.txt

B. Calculating Beta Diversity Significance

http:\/\/qiime.org\/scripts\/compare_categories.html

Description

Once the beta diversity PCoA plot has been generated, you may want to know the significance of the distance between 2 or more groups. There are many different statistical tests available for beta diversity, so it is best to find the appropriate test for your question and for your data set.

See (http:\/\/qiime.org\/tutorials\/category_comparison.html)forfor) more information

Parameters

--input_dm | -i

An input distance matrix found after running beta_diversity_through_plots.py. The same file can also be generated after running beta_diversity.py. The file normally ends in _dm.txt

--output_dir | -o

The name and location of the output folder to store the text file with the statistical results.

--mapping_file | -m

The mapping file that corresponds to the input distance matrix table.

--categories | -c

The column variable name to use for comparing 2 or more groups.

--method

The statistical method to use for comparing sample distances.

See http:\/\/qiime.org\/tutorials\/category_comparison.html for more information about the different types of methods.

Command

# Unweighted UniFrac stats
compare_categories.py \
-i bdiv_plots/unweight_unifrac_dm.txt \
-o bdiv_stats_adonis_unweighted/ \
-m mapping_file.txt \
-c SampleType \
--method adonis

# Weighted UniFrac stats
compare_categories.py \
-i bdiv_plots/weight_unifrac_dm.txt \
-o bdiv_stats_adonis_weighted/ \
-m mapping_file.txt \
-c SampleType \
--method adonis

C. Creating 2D PCoA Beta Diversity Plots

http:\/\/qiime.org\/scripts\/make_2d_plots.html

Another way to represent the beta diversity graphs is to view it in 2 dimensions rather than 3. To create these graphs you can use the command below.

Parameters

--coord_fname | -i

An input principle coordinate file found after running beta_diversity_through_plots.py. The same file can also be generated after running principal_coordinates.py on a distance matrix. The file normally ends in _pc.txt

--output_dir | -o

The name and location of the output folder to store the resulting beta diversity figures

--map_fname | -m

The mapping file that corresponds to the input principle coordinate table.

Command

make_2d_plots.py \
-i bdiv_plots/unweight_unifrac_pc.txt \
-o bdiv_2d_plot/ \
-m mapping_file.txt

D. Making Distance Boxplots

http:\/\/qiime.org\/scripts\/make_distance_boxplots.html

Description

Description

Parameters

--distance_matrix_fp| -d

Description

--output_dir | -o

Description

--mapping_fp | -m

Description

--fields | -f

Description

--save_raw_data

Description

Command

make_distance_boxplots.py \
-d bdiv_plots/unweighted_unifrac_dm.txt \
-o bdiv_plots/unweighted_distance_boxplot
-m mapping_file.txt \
-f "SampleType" \
--save_raw_data

Output

Description


E. Going Further with Beta Diversity PCoA Plots

There are many different ways you can customize your PCoA plot data. When running the beta diversity workflow command, the PCoA is generated using the package Emperor (http:\/\/biocore.github.io\/emperor\/build\/html\/scripts\/make_emperor.html). There are additional parameters within Emperor which can add a custom axes such as Time when plotting your individual samples, connect points of a similar subject and a biplot with taxonomic abundances.

a. Adding Custom Axes

To add a custom axes, such as Time, you can specify the column name that represents Time in your mapping file. The variable does not have to be Time, but could be any group of variable.

The only condition it must satisfy is that is must be numerical, so that the plot knows where to place each set of points that correspond to a particular factor. In this example the Time or custom axes will be the Day column.

#SampleID Subject Treatment Day
A.1 A Control 1
B.1 B Treated 1
A.2 A Control 2
make_emperor.py \
-i bdiv_plots/unweighted_unifrac_pc.txt \
-o bdiv_plots_axes \
-m mapping_file.txt \
--custom_axes Day \

b. Adding Vector Lines

Another option is to connect points that share a common variable. The most useful case is if you would like to connect many points from the sample subject. Use the --add_vectors parameter to set the column variable which will connect the points.

make_emperor.py \
-i bdiv_plots/unweighted_unifrac_pc.txt \
-o bdiv_plots_vector \
-m mapping_file.txt \
--add_vectors Subject \

c. Adding Custom Colors

By default, emperor colors each column variable by its own unique color. If you would like to generate unique colors for each sample based on two or more column variables, you can use the --color_by parameters.

By listing two or more variables separated by &&, you can have Emperor automatically make a unique color for each subject for each day instead of having to create a new column which merges these two variables.

make_emperor.py \
-i bdiv_plots/unweighted_unifrac_pc.txt \
-o bdiv_plots_colorby \
-m mapping_file.txt \
--color_by "Subject&&Day"

d. Creating Biplots (Beta diversity + Taxonomy)

Biplots are a good way to present the separation of samples in addition to the taxa that describes the separation. A biplot presents a single PCoA plot with both a beta diversity metric and taxonomy combined. See http:\/\/emperor.microbio.me\/master\/make_emperor\/biplot\/index.html for an example.

The first step to generate this plot is to generate the relative abundances of the taxa for each sample using the summarize_taxa.py command.

Run summarize taxa, which will generate relative abundance text files for each level of phylogeny.
summarize_taxa.py \
-i otu_table.biom \
-o summarize_taxa
Run the emperor command with the relative abundance file. Use the output from the summarize taxa command.

http:\/\/biocore.github.io\/emperor\/build\/html\/scripts\/make_emperor.html

After you have chosen your preferred level of phylogeny, you can specify how many of the top taxa you would like to keep using the -n option or you can leave it out and it will show all the taxa.

make_emperor.py \
-i bdiv_plots/unweighted_unifrac_pc.txt \
-o bdiv_plots_biplot \
-m mapping_file.txt \
--taxa_fp summarize_taxa/otu_table_L6.txt \
-n 5 \
--biplot_fp biplot.txt

results matching ""

    No results matching ""