Transform dataframes to suit confusion matrix plotting

I have a dataframe like the one below, and I would like to transform it to plot a confusion matrix. :TopL, :TopR, :BotL, :BotR are the four choices, and each time two and only two of them will be presented. :portChoice is what is chosen. :% is the proportion an option is chosen given the same two options (missing data dropped, so don’t always sum to 1).

I want to plot in Makie.jl a 4 x 4 heatmap to show the proportion of choosing one option when the two options are present. For that, I believe I need to transform the data frame into this format: the four option columns serve as both the row and the column, and use the :% column to fill the cell, and let the column to be the chosen option (so it’s not a symmetric matrix). For example, in the current dataframe, row2 and row3 has TopR and BotR to be True, and row2 chose BotR with 0.86 frequency, row3 chose TopR with 0.06 frequency. Then in the transformed dataframe, for row :TopR and column :BotR, the value would be 0.86, and for row :BotR and column :TopR, the value would be 0.06