我使用RStudio
为宏基因组数据创建了一个条形图plot_bar(mp3, "Sampletype", fill = "Family", title = title)
但是我在酒吧里面有线条。我需要没有任何线条的明显条形图。怎么做?
库( “phyloseq”); packageVersion( “phyloseq”)
库( “biomformat”); packageVersion( “biomformat”)
库( “GGPLOT2”); packageVersion( “GGPLOT2”)
库( “phyloseq”); packageVersion( “phyloseq”)
库( “biomformat”); packageVersion( “biomformat”)
库( “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)
树1
类(树1)
mp2 = merge_phyloseq(mp1,tree1) MP2 repseqFile =“seqs_rep_set.fasta”
bs1 = Biostrings :: readDNAStringSet(repseqFile) 名称(bs1)< - gsub(“\ s。+ $”,“”,名称(bs1))
总和(%taxa_names(mp2)中的名称(bs1)%) mp3 = merge_phyloseq(mp2,bs1)
plot_bar(mp3,“Sampletype”,fill =“Family”,title = title)
答案 0 :(得分:1)
plot_bar
包的 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)