我使用这个名为"phyloseq“的R包来分析生物信息数据。
otumat = matrix(sample(1:100, 100, replace = TRUE), nrow = 10, ncol = 10)
otumat
rownames(otumat) <- paste0("OTU", 1:nrow(otumat))
colnames(otumat) <- paste0("Sample", 1:ncol(otumat))
otumat
taxmat = matrix(sample(letters, 70, replace = TRUE), nrow = nrow(otumat), ncol = 7)
rownames(taxmat) <- rownames(otumat)
colnames(taxmat) <- c("Domain", "Phylum", "Class", "Order", "Family", "Genus",
"Species")
taxmat
library("phyloseq")
OTU = otu_table(otumat, taxa_are_rows = TRUE)
TAX = tax_table(taxmat)
OTU
TAX
physeq = phyloseq(OTU, TAX)
physeq
plot_bar(physeq, fill = "Family")因此,生成的条形图不会将同一系列堆叠在一起。例如,在示例10中有两个独立的"I“块。我知道使用ggplot2绘制的phyloseq曲线图。有没有人知道我可以向lot_bar(physeq,fill =“ggplot2”)添加哪些家族相关代码,以便在条形图中将相同的家族堆叠在一起?

发布于 2016-04-26 04:21:10
您需要重新排序用于x轴的因子的级别。physeq可能有一个名为"Sample“的列(没有安装相关的包),您需要对其中的级别进行重新排序。
应该可以使用如下所示的命令
physeq$Sample <- factor(physeq$Sample, levels = paste0("Sample", 1:10))那么它应该是正确的。
您可能需要挖掘以找到要更改的相关部分
发布于 2017-04-22 03:56:04
实际上,恕我直言,plot_bar函数已经完成了您所要求的操作:
# preliminaries
rm(list = ls())
library("phyloseq"); packageVersion("phyloseq")
data("GlobalPatterns")
gp.ch = subset_taxa(GlobalPatterns, Phylum == "Chlamydiae")
# the function call that does what you're asking for
plot_bar(gp.ch, fill = "Family")有关更多详细信息和示例,请参阅以下帮助教程:
https://joey711.github.io/phyloseq/plot_bar-examples.html
您还可以指定x轴分组。
https://stackoverflow.com/questions/36846577
复制相似问题