Moving Data to and from Other Toolsets: Qiime, R
A. Moving Data from Qiime to Explicet
- Explicet can import data from Qiime via Qiime’s "classic" OTU table format. More recent versions of Qiime require conversion from their internal .biom format to the classic OTU table format as follows:
- convert_biom.py -i table.biom -o table.from_biom_w_taxonomy.txt -b --header_key taxonomy
Additional information on the conversion process may be found here: http://biom-format.org/documentation/biom_conversion.html
- Many thanks to Dr. Lee Stanish for assistance in testing the .biom conversion process.
B. Moving Data from Explicet to R
- Explicet data can be moved to the R package for more advanced statistical analyses. The Explicet tutorial example will be used to illustrate the steps involved in moving data from Explicet to R. (Note: R packages are written by a diverse collection of individuals, and particular functions may require additional data manipulation that is not shown below.)
1. Data Export from Explicet
- Assuming you have built an Explicet project from the Explicet Tutorial, export the following:
An OTU file of count data, selecting the Export to R checkbox (File → Export → OTU). Name this file hsm_otu_cts.txt. Sort the OTUs from greatest to least abundance before exporting so that it is easier to pick out the most abundant OTUs in R.
A metadata file, exported as usual (File → Export → Metadata) and named hsm_meta.txt.
2. Data Import into R
- Open R and change the working directory to the directory storing hsm_otu_cts.txt and hsm_meta.txt.
- Import the OTU file by entering:
hsm_otu_cts <- read.table("hsm_otu_cts.txt",header=TRUE, na.strings = "na", sep="\t")
- Import the metadata file by entering:
hsm_meta <- read.table("hsm_meta.txt",header=TRUE, na.strings = "na", sep="\t")
3. Pre-process OTU File
- Create an object storing the total read counts for each OTU:
hsm_otu_total_reads <- hsm_otu_cts[1,]
- Remove OTU counts from OTU table:
hsm_otu_cts <- hsm_otu_cts[-1,]
- Create an object storing the OTU names:
hsm_otu_nms <- hsm_otu_cts[, 1]
- Remove OTU names from OTU table:
hsm_otu_cts <- hsm_otu_cts[, -1]
- Transform data table so that each row is a different subject:
hsm_otu_cts <- t(hsm_otu_cts)
- Convert to a data matrix:
hsm_otu_cts <- as.matrix(hsm_otu_cts)
Note: The previous three commands can be simplified into the following one command:
hsm_otu_cts <- as.matrix(t(hsm_otu_cts[, -1]))
- Create an object storing the total read counts for each OTU:
- As a check, enter the commands "ncol(hsm_otu_cts)" and "nrow(hsm_otu_cts)" to output the number of columns (131) and rows (30) in the resulting data structure.
4. Pre-process Metadata File
- Enter the commands "ncol(hsm_meta)" and "nrow(hsm_meta)" to output the number of columns (6) and rows (30). The number of rows in the metadata file should match the number of rows in the OTU files, since rows specify the libraries in the datasets.
5. Quick Analysis Using Vegan
- Assuming that "vegan" has been installed in your R environment…
- Load the vegan package: library("vegan")
- To determine whether the skin microbiome differs by Anatomy, enter:
- adonis(hsm_otu_cts ~ hsm_meta$Anatomy, method="bray", permutations = 1000)
The output, shown below, indicates a significant association between Anatomy and skin microbiome. Note: The p-value, under the heading Pr(>F) is calculated using a label-permutation test, so it will differ from run to run.