0

Currently, I have read in a genbank ptt file and used it to plot a genome in R using genoplotR

    plot_gene_map(dna_segs=list(mo),xlims=xlims,annotations=annotMED,annotation_height=5,main="Region",gene_type="side_blocks",dna_seg_scale=TRUE, scale=FALSE)

I have also read in its corresponding sorted bam file and used rbamtools to make a coverage plot

    start<-130000
    end<-140000
    coords<-as.integer(c(0,start,end))
    range<-bamRange(reader,coords)
    bamClose(reader)
    ad<-alignDepth(range)

    add<-data.frame(ad@pos, ad@depth)

    count<-bamCountAll(reader,verbose=TRUE)

    ggplot(add, aes(x=ad.pos, y=ad.depth)) + geom_histogram(stat="identity", position="dodge") + theme_bw() 

I would now like to overlay these two figures on one graph so we would have a basic genome alignment viewer in R. However, I'm stuck trying to overlay these two figures, as well as matching up there corresponding positions on the x axis.

Any help would be greatly appreciated!

Thanks

1 Answers1

0

Perhaps with viewports, as in this thread here:

Combine base and ggplot graphics in R figure window

Community
  • 1
  • 1
safay
  • 547
  • 5
  • 14