无法在 R 包 Divnet 生成的 phyloseq 对象上按组绘图
我打算绘制我的样本的 alpha 多样性图,该图由三组组成。 Alpha多样性是通过R包Divnet计算的。它涉及使用 phyloseq 作为依赖项。
每个样本的组在 phyloseq 对象“df_family”中的 sam_data、列“type”中指定 “dv”是由多样性估计和标准误差组成的列表。
这是我使用的代码:
dv$shannon %>% plot(df_family, color = "type", group = df_family@sam_data$type) +
xlab("sample type") +
ylab("Shannon diversity estimate (family level)") +
coord_cartesian(ylim = c(0,5))`
这是我得到的:
样本是独立显示的,而不是聚集为一组
这是我想要得到的:
I intend to plot an alpha diversity plot of my samples, which consist of three groups.
Alpha diversity is calculated by R package Divnet. It involve using phyloseq as a dependency.
The group of each sample is specified in a sam_data, column "type" in phyloseq object "df_family"
"dv" is list composed of diversity estimates and standard errors.
Here is the code I used:
dv$shannon %>% plot(df_family, color = "type", group = df_family@sam_data$type) +
xlab("sample type") +
ylab("Shannon diversity estimate (family level)") +
coord_cartesian(ylim = c(0,5))`
Here is what I get:
The samples were shown independently, instead of clustered as a group
Here is what I intend to get:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦您有了 phyloseq 对象
df_family
,您就可以使用 phyloseq 中的函数estimate_richness
。然后,您可以将示例元数据连接到该 alpha 多样性数据框。
最后,您可以直接使用 ggplot2 来相应地自定义绘图,例如在 x 轴上放置不同的样本组(此处为
SampleType
):您还可以添加额外的aes 中的示例属性,例如
aes(x = SampleType, y = Shannon, color = my_group)
如果my_group
是单元格包含 f、li 或 si 的示例属性列。Once you already have your phyloseq object
df_family
, you can use the functionestimate_richness
from phyloseq.You can then join the sample meta data to this data frame of alpha diversities.
Finally, you can use
ggplot2
directly to customize your plot accordingly, e.g. to put different sample groups (hereSampleType
) at your x axis:You can also add additional sample properties in aes e.g.
aes(x = SampleType, y = Shannon, color = my_group)
ifmy_group
is a sample property column with cells containing f, li, or si.