Hacking our way

Using the metadata looked complicated to us and hopefully not necessary for what we are trying to accomplish. That is, we really wanted to change the colors of the circles in each row, not the rows themselves. So we found the GitHub repo with the code, plugged a laptop to a TV and started exploring as a group. We went the rabbit hole to see how the matrix.color argument got used. To actually hack our way through, we downloaded the latest version of the code using git.

Next, we created the objects that match the default arguments of upset() by finding and replacing commas by semi-colons. Well, not all of the commas. Also, for inputs that specified a vector (mostly 2 options), we chose the first one to match the default R behavior. This way we could execute them and have them in our session.

Hacking internals

The function upset() is pretty long and uses many un-exported functions from the package itself. In order to test thing quickly we added UpSetR::: calls before the un-exported functions. Here’s our modified version where we added a piece of code to modify the Matrix_layout object and add some colors.

Line colors

Ok, that’s great but we have a problem with the lines. The color is no longer black, so we went deeper into the rabbit hole and found that the internal Make_matrix_plot() function is where the lines are made. We made some edits but got a plot where the lines were on top of the circles as shown in this screenshot.

Our club session was out of time, so we decided to continue our project another day and ask for help on twitter. And yay, we got help super fast!

So here’s our modified version of Make_matrix_plot() that keeps the lines black.

Make_matrix_plot 1 && length(text_scale) <= 6){
name_size_scale

Using that modified version we can then run the code again (note that we are not using UpSetR::: before Make_matrix_plot) and get the plot we wanted.

Matrix

We have quite a bit more to do in order to complete our pull request. We are also curious if you would have used a different approach to hack your way through UpSetR (Gehlenborg, 2016). For example, maybe some functions from devtools(Wickham, Hester, and Chang, 2018) would have enabled to do this equally fast without having to introduce UpSetR::: calls.