Ejemplo n.º 1
0
def plot_cno_saline():
    data: pd.DataFrame = pd.read_csv(
        analysis_folder.joinpath("decoder_cno.csv"),
        usecols=[1, 2, 3],
        index_col=[2, 1]).sort_index()  # type: ignore
    group_strs = ('saline', 'cno')
    paired_data = [data.loc[treat, 'mutual_info'] for treat in group_strs]
    p_value = wilcoxon(*paired_data).pvalue
    res = ["median: "] + str(data.groupby("treat").median()).split('\n')[2:]
    print_stats("saline vs. cno in Gq", res + [f"paired wilcox: p={p_value}"])
    with Figure(fig_folder.joinpath("decoder-pair-cno.svg"),
                figsize=(6, 9)) as axes:
        boxplots = plots.boxplot(axes[0],
                                 paired_data,
                                 whis=(10., 90.),
                                 zorder=1,
                                 showfliers=False,
                                 colors=colors[2:4],
                                 widths=0.65)
        plots.dots(axes[0], paired_data, zorder=3, s=24)
        axes[0].set_xticklabels(["Gq Saline", "Gq CNO"])
        plots.annotate_boxplot(axes[0], boxplots, 24, 1.2, [((0, 1), p_value)])
        [
            axes[0].plot([1, 2], x, color='gray')
            for x in np.array(paired_data).T
        ]
Ejemplo n.º 2
0
 def temp(data, ax, name, jitter=0.1):
     res = ["median: "]
     res.extend(str(data.groupby("group").median()).split("\n")[1:-1])
     annotation = list()
     for (idx, x), (idy, y) in combinations(enumerate(groups), 2):
         p = mannwhitneyu(data.loc[x, ], data.loc[y, ]).pvalue
         if p < 0.05:
             res.append(f"mann u {x} v. {y}, p={p}")
             annotation.append(((idx, idy), p))
     print_stats(name, res)
     values = [data.loc[x, ].tolist() for x in groups]
     boxplots = plots.boxplot(ax,
                              values,
                              zorder=1,
                              whis=(10., 90.),
                              showfliers=False,
                              colors=colors)
     plots.dots(ax, values, zorder=3, s=24, jitter=jitter)
     plots.annotate_boxplot(ax, boxplots, 24, 1.2, annotation)
     ax.set_xticklabels(group_strs)
     ax.set_ylabel(name)
Ejemplo n.º 3
0
 def temp(data, ax, name):
     res = ["median: "] + str(
         data.groupby('group').median()).split('\n')[2:]
     group_names = ('wt', 'glt1', 'dredd')
     group_strs = ["WT", "GLT1", "Gq"]
     annotation = list()
     for (idx, x), (idy, y) in combinations(enumerate(group_names), 2):
         p = mannwhitneyu(data.loc[x, ], data.loc[y, ], True,
                          'two-sided').pvalue
         res.append(f"mann u, {x} v. {y} p={p}")
         if p < 0.05:
             annotation.append(((idx, idy), p))
     print_stats(name, res)
     values = [data.loc[x, "mutual_info"] for x in group_names]
     boxplots = plots.boxplot(ax,
                              values,
                              whis=(10., 90.),
                              zorder=1,
                              showfliers=False,
                              colors=colors)
     plots.dots(ax, values, zorder=3, s=24, jitter=0.02)
     ax.set_xticklabels(group_strs)
     plots.annotate_boxplot(ax, boxplots, 24, 1.2, annotation)
Ejemplo n.º 4
0
def draw_diagnal():
    data = pd.read_csv(proj_folder.joinpath("data", "analysis", "classifier_power_validated.csv"))
    means = data.groupby(["id", "session", "group", "type"]).mean()
    colors = {'wt': '#00272B', 'glt1': '#099963', 'dredd': '#F94040', "gcamp6f": "#619CFF"}
    xs, ys = zip(*[(means.query(f"type=='corr' and group=='{group}'")['precision'].values,
                    means.query(f"type=='mean' and group=='{group}'")['precision'].values)
                   for group in ('wt', 'gcamp6f', 'glt1', 'dredd')])
    # customize Figure generation
    fig = plt.figure(figsize=(9, 9))
    ax1 = fig.add_subplot()
    pair(xs, ys, [colors[x] for x in ('wt', 'gcamp6f', 'glt1', 'dredd')], ax1,
         density_params={"bw": 0.5}, scatter_params={"alpha": 0.7})
    plt.savefig(fig_folder.joinpath("classifier-scatterplot.svg"))
    fig2 = plt.figure(figsize=(4, 9))
    ax2 = fig2.add_subplot(1, 1, 1, sharey=ax1)
    data_mean = data[data.type == "mean"]
    data_mean = data_mean.set_index(["group", "id", "session"])
    values_mean = [data_mean.loc[group_str, 'precision'].values for group_str in ('wt', 'glt1', 'dredd')]
    boxplot = plots.boxplot(ax2, values_mean, whis=(10., 90.), showfliers=False, colors=colors.values())
    plots.annotate_boxplot(ax2, boxplot, 16, 1.0, p_values=[((0, 1), 0.334), ((0, 2), 0.964)])
    ax2.set_xticklabels(["WT", 'gcamp6s', "GLT1", "Gq"])
    ax2.set_ylim(*ax1.get_ylim())
    plt.savefig(fig_folder.joinpath("classifier-edge.svg"))
    plt.show()