-
Notifications
You must be signed in to change notification settings - Fork 156
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
Assign plots to a variable. #100
base: master
Are you sure you want to change the base?
Conversation
I have started using UpSetR recently, and I was badly missing this feature. I hope this pull request gets merged soon! |
It would be good to check how this works within knitr and Rmd files before merging. I played briefly with these commits and even if saving to a variable is possible, a suitable print method would also need to be defined. I am not sure how one should go about building and printing the nested ggplots . |
There does seem to be some quirks with the graphical outputs of R notebooks when using the Knitr seems to work ok (see this file) and when you call However due to the nature of the way Upset plots are generated using it on its own in R notebooks and knitr documents results by not assigning to a variable you get multiple plots. While important and worth looking into I think this is a different issue to what I'm trying to address with this pull request. |
I have an alternative implementation for this in #101, I simply hope one of the two gets merged |
is it now possible to save plots into vars? For me it does not work, the result is empty. |
It is possible, just not on the CRAN version. install_github("hms-dbmi/UpSetR")
library("UpSetR")
movies <- read.csv( system.file("extdata", "movies.csv", package = "UpSetR"), header=T, sep=";" )
u <- upset(movies)
summary(u)
print(u) |
Thanks now it works. Great!
does not work |
I found a rather complicated solution but it works (idea from here):
|
Hi
I really like Upset plots and am using them in my work. However as part of a reproducible workflow I would like to be able to assign the plots to variables which can then be called later and if required incorporated into more complex figures.
I realise that this was not an intended use case when
UpsetR
was originally created given the composite nature of the plots but looking through the code and with help from @pmur002 we have come up with a solution. I have renamed all the grobs created inUpset.plot.R
with unique descriptive names which allowgrid.grab()
to distinguish between the components and select them all into agTree
object which I then called at the end ofupset()
.This solution retains all previous functionality but now allows the assigning of plots to variables. This script is a example of what I mean using my adapted code: