You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello and thank you so much for this great package!
Objective
I am trying to create a plot, very similar to the ones shown in this part of the tutorial and mentioned in #103 . However, instead of the number (count), I want to show the percentage of each group in the stacked Intersection size bars (see images below). This way, one could easily see if a reduced amount of counts of a given intersection is just a consequence of a reduced amount of total entries of that group.
Sadly I was unable to do this with the sections mentioned in your reply here, as the !!aes_percentage(relative_to='group') directive does not seem to work within the intersection_size() function. And the text_mapping=aes(label=!!upset_text_percentage()) way of displaying the percentages does not split them by the stacked bar plot groups.
Is there a way to do this that I am overlooking?
Thank you so much
RIchard
Code
library(tidyverse)
library(ComplexUpset)
# use data from tutorialmovies= as.data.frame(ggplot2movies::movies)
genres= colnames(movies)[18:24]
movies[genres] =movies[genres] ==1movies[movies$mpaa=='', 'mpaa'] =NA# for cleaner visualisation, split data into two groups ("released before 2000 and after")movies= na.omit(movies) %>% mutate(pre2000=if_else(year<=2000,"old","new"))
plot<- upset(movies,
genres,
width_ratio=0.1,
min_size=0,
wrap=T,
mode="distinct",
base_annotations=list(
'Intersection size'=intersection_size(
counts=F,
mapping=aes(fill=pre2000)
) +
stat_summary(fun=sum,
geom='text',
position=position_stack(vjust=0.5),
aes(label=after_stat(y)), color="white") +
theme(legend.position="top", legend.title= element_blank())
),
annotations=list(
'Percentage of Group'=list(
aes=aes(x=intersection, fill=pre2000),
geom=list(
geom_bar(stat='count', position='fill', na.rm=TRUE),
geom_text(
aes(
label=!!aes_percentage(relative_to='group'),
group=pre2000
),
stat='count',
position=position_fill(vjust=.5)
),
scale_y_continuous(labels=scales::percent_format())
)
)
),
set_sizes=(
upset_set_size(
geom=geom_bar(
aes(fill=pre2000, x=group),
width=0.8, show.legend=FALSE
)
)
)
)
plot
Screenshot or illustration
This is the closest I could get with the code above:
Hello and thank you so much for this great package!
Objective
I am trying to create a plot, very similar to the ones shown in this part of the tutorial and mentioned in #103 . However, instead of the number (count), I want to show the percentage of each group in the stacked Intersection size bars (see images below). This way, one could easily see if a reduced amount of counts of a given intersection is just a consequence of a reduced amount of total entries of that group.
Sadly I was unable to do this with the sections mentioned in your reply here, as the
!!aes_percentage(relative_to='group')
directive does not seem to work within theintersection_size()
function. And thetext_mapping=aes(label=!!upset_text_percentage())
way of displaying the percentages does not split them by the stacked bar plot groups.Is there a way to do this that I am overlooking?
Thank you so much
Code
Screenshot or illustration
This is the closest I could get with the code above:
And this is to show what I want to achieve:
Context (required)
ComplexUpset version: 1.3.3
R version details
R session information
The text was updated successfully, but these errors were encountered: