-
Notifications
You must be signed in to change notification settings - Fork 29
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
Issue with fill colours for set sizes #188
Comments
|
Thank you for the quick response. Really appreciate that. Unfortunately the set sizes plot seems to have reverted to the default colours (the same as in your example here: https://krassowski.github.io/complex-upset/articles/Examples_R.html#change-position-and-add-fill.) Code below. Any ideas? upset(
mm1, disease_names, width_ratio=0.2, height_ratio = 0.7,
base_annotations=list(
#Intersection size and annotations)
'Intersection size'=intersection_size(mode = 'exclusive_intersection',
text_mapping=aes(
label=paste0(!!size, '\n(', round(!!get_size_mode('exclusive_intersection')/nrow * 100), '%', ')'
)
), text=list(
size = 2.5), size=0.8,
mapping=aes(fill='bars_color')
) + ylab("Prevalence")
+ scale_y_continuous(labels=function(x) paste0(x/nrow*100, "%"), breaks = seq(0,0.30*nrow,0.10*nrow), limits = c(0,0.30*nrow))
+ scale_fill_manual(values=c('bars_color'= NA), guide='none')
+ theme(plot.background = element_rect(color = 'white', fill = 'white'),
element_line(linewidth = 0, colour = 'white'))
),
#sets and set annotations
encode_sets=FALSE, # for annotate() to select the set by name disable encoding
set_sizes=(
upset_set_size(position='right',
# add colours to the set sizes
geom=geom_bar(
aes(fill=mm_count2, x = group)))
+ scale_colour_manual(values = c(
"0"= 'steelblue1',
"1"= 'firebrick1',
"2" = 'violetred3',
"3" = 'royalblue2',
"4" = 'firebrick',
"5"= 'darkmagenta'))
+ geom_text(aes(label=paste0(..count.., ' (', round(..count../nrow*100), '%', ')')),
stat='count', hjust =1.1, vjust = "middle", size = 2.5, nudge_y = 80)
+ scale_y_continuous(labels=function(x) paste0(x/nrow*100, "%"), breaks = seq(0,0.50*nrow,0.20*nrow), limits = c(0,0.50*nrow))
# you can also add annotations on top of bars:
+ expand_limits(y=400)
+ theme(axis.text.x=element_text(angle=45))
+ ylab('Prevalence of individual diseases')
),
sort_sets = 'FALSE',
sort_intersections_by=c('degree', 'cardinality'),
ggtitle('Full data set'),
sort_intersections = 'ascending',
guides='over',
# colour arrangements for intersection matrix
queries= c(
query_by_degree(
mm1, disease_names,
mode=mode,
matrix=intersection_matrix(
geom=geom_point(shape='circle filled', size=10)),
params_by_degree=list(
'0'=list(color = 'steelblue1', fill='steelblue1'),
'1'=list(color = 'firebrick1', fill='firebrick1'),
'2'=list(color = 'violetred3', fill='violetred3'),
'3'=list( color = 'royalblue2',fill='royalblue2'),
'4'=list(color = 'firebrick',fill='firebrick'),
'5'=list(color = 'darkmagenta', fill='darkmagenta')), shared=list(
only_components=c("intersections_matrix", "Intersection size", "Set size"),
color='turquoise'))
)
)
|
worked it out. error in scale_fill_manual, where previously it was scale_colour_manual. Thanks for your help! |
**I would like to change the fill colours for the set size bars, to produce a stacked bar chart. I have developed my code based on the example coding here (https://krassowski.github.io/complex-upset/articles/Examples_R.html#change-position-and-add-fill).
However, I am unable to change the colours (either by stipulating exact colours or by using scale fill brewer palettes) - when I try other colours, the bars always come out as grey**
**Code **
ComplexUpset version: x.x.x
R version details
R session information
The text was updated successfully, but these errors were encountered: