0

我有所有样品的相对丰度 (X)。我还为特定属 (Y) 采用了该总体的子集分类单元。我现在如何测量 X 中 Y 的相对丰度?

ps<-phyloseq(ASV,TAX,mapfile,tree) relabun<-transform_sample_counts(ps,function(x) x / sum(x)) ps_genusP <- subset_taxa(ps, Genus == "D_5__Flavisolibacter" | Genus == "D_5__Halomonas"| Genus == "D_5__Thiobacillus"| Genus == "D_5__Sphingomonas"| Genus == "D_5__Bacillus" | Genus == "D_5__uncultured Acidobacterium sp." | Genus == "D_5__Bradyrhizobium"| Genus == "D_5__Ohtaekwangia"| Genus =="D_5__Steroidobacter")

如何找到 ps(总群落)中 ps_genusP 属的相对丰度?

谢谢

4

1 回答 1

0

首先,我可以看到您创建了新的 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" , ]

我希望这会有所帮助。干杯

于 2021-10-02T17:53:54.913 回答