Git Product home page Git Product logo

Comments (3)

krassowski avatar krassowski commented on September 22, 2024

scale_colour_manual() appears to be in an incorrect position, it should not be added to aes() but after upset_set_size() as is scale_y_continuous() in your example.

from complex-upset.

spencsa avatar spencsa commented on September 22, 2024

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'))
  )
)

from complex-upset.

spencsa avatar spencsa commented on September 22, 2024

worked it out. error in scale_fill_manual, where previously it was scale_colour_manual.

Thanks for your help!

from complex-upset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.