glogsdon1 / sunk-based_assembly

14 stars 2 forks source link

draw plot #8

Closed zhoudreames closed 3 years ago

zhoudreames commented 3 years ago

Hi~,would you tell me how to draw this plot? thanks image I have repeat annonation result,but idont how to draw this ploy,would you tell me ?

glogsdon1 commented 3 years ago

I drew the colorful bar plot in R. Here's a snippit of my code, which takes the repeatmasker out table as input (please edit as desired):

centromere colors

myColors <- c("#BFBFBF", "#639BD3", "#FFFFFF", "#A486BD", "#B77CB6", "#FFFFFF", "#E571AB",
"#FFFFFF", "#E97C71", "#FFFFFF", "#FFFFFF",
"#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#55BDC3", "#FFFFFF", "#FFFFFF", "#FFFFFF") names(myColors) <- levels(as.factor(c("ALR/Alpha", "BSR/Beta", "DNA", "DNA?", "GSAT", "HSAT", "snRNA", "LINE", "Low_complexity", "LTR", "RC/Helitron", "Retroposon", "RNA", "rRNA", "SAR", "SATR1", "SATR2", "scRNA", "Simple_repeat", "SINE", "srpRNA", "tRNA")))

ggplot() + geom_segment(data=df, aes(x=start2/1000, y=contig, xend=(end2/1000), yend=contig, color=rClass), size=height*2 ) + scale_color_manual(values=myColors) + scale_x_continuous(breaks = scales::pretty_breaks(n = 12)) + theme_classic() + theme(axis.line.y=element_line(colour="white")) + theme(legend.position="bottom") + theme(legend.key.width = unit(1,"cm")) + theme(legend.title = element_blank()) + guides(color = guide_legend(override.aes = list(size=6))) + xlab("Position (kbp)")

Hope this helps!

zhoudreames commented 3 years ago

thanks