krassowski / complex-upset

A library for creating complex UpSet plots with ggplot2 geoms
MIT License
458 stars 28 forks source link

What determines the size of the bars? #171

Open bagcik1lumc opened 1 year ago

bagcik1lumc commented 1 year ago

The size of the bars in the intersection chart do not match their percentage value. For example, the 15% bar > 26% bar. How can you change this?

upset(
  M1_BinaryMatrix,
  colnames(M1_BinaryMatrix),
  min_degree=2,
  sort_intersections_by='ratio',
  name="",
  mode="inclusive_intersection",
  set_sizes=(
    upset_set_size(position='right')
    + geom_text(aes(label=paste0(round((..count../nrow(M1_BinaryMatrix))*100), '%')), hjust=1.1, stat='count', color='white')
    + expand_limits(y=1000)
    + ylab("")
    + theme(axis.text.x = element_blank())
  ),
  #
  base_annotations=list(
    'Intersection size'=intersection_size(text_mapping=aes(label=paste0(round(
      !!get_size_mode('inclusive_intersection')/nrow(M1_BinaryMatrix) * 100
    ), '%')))
#    'Intersection ratio'= intersection_ratio(text_mapping=aes(label=paste0(round(
#      !!get_size_mode('inclusive_intersection')/!!nrow(head(M1_BinaryMatrix, 1000)) * 100
#    ), '%')))
    + ylab("") 
    + theme(axis.text.y=element_blank())
  ),
  # sort_intersections='descending',
  #
  stripes=c(alpha('grey90', 0.45), alpha('white', 0.3)),
  matrix = intersection_matrix(    
    geom=geom_point(
      shape='square',
      size=4
    ),
    segment=geom_segment(
      linetype='solid'
    ), 
    outline_color=list(
      active='darkorange3',
      inactive='grey70'
    )
  )
  #
) + labs(title = "", caption = "")
krassowski commented 1 year ago

Please fill in the issue template with a reproducible example

bagcik1lumc commented 1 year ago

Which template?

krassowski commented 1 year ago

https://github.com/krassowski/complex-upset/issues/new?assignees=&labels=help-request&template=help-request.md&title=

or more appropriately

https://github.com/krassowski/complex-upset/issues/new?assignees=&labels=potential-bug&template=bug_report.md&title=

You must have went through the first screens to open the issue (since it is tagged help-request).