Description Usage Arguments Details Value Author(s) Examples
View source: R/import_itagger_otutab_taxa.R
Converts the tab-delimited iTagger otu.tax.tsv file into a phyloseq object with otu_table and tax_table.
1 | import_itagger_otutab_taxa(in_file)
|
in_file |
otu.tax.tav file |
The iTagger otu.tax.tsv file is similar to legacy QIIME format. This function expects six ranks: Kingdom, Phylum, Class, Order, Family, and Genus. The taxonomy field in otu.tax.tsv is parsed on semicolons.
A phyloseq object with OTU and taxonomy tables.
John Quensen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ##---- Not run. ----
##-- expt <- import_itagger_otutab_taxa(in_file = "iTagger_otutab_taxa_file.txt")
## The function is currently defined as
function (in_file)
{
temp <- read.table(file = in_file, comment.char = "", header = TRUE,
row.names = 1, stringsAsFactors = FALSE, sep = "\t")
otu <- temp[, 1:ncol(temp) - 1]
otu <- otu_table(as.matrix(otu), taxa_are_rows = TRUE, errorIfNULL = TRUE)
tax <- matrix(data = NA, nrow = nrow(temp), ncol = 6)
rownames(tax) <- rownames(temp)
colnames(tax) <- c("Kingdom", "Phylum", "Class", "Order",
"Family", "Genus")
for (i in 1:nrow(temp)) {
l <- temp[i, ncol(temp)]
l.s <- strsplit(l, split = ";", fixed = TRUE)
n <- length(l.s[[1]])
for (j in 1:n) {
tax[i, j] <- l.s[[1]][j]
}
}
for (i in 1:nrow(tax)) {
for (j in 1:ncol(tax)) {
if (is.na(tax[i, j])) {
t <- paste("uncl", tax[i, j - 1], sep = "_")
for (n in j:ncol(tax)) {
tax[i, n] <- t
}
}
}
}
tax <- tax_table(tax, errorIfNULL = TRUE)
expt <- phyloseq(otu, tax)
return(expt)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.