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()UpSet (interactive)
The same UpSet layout as UpSet (static), rendered in Plotly with members shown on hover.
upset_interactive
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
Interactive UpSet
Hover any intersection bar to list its members.
upset_interactive({"Fluoxetine": flu, "Ibuprofen": ibu, "Acetaminophen": acet}, title="Drug target intersections", color_list="Set2", figsize=(10.5, 6), wspace = 0.5)Controlling plot aesthetics
| Argument | Controls |
|---|---|
color_list |
list of bar colours, or a colormap name; one per intersection bar |
title, title_fontsize |
figure title text and size |
count_color, count_fontsize |
colour and size of the count above each bar |
hover_size |
font size of the member list in the hover tooltip |
circle_size |
size of the dot-matrix markers |
gridkey_fontsize, axis_fontsize |
font sizes of the set names and the axes |
bar_width, totals_bar_height |
thickness of the intersection and set-total bars |
shading, shading_color |
the alternating row bands behind the dot matrix |
sort_by |
order bars by "cardinality" or "degree" |
figsize |
figure size in inches (converted to pixels) |
save_path |
optional path to save a standalone HTML file |
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.