krassowski/complex-upset

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

a14578 opened this issue · 5 comments

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

Is $sorted$intersections what you are looking for?

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

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

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:

complex-upset/R/upset.R

Lines 984 to 987 in bb3f10a

intersections_sorted = rev(data$sorted$intersections)
intersections_limits = intersections_sorted[intersections_sorted %in% data$plot_intersections_subset]
scale_intersections = scale_x_discrete(limits=intersections_limits)

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

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!