Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass ggplot2 objects in HeatmapAnnotation() #261

Closed
RudRho opened this issue Feb 27, 2019 · 2 comments
Closed

pass ggplot2 objects in HeatmapAnnotation() #261

RudRho opened this issue Feb 27, 2019 · 2 comments

Comments

@RudRho
Copy link

RudRho commented Feb 27, 2019

Hi Gu,

Just wondering is it possible to pass ggplot into the HeatmapAnnotation()? This could be a great expansion of many features on the annotations. Like a density plot in rowAnnotation colored by wether samples with mutation or not.

Understand this is asking too much. But any response is greatly appreciated.

Cheers,
MJ

@jokergoo
Copy link
Owner

Theoretically yes, but I haven't tried so far. See following example:

library(ggplot2)
g = ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point()

m = matrix(rnorm(100), 10)
Heatmap(m, top_annotation = HeatmapAnnotation(ggplot = anno_empty(height = unit(6, "cm"))))

decorate_annotation("ggplot", {
	vp = current.viewport()$name
	print(g, vp = vp)
})

screenshot from 2019-02-27 09-16-15

Because you can draw the ggplot2 object in a certain viewport and each heatmap annotation contains a viewport that users can access, but you need to make sure the graphic elements in ggplot2 plots are properly aligned to the heatmap rows or columns.

@RudRho
Copy link
Author

RudRho commented Feb 28, 2019

This is greaaat!

I will try seeing if the alignment works. I will keep you updated.

Cheers
MJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants