yl="Probability\ncorrect (%)", ymin=44, ymax=91, yticks=[50, 70, 90]) print(df_correctness_as_function_of_coherence) myfig.Line(p0, x=[0, 25, 50, 100], y=df_correctness_as_function_of_coherence.values, lc="black", zorder=1) myfig.Scatter(p0, x=[0, 25, 50, 100], y=df_correctness_as_function_of_coherence.values, lc='black', pt='o', lw=0.5, ps=9.8, pc='white', zorder=2) #### # Interbout interval as function of coherence p0 = myfig.Plot(fig, num='', xpos=5, ypos=20.5, plot_height=1.25, plot_width=1.25, lw=1, pc='white',
)[f"fraction_of_time_spent"] fraction_of_time_spent_control = df1.query( "experiment_name == 'virtual_valley_stimulus_control_drosolarva' and region_bin == @region_bin and time_bin == @time_bin" )[f"fraction_of_time_spent"] p_time_spent = ttest_ind(fraction_of_time_spent_experiment, fraction_of_time_spent_control, nan_policy='omit', equal_var=False)[1] myfig.Scatter( p0, x=np.random.random(len(fraction_of_time_spent_experiment)) * 0.1 - 0.05 + x_pos - 0.2, y=fraction_of_time_spent_experiment, lc=color, pt='o', lw=0.5, ps=2, pc='white', zorder=2, alpha=0.5) myfig.Scatter( p0, x=np.random.random(len(fraction_of_time_spent_control)) * 0.1 - 0.05 + x_pos + 0.2, y=fraction_of_time_spent_control, lc='gray', pt='o', lw=0.5, ps=2, pc='white',
zticks=[-50, -25, 0, 14, 25, 50], zl= "Performance index\n(% change relative to control\nfor fraction of time\nspent in the dark ring)" ) for i in range(5): for j in range(5): print(df.index) run_length_multiplier = [0.25, 0.5, 1, 2, 4][i] turn_amplitude_multiplier = [0.25, 0.5, 1, 2, 4][j] myfig.Scatter(p0, x=[i], y=[j], lc='none', pt='s', pc=cmap( norm(df.loc[run_length_multiplier, turn_amplitude_multiplier])), ps=65, vmin=-40, vmax=40) fig.savepdf(root_path / f"figure3_gridsearch", open_pdf=True) sdfsfsf # sdf # print(df.loc[0.5, 0.5]) # # asd # pl.plot(df["phototaxis_index_mean"].values) # #m = [df.loc[]]
angle_change0 = df.query("experiment_name == @experiment_name")[f"angle_change_at_current_turn_event_if_dark_at_current_turn_event"] angle_change1 = df.query("experiment_name == @experiment_name")[f"angle_change_at_current_turn_event_if_bright_at_current_turn_event"] if i == 1: angle_change0 = df.query("experiment_name == @experiment_name")[f"angle_change_at_current_turn_event_if_darkening_since_previous_turn_event"] angle_change1 = df.query("experiment_name == @experiment_name")[f"angle_change_at_current_turn_event_if_brightening_since_previous_turn_event"] for j in range(len(angle_change0)): x1 = np.random.random() * 0.2 - 0.1 + [0, 1, 2.5, 3.5, 6, 7, 8.5, 9.5, 11, 12, 13.5, 14.5, 16, 17, 19.5, 20.5, 22, 23][i * 2] x2 = np.random.random() * 0.2 - 0.1 + [0, 1, 2.5, 3.5, 6, 7, 8.5, 9.5, 11, 12, 13.5, 14.5, 16, 17, 19.5, 20.5, 22, 23][i * 2 + 1] y1 = angle_change0[j] y2 = angle_change1[j] myfig.Line(p0, x=[x1, x2], y=[y1, y2], lc=color, lw=0.25, zorder=1, alpha=0.5) myfig.Scatter(p0, x=[x1], y=[y1], lc=color, pt='o', lw=0.25, ps=2, pc='white', zorder=2, alpha=0.5) myfig.Scatter(p0, x=[x2], y=[y2], lc=color, pt='o', lw=0.25, ps=2, pc='white', zorder=2, alpha=0.5) x1 = [0, 1, 2.5, 3.5][i * 2] x2 = [0, 1, 2.5, 3.5][i * 2 + 1] y1 = np.mean(angle_change0) y2 = np.mean(angle_change1) myfig.Line(p0, x=[x1, x2], y=[y1, y2], lc=color, lw=1, zorder=3, alpha=0.9) myfig.Line(p0, x=[x1, x2], y=[y1, y2], lc=color, lw=1, zorder=3, alpha=0.9) myfig.Scatter(p0, x=[x1, x2], y=[y1, y2], lc=color, pt='o', lw=0.25, ps=2, pc='white', zorder=4, alpha=0.9) p = ttest_1samp(angle_change0 - angle_change1, 0, nan_policy='omit')[1] print("Angle change statistical comparison", i, "Experiment", experiment_name, ": p = ", p, np.mean(angle_change0 - angle_change1), "n = ", len(angle_change0 - angle_change1)) myfig.Line(p0, x=[x1 + 0.1, x2 - 0.1], y=[55, 55], lc='black', lw=0.75)
ymax=91, yticks=[50, 70, 90], vlines=[0]) for optimized_i in range(7) ] # Show the target experimental data myfig.Line(p1_experiment, x=[0, 25, 50, 100], y=target_correctness_as_function_of_coherence.values, lc="black", zorder=1) myfig.Scatter(p1_experiment, x=[0, 25, 50, 100], y=target_correctness_as_function_of_coherence.values, lc='black', pt='o', lw=0.5, ps=9.8, pc='white', zorder=2) myfig.Line( p2_experiment, x=[0, 25, 50, 100], y=target_inter_bout_interval_as_function_of_coherence.values, lc="black", zorder=1) myfig.Scatter( p2_experiment, x=[0, 25, 50, 100], y=target_inter_bout_interval_as_function_of_coherence.values,
luminance_change = df.query( "experiment_name == @experiment_name" )[f"luminance_change_over_last_2s_before_current_turn_event"] if i == 4: luminance_change = df.query( "experiment_name == @experiment_name" )[f"luminance_change_over_last_1s_before_current_turn_event"] x = np.random.random() * 0.2 - 0.1 + i y = luminance_change[j] myfig.Scatter(p0, x=[x], y=[y], lc=color, pt='o', lw=0.5, ps=2, pc='white', zorder=2, alpha=0.5) if i > 0: myfig.Line(p0, x=[x, previous_x], y=[y, previous_y], lc=color, lw=0.5, zorder=1, alpha=0.5) previous_x = x
hlines=[0], xl="", xmin=-0.5, xmax=1.5, xticks=[0, 1], yl="Speed (cm/s)" if i == 0 else None, ymin=-0.1, ymax=0.51, yticks=[0, 0.25, 0.5] if i == 0 else None) myfig.Scatter(p0, x=[0] * 12, y=np.nanmean(speed_over_time_wt[:, int(80):int(100)], axis=1), lc='black', pt='o', lw=0.5, ps=5, pc='white', zorder=2, alpha=0.5) myfig.Scatter(p0, x=[0], y=np.median( np.nanmean(speed_over_time_wt[:, int(80):int(100)], axis=1)), lc='black', pt='o', lw=1, ps=10,
binned_same_direction_mutant_mean = df_extracted_binned_features_same_direction_mutant.query("genotype == @mutant_name").groupby(["bin"]).mean() binned_same_direction_mutant_sem = df_extracted_binned_features_same_direction_mutant.query("genotype == @mutant_name").groupby(["bin"]).sem() histogram_heading_angle_change_mutant_mean = df_extracted_binned_features_heading_angle_change_histograms_mutant.query("genotype == @mutant_name").groupby(["stim", "bin"]).mean() histogram_heading_angle_change_mutant_sem = df_extracted_binned_features_heading_angle_change_histograms_mutant.query("genotype == @mutant_name").groupby(["stim", "bin"]).sem() ##### # Correctness as function of coherence p0 = myfig.Plot(fig, num='b1', xpos=10, ypos=ypos, plot_height=1.25, plot_width=1.25, title="Wildtype / mutant", lw=1, pc='white', errorbar_area=False, xmin=-15, xmax=115, hlines=[50], xticks=[0, 25, 50, 100], xticklabels=[""]*4, yl="Probability\ncorrect (%)", ymin=44, ymax=91, yticks=[50, 70, 90]) myfig.Line(p0, x=[0, 25, 50, 100], y=correctness_as_function_of_coherence_wt_mean, yerr=correctness_as_function_of_coherence_wt_sem, lc="black", zorder=1) myfig.Scatter(p0, x=[0, 25, 50, 100], y=correctness_as_function_of_coherence_wt_mean, lc='black', pt='o', lw=0.5, ps=9.8, pc='white', zorder=2) myfig.Line(p0, x=[0, 25, 50, 100], y=correctness_as_function_of_coherence_mutant_mean, yerr=correctness_as_function_of_coherence_mutant_sem, lc=basecolor, zorder=1) myfig.Scatter(p0, x=[0, 25, 50, 100], y=correctness_as_function_of_coherence_mutant_mean, lc=basecolor, pt='o', lw=0.5, ps=9.8, pc='white', zorder=2) #### # Interbout interval as function of coherence p0 = myfig.Plot(fig, num='b2', xpos=10, ypos=ypos - 1.5, plot_height=1.25, plot_width=1.25, lw=1, pc='white', errorbar_area=False, xl="Coherence (%)", xmin=-15, xmax=115, xticks=[0, 25, 50, 100], hlines=[50], yl="Interbout\ninterval (s)", ymin=0.6, ymax=1.9, yticks=[0.7, 1.2, 1.7]) myfig.Line(p0, x=[0, 25, 50, 100], y=interbout_interval_as_function_of_coherence_wt_mean, yerr=interbout_interval_as_function_of_coherence_wt_sem, lc="black", zorder=1) myfig.Scatter(p0, x=[0, 25, 50, 100], y=interbout_interval_as_function_of_coherence_wt_mean, lc='black', pt='o', lw=0.5, ps=9.8, pc='white', zorder=2) myfig.Line(p0, x=[0, 25, 50, 100], y=interbout_interval_as_function_of_coherence_mutant_mean, yerr=interbout_interval_as_function_of_coherence_mutant_sem, lc=basecolor, zorder=1)
p0 = myfig.Plot(fig, num='', xpos=1.5, ypos=y_pos, plot_height=2.5, plot_width=2.5, lw=1, pc='white', errorbar_area=False, xl=errornames[error_index0], xmin=xmin, xmax=xmax, xticks=xticks, yl=errornames[error_index1], ymin=ymin, ymax=ymax,yticks=yticks, hlines=[0], vlines=[0]) print(F[0][:, error_index0].max()) print(F[0][:, error_index1].max()) res = NonDominatedSorting().do(F[0]) x = F[0][res[0]][:, error_index0] y = F[0][res[0]][:, error_index1] ind = np.where((x < xmax) & (y < ymax)) x = x[ind] y = y[ind] myfig.Scatter(p0, x,y, pt='.', ps=8, lw=0, pc='blue',alpha=0.8) res = NonDominatedSorting().do(F[-1]) x = F[-1][res[0]][:, error_index0] y = F[-1][res[0]][:, error_index1] ind = np.where((x < xmax) & (y < ymax)) x = x[ind] y = y[ind] myfig.Scatter(p0, x, y, pt='.', ps=8, lw=0, pc='red',alpha=0.3) y_pos-= 4 tsne = TSNE(n_components=2, random_state=1) res_initial = NonDominatedSorting().do(F[0])
for i, age in enumerate([7, 14, 21]): group_polarization_rel_chance = np.load( root_path / f"group_polarization_rel_chance_{genotype}_age{age}dpf.npy") group_spacing_rel_chance = np.load( root_path / f"group_spacing_rel_chance_{genotype}_age{age}dpf.npy" ) #[:,::10] / 100 group_speed = np.load( root_path / f"group_speed_{genotype}_age{age}dpf.npy") #[:, :] / 100 myfig.Scatter(p0, x=[i] * group_speed.shape[0], y=group_speed, lc='black', pt='o', lw=0.5, ps=5, pc='white', zorder=2, alpha=0.5) myfig.Scatter(p0, x=[i], y=np.median(group_speed), lc='black', pt='o', lw=1, ps=10, pc='white', zorder=2)
cs_next_shuffled.append(c_next_shuffled) cs_second_next.append(c_second_next) cs_second_next_shuffled.append(c_second_next_shuffled) cs_third_next.append(c_third_next) cs_third_next_shuffled.append(c_third_next_shuffled) all_first_bouts = np.array(all_first_bouts) all_next_bouts = np.array(all_next_bouts) all_first_bouts_shuffled = np.array(all_first_bouts_shuffled) all_next_bouts_shuffled = np.array(all_next_bouts_shuffled) ind1 = np.where((all_first_bouts < 2) & (all_next_bouts < 2)) ind2 = np.where((all_first_bouts_shuffled < 2) & (all_next_bouts_shuffled < 2)) myfig.Scatter(p0, x=all_first_bouts[ind1], y=all_next_bouts[ind1], lc='C3', pt='.', alpha=0.25, ps=1, lw=0.25, rasterized=True) myfig.Scatter(p1, x=all_first_bouts_shuffled[ind2], y=all_next_bouts_shuffled[ind2], lc='gray', pt='.', alpha=0.25, ps=1, lw=0.25, rasterized=True) myfig.Scatter(p2, x=[0], y=[c_next], lc='C3', pt='o', ps=1.5, zorder=2) myfig.Scatter(p2, x=[1], y=[c_next_shuffled], lc='gray', pt='o', ps=1.5, zorder=2) myfig.Line(p2, x=[0,1], y=[c_next, c_next_shuffled], lc='black', lw=0.5, zorder=1) myfig.Scatter(p3, x=[0], y=[c_second_next], lc='C3', pt='o', ps=1.5, zorder=2) myfig.Scatter(p3, x=[1], y=[c_second_next_shuffled], lc='gray', pt='o', ps=1.5, zorder=2) myfig.Line(p3, x=[0, 1], y=[c_second_next, c_second_next_shuffled], lc='black', lw=0.5, zorder=1) myfig.Scatter(p4, x=[0], y=[c_third_next], lc='C3', pt='o', ps=1.5, zorder=2) myfig.Scatter(p4, x=[1], y=[c_third_next_shuffled], lc='gray', pt='o', ps=1.5, zorder=2) myfig.Line(p4, x=[0, 1], y=[c_third_next, c_third_next_shuffled], lc='black', lw=0.5, zorder=1)