Mercurial > repos > artbio > sr_bowtie_dataset_annotation
diff barplot.r @ 4:e11f91575af6 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/sr_bowtie_dataset_annotation commit 618a7892f6af26278364a75ab23b3c6d8cdc73db
author | artbio |
---|---|
date | Wed, 20 Mar 2019 07:12:53 -0400 |
parents | 008de522b3ea |
children | 8829656d6999 |
line wrap: on
line diff
--- a/barplot.r Sun Feb 10 18:31:51 2019 -0500 +++ b/barplot.r Wed Mar 20 07:12:53 2019 -0400 @@ -11,8 +11,7 @@ warnings() library(optparse) library(ggplot2) -library(scales) - +library(ggrepel) #Arguments @@ -37,12 +36,20 @@ ## annotations = read.delim(opt$input, header=F) -colnames(annotations) = c("class", "counts") -annotations = cbind(annotations, fraction=annotations$counts/annotations$counts[1]) -annotations = annotations[-1,] +colnames(annotations) = c("sample", "class", "percent_of_reads", "total") +annotations$percent=round(annotations$percent_of_reads/annotations$total*100, digits=2) # ggplot2 plotting -ggplot(annotations, aes(x="classes", y=fraction, fill=class)) + -geom_bar(width = .7, position=position_stack(), stat = "identity") + -geom_text(aes(label = percent(fraction)), position = position_stack(vjust = 0.5),size = 4) ggtitle('Class proportions') +ggplot(annotations, aes(x=total/2, y = percent_of_reads, fill = class, width = total)) + + geom_bar(position="fill", stat="identity") + + facet_wrap(~sample, ncol=3 ) + geom_label_repel(aes(label = percent), position = position_fill(vjust = 0.5), size=2,show.legend = F) + + coord_polar(theta="y") + + labs(x = "Class fractions (%)") + + theme(axis.text = element_blank(), + axis.ticks = element_blank(), + panel.grid = element_blank(), + axis.title.y = element_blank(), + legend.position="bottom") + + geom_text(aes(x = total/2, y= .5, label = paste(round(total/1000000, digits=3), "M"), vjust = 4, hjust=-1), size=2) ggsave(file=opt$barplot, device="pdf") +