The variable associated with most differences in the above comparisons is the three-group variable contrasting females who swab their ears, females who do not swab their ears, and males who do not swab their ears. To conclude the analysis, use DESeq2 to test what specific ASVs and genera differ between these three groups.
# Testing function eards2 <- function(phy){
dsO <- phyloseq_to_deseq2(phy, ~ Sampling_season + Swab_3) dsO <- DESeq(dsO, fitType = "parametric", sfType = "poscounts") return(dsO)
}
# Filter out some rare taxa
ear_ASV_right_trim <- filter_taxa(ear_ASV_right, function(x) sum(x > 1) > 5, prune = TRUE) ear_gen_right_trim <- filter_taxa(ear_gen_right, function(x) sum(x > 1) > 5, prune = TRUE)
# Add the three-group swab+sex variable:
sample_data(ear_ASV_right_trim)$Swab_3 <- factor( paste(sample_data(ear_ASV_right_trim)$Sex,
sample_data(ear_ASV_right_trim)$Ear_cleaning_swab, sep = "_"))
sample_data(ear_ASV_right_trim)[sample_data(ear_ASV_right_trim)$Swab_3 == "male_1",
"Swab_3"] <- NA
sample_data(ear_gen_right_trim)$Swab_3 <- sample_data(ear_ASV_right_trim)$Swab_3
# Trim the three swab-user males
ear_ASV_right_trim <- subset_samples(ear_ASV_right_trim, !is.na(Swab_3)) ear_gen_right_trim <- subset_samples(ear_gen_right_trim, !is.na(Swab_3))
# Test at both levels
ear_ds2_ASV <- eards2(ear_ASV_right_trim) ear_ds2_gen <- eards2(ear_gen_right_trim)
# Summarize the significant hits
ear_ds2_contrasts <- list(c("Sampling_season", "spring", "autumn"), c("Swab_3", "female_1", "female_0"), c("Swab_3", "female_1", "male_0"), c("Swab_3", "female_0", "male_0"))
ds2resdf <- data.frame(Variable = sapply(ear_ds2_contrasts, function(x) paste(x, collapse = "_")),
ASVs = NA, Genera = NA)
ds2resdf$ASVs <- sapply(ear_ds2_contrasts, function(x)
nrow(subset(results(ear_ds2_ASV, contrast = x, independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05)))
ds2resdf$Genera <- sapply(ear_ds2_contrasts, function(x)
nrow(subset(results(ear_ds2_gen, contrast = x, independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05)))
Number of significant taxa detected for each contrast in this comparison:
customKable(ds2resdf)
Variable ASVs Genera
Sampling_season_spring_autumn 11 1
Swab_3_female_1_female_0 5 1
Swab_3_female_1_male_0 4 1
Swab_3_female_0_male_0 2 0
The largest amount of taxa is associated with the two extraction batches. The taxa differing between the batches are the following:
# Collect results ds2_batch <- rbind(
data.frame(subset(results(ear_ds2_ASV,
contrast = ear_ds2_contrasts[[1]], independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05),
level = "ASV"),
data.frame(subset(results(ear_ds2_gen,
contrast = ear_ds2_contrasts[[1]], independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05),
level = "Genus"))
# Add taxon names
ds2_batch$Taxon <- rownames(ds2_batch)
ds2_batch[ds2_batch$level == "ASV", "Taxon"] <-
tax_table(ear_ASV_right_trim)[ds2_batch[ds2_batch$level == "ASV", "Taxon"], "Species"]
# Show results
customKable(ds2_batch[, c("baseMean", "log2FoldChange", "lfcSE", "padj", "Taxon")]) baseMean log2FoldChange lfcSE padj Taxon
ASV9 335.256 -4.620 1.139 0.001 ASV9: Corynebacterium unclassified
ASV22 30.201 -23.352 2.157 0.000 ASV22: unclassified
ASV34 125.293 5.757 2.071 0.047 ASV34: Streptococcus salivarius
ASV46 74.818 -9.464 2.563 0.003 ASV46: unclassified
ASV75 36.553 8.729 1.792 0.000 ASV75: Staphylococcus unclassified ASV78 36.297 8.665 1.587 0.000 ASV78: Staphylococcus unclassified ASV93 25.901 7.878 2.177 0.004 ASV93: Staphylococcus unclassified ASV103 67.582 13.527 2.887 0.000 ASV103: Alloiococcus unclassified ASV104 68.656 27.388 2.317 0.000 ASV104: Alloiococcus unclassified ASV207 4.716 -5.577 1.577 0.004 ASV207: Acinetobacter unclassified
ASV211 4.255 -4.580 1.367 0.008 ASV211: unclassified
Corynebacterium 2,300.479 -4.734 0.778 0.000 Corynebacterium The taxa that differ between each contrast for the ear swabbing/sex variable:
Swab-cleaning vs non-swab-cleaning females
ds2_Swab_3_female_1_female_0 <- rbind( data.frame(subset(results(ear_ds2_ASV,
contrast = ear_ds2_contrasts[[2]], independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05),
level = "ASV"),
data.frame(subset(results(ear_ds2_gen,
contrast = ear_ds2_contrasts[[2]], independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05),
level = "Genus"))
# Add taxon names
ds2_Swab_3_female_1_female_0$Taxon <- rownames(ds2_Swab_3_female_1_female_0)
ds2_Swab_3_female_1_female_0[ds2_Swab_3_female_1_female_0$level == "ASV", "Taxon"] <- tax_table(ear_ASV_right_trim)[
ds2_Swab_3_female_1_female_0[ds2_Swab_3_female_1_female_0$level == "ASV",
"Taxon"], "Species"]
# Show results
customKable(ds2_Swab_3_female_1_female_0[, c("baseMean", "log2FoldChange",
"lfcSE", "padj", "Taxon")])
baseMean log2FoldChange lfcSE padj Taxon
ASV3 60,971.397 -7.376 1.284 0.000 ASV3: Alloiococcus otitis
ASV22 30.201 8.355 2.395 0.009 ASV22: unclassified
ASV104 68.656 -27.608 2.616 0.000 ASV104: Alloiococcus unclassified ASV124 4.655 15.961 3.538 0.000 ASV124: Veillonella unclassified
ASV187 23.519 19.636 3.350 0.000 ASV187: Corynebacterium lipophiloflavum Brevibacterium 13.064 -17.419 3.534 0.000 Brevibacterium
Swab-cleaning females vs non-swab-cleaning males ds2_Swab_3_female_1_male_0 <- rbind(
data.frame(subset(results(ear_ds2_ASV,
contrast = ear_ds2_contrasts[[3]], independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05),
level = "ASV"),
data.frame(subset(results(ear_ds2_gen,
contrast = ear_ds2_contrasts[[3]], independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05),
level = "Genus"))
# Add taxon names
ds2_Swab_3_female_1_male_0$Taxon <- rownames(ds2_Swab_3_female_1_male_0)
ds2_Swab_3_female_1_male_0[ds2_Swab_3_female_1_male_0$level == "ASV", "Taxon"] <- tax_table(ear_ASV_right_trim)[
ds2_Swab_3_female_1_male_0[ds2_Swab_3_female_1_male_0$level == "ASV",
"Taxon"], "Species"]
# Show results
customKable(ds2_Swab_3_female_1_male_0[, c("baseMean", "log2FoldChange",
"lfcSE", "padj", "Taxon")])
baseMean log2FoldChange lfcSE padj Taxon
ASV3 60,971.397 -5.450 1.335 0.001 ASV3: Alloiococcus otitis
ASV35 20.830 -9.859 2.346 0.001 ASV35: Chryseobacterium unclassified ASV103 67.582 10.461 3.370 0.045 ASV103: Alloiococcus unclassified ASV104 68.656 -25.602 2.710 0.000 ASV104: Alloiococcus unclassified Brevibacterium 13.064 -25.624 3.643 0.000 Brevibacterium
Non-swab-cleaning females vs males ds2_Swab_3_female_0_male_0 <- rbind(
data.frame(subset(results(ear_ds2_ASV,
contrast = ear_ds2_contrasts[[4]], independentFiltering = FALSE, cooksCutoff = FALSE), padj < 0.05),
level = "ASV"))
# Add taxon names
ds2_Swab_3_female_0_male_0$Taxon <- rownames(ds2_Swab_3_female_0_male_0)
ds2_Swab_3_female_0_male_0[ds2_Swab_3_female_0_male_0$level == "ASV", "Taxon"] <- tax_table(ear_ASV_right_trim)[
ds2_Swab_3_female_0_male_0[ds2_Swab_3_female_0_male_0$level == "ASV",
"Taxon"], "Species"]
# Show results
customKable(ds2_Swab_3_female_0_male_0[, c("baseMean", "log2FoldChange",
"lfcSE", "padj", "Taxon")])
baseMean log2FoldChange lfcSE padj Taxon
ASV124 4.655 -23.475 3.874 0 ASV124: Veillonella unclassified
ASV187 23.519 -24.697 3.683 0 ASV187: Corynebacterium lipophiloflavum
The most abundant taxon that differs between both non-swabbing and swabbing females, and non-swabbing males and swabbing females is ASV3, classified asAlloiococcus otitis. Plot for this:
# Collect data
ear_relabunds <- data.frame(
ASV3 = t(relAbundChart(ear_ASV_right_trim, taxaCount = 10, table=TRUE)["ASV3",]), Swab_3 = factor(sample_data(ear_ASV_right_trim)$Swab_3,
levels = c("female_1", "female_0", "male_0"))) ear_ra_swab3 <- melt(ear_relabunds[, c("ASV3", "Swab_3")]) colnames(ear_ra_swab3) <- c("Swab_3", "Taxon", "Rel_abund")
# Plot
figS4 <- ggplot(ear_ra_swab3, aes(x = Swab_3, y = Rel_abund)) +
geom_boxplot(position = position_dodge(width = 0.75), outlier.size = 1) + theme_bw(base_size = 10) +
ylab("ASV3 relative abundance (%)") +
stat_summary(fun.y = mean, geom = "point", shape = 4, size = 2, position = position_dodge(width = 0.75)) +
xlab(NULL) +
scale_x_discrete(labels = c("female,\nswab", "female,\nno swab", "male,\nno swab")) + theme(panel.grid = element_blank(),
axis.text = element_text(color = "black"), legend.position = "bottom",
legend.key.height = unit(4, "mm"),
legend.margin = margin(t = -1, unit = "mm"), legend.text.align = 0) +
guides(color = guide_legend(nrow = 2, byrow = TRUE))
Figure S4 figS4
0 25 50 75 100
female, swab
female, no swab
male, no swab
ASV3 relative abundance (%)
ggsave(figS4, filename = "Outputs/figS4_alloiococcus_diffs.pdf", device = cairo_pdf, width = 80, height = 65, units = "mm")