krassowski / complex-upset

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

How to list intersections, as they appear in an upset plot #164

Closed a14578 closed 1 year ago

a14578 commented 2 years ago

Hello,

Is there a way to extract the list of intersections based on the specific order that they appear in, in an upset plot please? I've generated an upset plot where the sets are ordered in a specific way but when I use the below command the intersections listed are not in the same order as the upset plot:

upset_data(df, gene_list_ordered)$size

krassowski commented 2 years ago

Is $sorted$intersections what you are looking for?

a14578 commented 2 years ago

I just tried the below but it doesn't seem to work. The last intersection in the upset plot appears in the middle of the extracted list.

upset_data(df, gene_list_ordered)$size upset_data(df, gene_list_ordered, sort_sets =FALSE)$size upset_data(df, gene_list_ordered)$sorted$intersections upset_data(df, gene_list_ordered, sort_sets = FALSE)$sorted$intersections

a14578 commented 2 years ago

Alternatively is there a way to add intersection labels to the upset plot on the x axis? Perhaps I could extract the list this way

krassowski commented 2 years ago

I just tried the below but it doesn't seem to work. The last intersection in the upset plot appears in the middle of the extracted list. upset_data(df, gene_list_ordered)$sorted$intersections

It should work because this is how the order of intersections is defined:

https://github.com/krassowski/complex-upset/blob/bb3f10a35eb2033754620aacdedc1d52357f13e4/R/upset.R#L984-L987

Please provide a reproducible example so I can look into this.

krassowski commented 1 year ago

I am going to close this one as I was not able to reproduce the issue, but please reopen if it persists, ideally with a reproducible example. Thanks!