samecode.plot package

Submodules

samecode.plot.network module

samecode.plot.network.bipartite_graph(left_nodes: dict, right_nodes: dict, edges: dict, direction: dict, ax: object, **kwargs)[source]

Plot attention map: nodes: A list of all nodes in the data edges: A list of all edges in the data [source, target, score] direction: A dict where key is a positive and negative score (defines the direction) pos_color: color for positive scores (raw values of each feature in the population) neg_color: color for positive scores (raw values of each feature in the population) label_color: label color in boxes edge_color: edge color offset_x: For edges and labels overlap offset_y: For edges and labels overlap alpha: alpha for edges

Example:

nodes = [‘<cls>’,

‘Tumor proliferation rate’, ‘Angiogenesis’, ‘Matrix’, ‘Cancer-associated fibroblasts’, ‘Protumor cytokines’, ‘Antitumor cytokines’, ‘Th1 signature’, ‘B cells’, ‘NK cells’, ‘T cells’, ‘MHCI’]

edges = [[‘Matrix’, ‘NK cells’, 8.823914508677685],

[‘Matrix’, ‘T cells’, 8.06140887859505], [‘Angiogenesis’, ‘Th1 signature’, 6.868375098347111]]

direction = {‘Matrix’: 0.30622423947951827,

‘MHCI’: -0.05945478997492155, ‘B cells’: -0.10101842522915781, ‘NK cells’: -0.06531603322426809, ‘T cells’: -0.34819624947872607, ‘Tumor proliferation rate’: 0.6231494073580373, ‘Protumor cytokines’: 0.2560214461158169, ‘Th1 signature’: 0.014631845496634476, ‘<cls>’: 0, ‘Cancer-associated fibroblasts’: 0.4457385288264749, ‘Angiogenesis’: 0.10007748649060139, ‘Antitumor cytokines’: -0.534504312182629}

f, axs = subplots(cols=1, rows=2, w=4.5, h=6.4, return_f=True) attention_plot(

nodes, edges, direction, axs[0], alpha=0.3, edge_color=’black’, offset_x=0.1, rename = {‘<cls>’: ‘Short-term Survivors’, ‘Cancer-associated fibroblasts’: ‘CAFs’, ‘Tumor proliferation rate’: ‘Proliferation’}

)

samecode.plot.props module

samecode.plot.pyplot module

samecode.plot.pyplot.clear_plot(ax, **kwargs)[source]
samecode.plot.pyplot.dibarplot(x, y, legend='', color='black', title='', ylim=[], figsize=(10, 4), x_label='')[source]

Input is a dataframe with the required data.

dibarplot(

x=[‘orange’, ‘abd’], y=[100, 3], legend=’test’, ylim=[0, 2, 29], figsize=(4, 4)

)

samecode.plot.pyplot.mutation_plot(data, classifier, axs=[])[source]
samecode.plot.pyplot.regplot_stats(mutation_counts, x=[], y=[], ax=[], filter=[], label_reg=False, color='black')[source]
samecode.plot.pyplot.skdeplot(df, x, y, ax, **kwargs)[source]

Usage:

skdeplot(

beta_dist, x=’β’, y=’group’, ax=axs[0], offset=0.9, order = [‘Original Scores’, “Perturbing: ” + var2, “Perturbing: ” + var1, ‘Perturbing: Both’], alpha=1

)

samecode.plot.pyplot.subplots(**kwargs)[source]

axs = subplots(rows=1, cols=4, w=8, h=4)

sns.boxplot(y=performance.loc[1].scalars, ax=axs[0]) sns.boxplot(y=performance.loc[7].scalars, ax=axs[1])

[ax.set_ylim([0.7, 1]) for ax in axs];

samecode.plot.pyplot.variable_change_interval(data, axs=[], x_lo=5, x_hi=10, var_x='', var_y='', population=0.25, OS='OS', event='event')[source]

From two surrogate metrics x and y, take an interval on x [x_lo, x_hi]. Then, sort the difference per patient between the two distributions and

samecode.plot.pyplot.variable_change_percentil(data, percentil, ref_x, ref_y, event='event', OS='OS', iterations=10, axs=[], f=[], ref_x_lab='Target Population')[source]
samecode.plot.pyplot.variable_change_percentil_summary(data, ref_x, ref_y, event='event', OS='OS', axs=[], ref_x_lab='TG')[source]
samecode.plot.pyplot.variable_survival_change(data, var, ref, treat, arm, event='event', OS='OS', axs=[], run_name='R', low_p=25, high_p=91)[source]
samecode.plot.pyplot.variable_survival_change_2_metrics(data, var_x, var_y, treatment, arm, event='event', OS='OS', axs=[], run_name='R', low_p=25, high_p=91)[source]

samecode.plot.transformer module

samecode.plot.transformer.attention_plot(nodes: dict, edges: dict, direction: dict, ax: object, **kwargs)[source]

Plot attention map: nodes: A list of all nodes in the data edges: A list of all edges in the data [source, target, score] direction: A dict where key is a positive and negative score (defines the direction) pos_color: color for positive scores (raw values of each feature in the population) neg_color: color for positive scores (raw values of each feature in the population) label_color: label color in boxes edge_color: edge color offset_x: For edges and labels overlap offset_y: For edges and labels overlap alpha: alpha for edges

Example:

nodes = [‘<cls>’,

‘Tumor proliferation rate’, ‘Angiogenesis’, ‘Matrix’, ‘Cancer-associated fibroblasts’, ‘Protumor cytokines’, ‘Antitumor cytokines’, ‘Th1 signature’, ‘B cells’, ‘NK cells’, ‘T cells’, ‘MHCI’]

edges = [[‘Matrix’, ‘NK cells’, 8.823914508677685],

[‘Matrix’, ‘T cells’, 8.06140887859505], [‘Angiogenesis’, ‘Th1 signature’, 6.868375098347111]]

direction = {‘Matrix’: 0.30622423947951827,

‘MHCI’: -0.05945478997492155, ‘B cells’: -0.10101842522915781, ‘NK cells’: -0.06531603322426809, ‘T cells’: -0.34819624947872607, ‘Tumor proliferation rate’: 0.6231494073580373, ‘Protumor cytokines’: 0.2560214461158169, ‘Th1 signature’: 0.014631845496634476, ‘<cls>’: 0, ‘Cancer-associated fibroblasts’: 0.4457385288264749, ‘Angiogenesis’: 0.10007748649060139, ‘Antitumor cytokines’: -0.534504312182629}

f, axs = subplots(cols=1, rows=2, w=4.5, h=6.4, return_f=True) attention_plot(

nodes, edges, direction, axs[0], alpha=0.3, edge_color=’black’, offset_x=0.1, rename = {‘<cls>’: ‘Short-term Survivors’, ‘Cancer-associated fibroblasts’: ‘CAFs’, ‘Tumor proliferation rate’: ‘Proliferation’}

)

Module contents

samecode.plot.plot_arrows(data, **kwargs)[source]
samecode.plot.volcano_plot(data, x, y, top=10, ax=[], label='gene', **kwargs)[source]