lawremi / ggbio

Grid and ggplot2 based visualization for biological data
111 stars 24 forks source link

how to overlay two coverage plots? #92

Open zhenyisong opened 7 years ago

zhenyisong commented 7 years ago

I figured out the following snippet to draw the read coverage plot:

autoplot( xinli.test.gene, geom = 'polygon', stat = 'coverage',
                coverage.col = 'green', fill = 'green', alpha = .2)

xinli.test.gene is a GenomicAlignments object.

However, I would like to overlay two plots, one is the treatment result and the other is the input control. In this case , I do not want to split the coverage plots in two panes as usual.

Instead, the question is, There are two GenomicAlignments objects from two independent experiments, how can I impose one on the other?

Thanks in advance.

lawremi commented 7 years ago

Do you really want to overlay the plots? There would be occlusion when filling. You could combine/stack the GAlignments with a grouping variable tracking their origin. Map that to color and then use lines as the geom. Not sure if ggbio supports that, though.

chrisgulvik commented 6 years ago

@lawremi This could be useful to overlay coverage of long and short reads from the same gDNA sample. Coverage is likely to be quite different (Y-axis), so I think you'd have to specify a ylim or ymax on both but that's a separate issue #105.

Overlapping works: ggplot() + stat_coverage(short.bam, geom = 'line', col = 'red', alpha = 0.2) + stat_coverage(long.bam, geom = 'line', col = 'blue', alpha = 0.2) where bam each are GRanges objects from two different alignment files.