首先,我可以看到您创建了新的 phyloseq 对象 ( ps_genusP
)ps
而不是您的relabun
. 这样,ps_genusP
显示原始计数数据而不是相对丰度。此外,您可能希望在属级别聚合数据。
至于你的问题,我最喜欢的方法是将我的 phyloseq 对象转换为数据框,然后使用 tidyverse 函数来访问我需要的任何信息。
所以,在你的鞋子里,我会这样做:
library(phyloseq)
library(dplyr)
library(tidyr)
relabun.ps <- transform_sample_counts(ps,function(x) x / sum(x))
ps_genus <- tax_glom(relabun.ps, taxrank = "Genus", NArm = FALSE)
ps_genusP <- subset_taxa(ps_genus, Genus %in% c("D_5__Flavisolibacter", "D_5__Halomonas",
"D_5__Thiobacillus", "D_5__Sphingomonas",
"D_5__Bacillus", "D_5__uncultured Acidobacterium sp.",
"D_5__Bradyrhizobium", "D_5__Ohtaekwangia",
"D_5__Steroidobacter")
genus.df <- psmelt(ps_genusP)
head(genus.df)
names(myphyla.df) # to choose factors you want to use to navigate
MySummary <- genus.df %>%
group_by(Factor1, Factor2, Genus) %>%
summarize(mean_abund = mean(Abundance, na.rm=TRUE))
head(MySummary)
现在您将拥有一个如下所示的数据框:
*小标题:6 x 6 组:Factor1、Factor2
Factor1 Factor2 Genus mymean
1 Level1 LevelA Genus1 0.107
2 Level1 LevelA Genus2 8.83
3 Level1 LevelB Genus1 0.0101
4 Level1 LevelB Genus2 17.2
5 Level2 LevelA Genus1 0.533
6 Level2 LevelA Genus2 0.00121*
您可以使用它来提取信息:
MySummary[MySummary$Genus == "Genus1" & MySummary$Factor1 == "Level1" , ]
我希望这会有所帮助。干杯