Extract Interaction Matrix from UpSetR
1
0
Entering edit mode
4.7 years ago
ste.lu ▴ 80

Do you know if there is a way to extract the interaction matrix UpSetR is creating for its plots?

I want to plot the interactions in between the columns of my data.frame, but I have several columns and UpSetR style of plotting is quite heavy. To solve this problem, I'd like to extract the values and interactions UpSetR is calculating for its matrix and use it to build a heatmap which I think will be more easy to read.

Do you have any suggestion on how to export the upsetR data?

What I have in mind (source: Intervene R package): https://intervene.readthedocs.io/en/latest/_images/pairwise_tribar.png

My dataframe structure is like:

dummy_df <- data.frame(A = c(1,1,1,0),
B = c(0,1,0,1),
C = c(0,1,0,1),
D = c(1,0,0,0),
E = c(0,0,0,0))


But I have a 2000x24 dataframe.

If it's not possible to extract this info from UpsetR: Ultimately, I'd like to have a list of interaction which is reporting how many times that columns have "1s" together in the same row. e.g.:

ABC = 1,
BC = 1,
A = 1,


And a matrix reporting the rows which are sharing "1s" in columns (it can be the count, but better a fraction)

 A B C D E
A 1
B 0.25 1
C 0.25 0.5  1
D 0 0 0 1
E 0 0 0 0 1


Any help would be much appreciated.

UpSetR R matrix • 2.1k views
1
Entering edit mode
4.7 years ago

You might find this useful: https://tools.altiusinstitute.org/checkerboard/

Click on "Example" and "Import" buttons in the left-most column, then click on "Select All" in the second column, "Render" in the third column, and you can see the mileage-between-cities-like figure on the right.

To reuse this with your data, you'd just reformat your pairwise matrix into a JSON object like that in the example, and paste it into the input field. Then "Import", "Select All", and "Render" as before.

0
Entering edit mode

Thanks for your answer. Do you know if there is a package (preferably in R) which I can implement in my script?

0
Entering edit mode