Sandra
Sandra

Reputation: 81

ComplexUpset: How can I plot ONLY specific intersections?

I am trying to make an upset plot that only shows specific intersections. I have 6 different fjords which generate too many intersections. I am only interested in plotting some of those:

I have run this next script:

upset(fjords, fjordnames, width_ratio=0.15, height_ratio = 0.6, sort_sets=FALSE, sort_intersections = "descending", sort_intersections_by = 'cardinality',
 base_annotations = list('Intersection size'=list(aes=aes(x=intersection, fill=Classification), geom=list(geom_bar(stat = "count", position='stack'),
 theme(panel.border = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.line = element_line(colour = "black")), scale_fill_manual(values=divpalette)))))

I obtained the next plot: Species shared by fjords

But I am only interested in showing the intersections that are marked with the red arrow. I want all the others removed. I have looked for answers but have found none. Is there a way to only select those intersections?

Thank you in advanced

Upvotes: 2

Views: 2305

Answers (1)

krassowski
krassowski

Reputation: 15379

You need to first update to a recent version (minimum recommended 1.2):

install.packages('ComplexUpset')

And then use the intersections argument:

upset(
    movies,
    genres,
    width_ratio=0.1,
    intersections=list(
        'Comedy',
        'Drama',
        c('Comedy', 'Romance'),
        c('Drama', 'Romance'),
        'Outside of known sets',
        'Action'
    )
)

enter image description here

You can keep the order by adding sort_intersections=FALSE.

Upvotes: 2

Related Questions