# UpSet (interactive)


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/mnicolee/VISET/blob/main/viset/upset_interactive.py#L33"
target="_blank" style="float:right; font-size:smaller">source</a>

### upset_interactive

``` python
def upset_interactive(
    data_dict, color_list:NoneType=None, bar_width:float=0.8, totals_bar_height:float=0.6, matrix_height:float=1.0,
    intersection_plot_elements:int=6, totals_plot_elements:int=2, circle_size:int=100, gridkey_fontsize:int=13,
    axis_fontsize:int=13, hover_size:int=12, count_fontsize:int=12, count_color:NoneType=None, figsize:NoneType=None,
    font:str='Inter', sort_by:str='cardinality', shading:bool=True, shading_color:str='#f0f0f0', wspace:int=0,
    hspace:int=0, title:str='', title_fontsize:int=20, title_fontweight:str='bold', save_path:NoneType=None
):
```

*Call self as a function.*

## Data

``` python
drugbase = ("Drug target sample files/" if __import__("os").path.isdir("Drug target sample files") else "../Drug target sample files/")
flu = pd.read_csv(drugbase + "1. FLUOXETINE_sample.csv")["Gene names"].dropna().tolist()
ibu = pd.read_csv(drugbase + "2. IBUPROFEN_sample.csv")["Gene names"].dropna().tolist()
acet = pd.read_csv(drugbase + "3. ACETAMINOPHEN_sample.csv")["Gene names"].dropna().tolist()
```

## Interactive UpSet

Hover any intersection bar to list its members.

``` python
upset_interactive({"Fluoxetine": flu, "Ibuprofen": ibu, "Acetaminophen": acet}, title="Drug target intersections", color_list="Set2", figsize=(10.5, 6), wspace = 0.5)
```

        <script>
        window.PlotlyConfig = {MathJaxConfig: 'local'};
        if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}
        </script>
        <script type="module">import "https://cdn.plot.ly/plotly-3.6.0.min"</script>
        

<div style="height:432px; width:756.0px;">            <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG"></script><script>if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}</script>                <script>window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
        <script charset="utf-8" src="https://cdn.plot.ly/plotly-3.6.0.min.js" integrity="sha256-QaOVwtVY0T02VaHrr6pnoHLCwayMJp4O5n4YyaE3rJk=" crossorigin="anonymous"></script>                <div id="d4389ede-e7aa-4877-a6b7-a6dd3bebc8e2" class="plotly-graph-div" style="height:100%; width:100%;"></div>            <script>                window.PLOTLYENV=window.PLOTLYENV || {};                                if (document.getElementById("d4389ede-e7aa-4877-a6b7-a6dd3bebc8e2")) {                    Plotly.newPlot(                        "d4389ede-e7aa-4877-a6b7-a6dd3bebc8e2",                        [{"customdata":["BRD2     CYP2E1     PLCG1       TRPV1     UGT1A8\u003cbr\u003eCCND1    CYP7B1     SULT1A4     UGT1A10   UGT2B15\u003cbr\u003eCD44     HLA-DQB1   SULT1E1     UGT1A4\u003cbr\u003eCDK2     HSPA8      SULT2A1     UGT1A5\u003cbr\u003eCXCL8    NPIPB8     TLR4        UGT1A6\u003cbr\u003eCYP2A6   PLA2G4A    TNFRSF11A   UGT1A7","AMACR     CYP2C8   NOS1     TARDBP\u003cbr\u003eAPC       CYP3A5   NOS3     UGT2B17\u003cbr\u003eCXCR1     DDIT3    PIK3CA   UGT2B4\u003cbr\u003eCXCR2     HPGD     PTGER1   UGT2B7\u003cbr\u003eCYP19A1   IFNG     PTGER4   VHL","AANAT   HTR1B   PPP1R1B\u003cbr\u003eACE     HTR2A   REEP5\u003cbr\u003eATXN2   HTR7    SLC6A4\u003cbr\u003eCRHR1   IGF2    SLCO1B1\u003cbr\u003eDRD1    KCNH2   SRP19\u003cbr\u003eGSK3B   NOS2","ABCB1     OPRM1\u003cbr\u003eCOMT      PTGS1\u003cbr\u003eCYP2C19   PTGS2\u003cbr\u003eCYP2C9    UGT1A3\u003cbr\u003eFAAH      UGT1A9","CYP1A2\u003cbr\u003eCYP2D6","CYP3A4","HTR4"],"hoverlabel":{"bgcolor":"rgba(211,211,211,0.5)","font":{"color":"black","family":"Inter, sans-serif","size":12}},"hovertemplate":"%{customdata}\u003cextra\u003e\u003c\u002fextra\u003e","marker":{"color":["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494"]},"showlegend":false,"text":["26","20","17","10","2","1","1"],"textfont":{"color":["#3d7463","#97553b","#55607a","#8b5375","#648232","#99821c","#897659"],"family":"Inter, sans-serif","size":12},"textposition":"outside","width":0.8,"x":[0,1,2,3,4,5,6],"y":[26,20,17,10,2,1,1],"type":"bar","xaxis":"x","yaxis":"y"},{"hoverinfo":"skip","marker":{"color":"#c4c4c4","size":14.0},"mode":"markers","showlegend":false,"x":[0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6],"y":[0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2],"type":"scatter","xaxis":"x3","yaxis":"y3"},{"hoverinfo":"skip","line":{"color":"black","width":1.68},"mode":"lines","showlegend":false,"x":[0,0,null,1,1,null,2,2,null,3,3,null,4,4,null,5,5,null,6,6,null],"y":[0,0,null,1,1,null,2,2,null,0,1,null,0,2,null,1,2,null,0,2,null],"type":"scatter","xaxis":"x3","yaxis":"y3"},{"hoverinfo":"skip","marker":{"color":["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#e78ac3","#a6d854","#a6d854","#a6d854","#ffd92f","#ffd92f","#e5c494","#e5c494"],"line":{"color":"black","width":1.68},"size":14.0},"mode":"markers","showlegend":false,"x":[0,1,2,3,3,4,4,4,5,5,6,6],"y":[0,1,2,0,1,0,1,2,1,2,0,2],"type":"scatter","xaxis":"x3","yaxis":"y3"},{"hoverinfo":"skip","marker":{"color":"black"},"orientation":"h","showlegend":false,"width":0.6,"x":[39,33,21],"y":[0,1,2],"type":"bar","xaxis":"x2","yaxis":"y2"}],                        {"template":{"data":{"histogram2dcontour":[{"type":"histogram2dcontour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"choropleth":[{"type":"choropleth","colorbar":{"outlinewidth":0,"ticks":""}}],"histogram2d":[{"type":"histogram2d","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"heatmap":[{"type":"heatmap","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"contourcarpet":[{"type":"contourcarpet","colorbar":{"outlinewidth":0,"ticks":""}}],"contour":[{"type":"contour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"surface":[{"type":"surface","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"mesh3d":[{"type":"mesh3d","colorbar":{"outlinewidth":0,"ticks":""}}],"scatter":[{"fillpattern":{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"parcoords":[{"type":"parcoords","line":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolargl":[{"type":"scatterpolargl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"scattergeo":[{"type":"scattergeo","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolar":[{"type":"scatterpolar","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"scattergl":[{"type":"scattergl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatter3d":[{"type":"scatter3d","line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattermap":[{"type":"scattermap","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattermapbox":[{"type":"scattermapbox","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterternary":[{"type":"scatterternary","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattercarpet":[{"type":"scattercarpet","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}],"barpolar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"pie":[{"automargin":true,"type":"pie"}]},"layout":{"autotypenumbers":"strict","colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"hovermode":"closest","hoverlabel":{"align":"left"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","polar":{"bgcolor":"#E5ECF6","angularaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"radialaxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"ternary":{"bgcolor":"#E5ECF6","aaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","ticks":""},"caxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]]},"xaxis":{"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","automargin":true,"zerolinewidth":2},"yaxis":{"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","automargin":true,"zerolinewidth":2},"scene":{"xaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white","gridwidth":2},"yaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white","gridwidth":2},"zaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white","gridwidth":2}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"geo":{"bgcolor":"white","landcolor":"#E5ECF6","subunitcolor":"white","showland":true,"showlakes":true,"lakecolor":"white"},"title":{"x":0.05},"mapbox":{"style":"light"}}},"xaxis":{"anchor":"y","domain":[0.31065767195767197,1.0],"matches":"x3","showticklabels":false,"range":[-0.6,6.6],"showgrid":false,"showline":true,"linecolor":"black","linewidth":1},"yaxis":{"anchor":"x","domain":[0.36666666666666664,1.0],"title":{"font":{"size":13,"color":"black"},"text":"Intersection size"},"tickfont":{"size":13,"color":"black"},"range":[0,33.800000000000004],"showgrid":false,"zeroline":false,"showline":true,"linecolor":"black","linewidth":1,"ticks":"outside","tickcolor":"black"},"xaxis2":{"anchor":"y2","domain":[0.0,0.11221851851851854],"title":{"text":"Set size"},"autorange":"reversed","showgrid":false,"showline":true,"linecolor":"black","linewidth":1,"ticks":"outside","tickcolor":"black"},"yaxis2":{"anchor":"x2","domain":[0.0,0.31666666666666665],"range":[2.6,-0.6],"showticklabels":false,"showgrid":false,"zeroline":false},"xaxis3":{"anchor":"y3","domain":[0.31065767195767197,1.0],"range":[-0.6,6.6],"showticklabels":false,"showgrid":false,"zeroline":false},"yaxis3":{"anchor":"x3","domain":[0.0,0.31666666666666665],"tickfont":{"size":13,"color":"black"},"tickvals":[0,1,2],"ticktext":["Acetaminophen","Ibuprofen","Fluoxetine"],"range":[2.6,-0.6],"side":"left","showgrid":false,"zeroline":false},"shapes":[{"fillcolor":"#f0f0f0","layer":"below","line":{"width":0},"type":"rect","x0":0,"x1":1,"xref":"paper","y0":-0.5,"y1":0.5,"yref":"y3"},{"fillcolor":"#f0f0f0","layer":"below","line":{"width":0},"type":"rect","x0":0,"x1":1,"xref":"paper","y0":1.5,"y1":2.5,"yref":"y3"}],"title":{"font":{"size":20,"weight":"bold","color":"black","family":"Inter, sans-serif"},"text":"Drug target intersections"},"font":{"color":"black","family":"Inter, sans-serif"},"margin":{"t":90,"l":110,"r":40,"b":60},"width":756.0,"height":432,"plot_bgcolor":"white"},                        {"responsive": true}                    ).then(function(){
                            &#10;var gd = document.getElementById('d4389ede-e7aa-4877-a6b7-a6dd3bebc8e2');
var x = new MutationObserver(function (mutations, observer) {{
        var display = window.getComputedStyle(gd).display;
        if (!display || display === 'none') {{
            console.log([gd, 'removed!']);
            Plotly.purge(gd);
            observer.disconnect();
        }}
}});
&#10;// Listen for the removal of the full notebook cells
var notebookContainer = gd.closest('#notebook-container');
if (notebookContainer) {{
    x.observe(notebookContainer, {childList: true});
}}
&#10;// Listen for the clearing of the current output cell
var outputEl = gd.closest('.output');
if (outputEl) {{
    x.observe(outputEl, {childList: true});
}}
&#10;                        })                };            </script>        </div>

## Controlling plot aesthetics

<table>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr>
<th>Argument</th>
<th>Controls</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>color_list</code></td>
<td>list of bar colours, or a colormap name; one per intersection
bar</td>
</tr>
<tr>
<td><code>title</code>, <code>title_fontsize</code></td>
<td>figure title text and size</td>
</tr>
<tr>
<td><code>count_color</code>, <code>count_fontsize</code></td>
<td>colour and size of the count above each bar</td>
</tr>
<tr>
<td><code>hover_size</code></td>
<td>font size of the member list in the hover tooltip</td>
</tr>
<tr>
<td><code>circle_size</code></td>
<td>size of the dot-matrix markers</td>
</tr>
<tr>
<td><code>gridkey_fontsize</code>, <code>axis_fontsize</code></td>
<td>font sizes of the set names and the axes</td>
</tr>
<tr>
<td><code>bar_width</code>, <code>totals_bar_height</code></td>
<td>thickness of the intersection and set-total bars</td>
</tr>
<tr>
<td><code>shading</code>, <code>shading_color</code></td>
<td>the alternating row bands behind the dot matrix</td>
</tr>
<tr>
<td><code>sort_by</code></td>
<td>order bars by <code>"cardinality"</code> or
<code>"degree"</code></td>
</tr>
<tr>
<td><code>figsize</code></td>
<td>figure size in inches (converted to pixels)</td>
</tr>
<tr>
<td><code>save_path</code></td>
<td>optional path to save a standalone HTML file</td>
</tr>
</tbody>
</table>

**Colormap names.** Any Matplotlib colormap name works for `color_list`;
qualitative maps keep the sets/bars most distinct: `Set1`, `Set2`,
`Set3`, `Dark2`, `Paired`, `Accent`, `Pastel1`, `Pastel2`, `tab10`,
`tab20`. You can also pass an explicit list of colours instead.
