Changes
Page history
Updated Practical 3 Processing 16S rRNA amplicon data (markdown)
authored
Jan 16, 2020
by
Ben Francis
Show whitespace changes
Inline
Side-by-side
Practical-3-Processing-16S-rRNA-amplicon-data.md
View page @
b09d2360
...
...
@@ -111,13 +111,13 @@ For now though, we're just going to use a (relatively) simple plotting function
library(reshape2)
library(RColorBrewer)
plotTaxon <- function(seqtab, taxon, min_abund, taxonomicLevel) {
seqtab
.copy <-
seqtab
seqtab.copy <- data.frame(seqtab.copy)
colnames(seqtab.copy) <- paste(tax[, 1], tax
[,
2
], tax
[, 3], tax[, 4], tax[, 5], tax
[, 6], as.character(1:length(tax[, 1])), sep="-")
seqtab
.copy
<- seqtab
.copy
/rowSums(seqtab
.copy
)
seqtab
.copy
<- seqtab
.copy
[, sapply(seqtab
.copy
, function(x) max(x)) >= min_abund]
seqtab
.copy
$sample <- rownames(seqtab
.copy
)
plotTaxon <- function(seqtab,
taxtable,
taxon, min_abund, taxonomicLevel) {
seqtab
<- data.frame(
seqtab
)
colnames(seqtab) <- paste(taxtable[, 1], taxtable[, 2], taxtable[, 3], taxtable[, 4],
taxtable
[,
5
], tax
table
[, 6], as.character(1:length(tax
table
[, 1])), sep="-")
seqtab <- seqtab/rowSums(seqtab)
seqtab
<-
seqtab
[,
sapply
(
seqtab
,
function
(
x
)
max
(
x
))
>
= min_abund]
seqtab$sample <- rownames(seqtab)
seqtab.m <- melt(seqtab.copy)
seqtab.m <- seqtab.m[grep(taxon, seqtab.m$variable),]
seqtab.m$variable <- gsub("NA", "uncultured", seqtab.m$variable)
...
...
@@ -139,4 +139,4 @@ For now though, we're just going to use a (relatively) simple plotting function
theme_classic() +
theme(axis.text.x=element_text(angle=45, hjust=1))
}
plotTaxon(seqtab, "Bacteroidetes", 0.01, "Genus")
plotTaxon(seqtab
.nochim, taxa
, "Bacteroidetes", 0.01, "Genus")