我使用RStudio为元数据创建了一个桶形图。
plot_bar(mp3, "Sampletype", fill = "Family", title = title)但我在酒吧里要排队,我需要没有线的清楚的酒吧。该怎么做呢?

库(“phyloseq”);packageVersion("phyloseq")
图书馆(“生物格式”);packageVersion(生物格式)
库(“ggplot2”);packageVersion("ggplot2")
库(“phyloseq”);packageVersion("phyloseq")
图书馆(“生物格式”);packageVersion(生物格式)
库(“ggplot2”);packageVersion("ggplot2")
biom1 = biomformat::read_biom(biom_file = "otu_table.json.biom")
mp0 = import_biom(biom1,parseFunction = parse_taxonomy_greengenes)
tax_table(mp0) <- tax_table(mp0),1:7
treeFile1 = "rep_set.tre“
tree1 = read_tree(treeFile1)
tree1
类(Tree1)
mp2 = merge_phyloseq(mp1,tree1) mp2 repseqFile = "seqs_rep_set.fasta“
bs1 =Biostring::readDNAStringSet(RepseqFile)名称(Bs1) <- gsub("\s.+$“、"”、names(bs1))
sum(名称( bs1) %in% taxa_names(mp2)) mp3 = merge_phyloseq(mp2,bs1)
plot_bar(mp3,"Sampletype",fill = "Family",title = title)
发布于 2018-01-18 07:07:11
来自phyloseq包的phyloseq使用ggplot进行绘图。您可以通过在控制台中键入plot_bar代码来查看plot_bar代码,这将产生以下结果:
function (physeq, x = "Sample", y = "Abundance", fill = NULL, title = NULL,
facet_grid = NULL) {
mdf = psmelt(physeq)
p = ggplot(mdf, aes_string(x = x, y = y, fill = fill))
p = p + geom_bar(stat = "identity", position = "stack", color = "black")
p = p + theme(axis.text.x = element_text(angle = -90, hjust = 0))
if (!is.null(facet_grid)) {
p <- p + facet_grid(facet_grid)
}
if (!is.null(title)) {
p <- p + ggtitle(title)
}
return(p)
}如您所见,该函数包括以下语句:
geom_bar(stat = "identity", position = "stack", color = "black")color="black"参数是导致黑线的原因。这是一个非常基本的条形图,您可以根据以下代码创建自己的函数:
library(phyloseq)
my_plot_bar = function (physeq, x = "Sample", y = "Abundance", fill = NULL, title = NULL,
facet_grid = NULL) {
mdf = psmelt(physeq)
p = ggplot(mdf, aes_string(x = x, y = y, fill = fill))
p = p + geom_bar(stat = "identity", position = "stack")
p = p + theme(axis.text.x = element_text(angle = -90, hjust = 0))
if (!is.null(facet_grid)) {
p <- p + facet_grid(facet_grid)
}
if (!is.null(title)) {
p <- p + ggtitle(title)
}
return(p)
}注意,唯一的改变是我已经删除了color="black"。现在您可以运行my_plot_bar而不是plot_bar,并在没有黑线的情况下获得一个条形图。
my_plot_bar(mp3, "Sampletype", fill = "Family", title = title)https://stackoverflow.com/questions/48314292
复制相似问题