|
| 1 | +import pandas as pd |
| 2 | +import matplotlib.pyplot as plt |
| 3 | +from fishplotpy import FishPlotData, fishplot, draw_legend |
| 4 | + |
| 5 | +timepoints = [0.0, 2.0, 3.0, 4.0] |
| 6 | +frac_table = pd.DataFrame([ |
| 7 | + [15, 40, 50, 100], |
| 8 | + [1, 15, 20, 60], |
| 9 | + [ 1, 5, 20, 20], |
| 10 | + [ 0, 0, 3, 20] |
| 11 | +], columns=timepoints) |
| 12 | +parents = [0, 1, 1, 3] # first root (0), second and third inside the first one, fourth is inside the third one. |
| 13 | + |
| 14 | +custom_labels = ["Founder (WT)", "Gain(Chr3)", "Mut(GeneA)", "DoubleHit+Resist"] |
| 15 | +custom_colors = ['#FFFFFF', '#4682B4', '#FF4500', '#2E8B57'] |
| 16 | + |
| 17 | +custom_annots_base = ["First", "Second", "Third", "Fourth"] |
| 18 | + |
| 19 | +fish_data = FishPlotData( |
| 20 | + frac_table=frac_table, |
| 21 | + parents=parents, |
| 22 | + timepoints=timepoints, |
| 23 | + clone_labels=custom_labels, |
| 24 | + colors=custom_colors, |
| 25 | + clone_annots=custom_annots_base, |
| 26 | + clone_annots_angle=45, |
| 27 | + clone_annots_pos=5, |
| 28 | + clone_annots_offset=0.6, |
| 29 | + clone_annots_col='#111111', |
| 30 | + clone_annots_cex=0.9 |
| 31 | +) |
| 32 | + |
| 33 | +fish_data.layout_clones() |
| 34 | + |
| 35 | +fig, ax = plt.subplots(figsize=(9, 6.5)) |
| 36 | +fig.subplots_adjust(left=0.05, right=0.95, bottom=0.22, top=0.88) |
| 37 | + |
| 38 | +fishplot( |
| 39 | + fish_data, |
| 40 | + ax=ax, |
| 41 | + shape="spline", |
| 42 | + pad_left_frac=0.1, |
| 43 | + vlines=timepoints, |
| 44 | + vlab=[f"T={int(t)}" for t in timepoints], |
| 45 | + cex_vlab=0.75, |
| 46 | + col_vline="#cccccc", |
| 47 | + border=0.6, |
| 48 | + col_border="#666666", |
| 49 | + bg_type='solid', |
| 50 | + bg_col='#f0f0f0', |
| 51 | + use_annot_outline=True |
| 52 | +) |
| 53 | + |
| 54 | +ax.set_title("Muller Graphs Testing", fontsize=14, weight='bold', pad=25) |
| 55 | + |
| 56 | +ax.text(ax.get_xlim()[0] - fish_data.timepoints[-1]*0.02, 50, 'Clonal Fraction (%)', |
| 57 | + ha='right', va='center', fontsize=9, rotation=90, color='#444444') |
| 58 | + |
| 59 | +draw_legend( |
| 60 | + fish_data, |
| 61 | + fig=fig, |
| 62 | + ncol=4, |
| 63 | + frameon=True, |
| 64 | + title="Clone Identity", |
| 65 | + loc='upper center', |
| 66 | + bbox_to_anchor=(0.5, 0.15), |
| 67 | + cex=0.9 |
| 68 | +) |
| 69 | + |
| 70 | +plt.show() |
0 commit comments