BYOST.visualize#
Visualization helpers for building blocks, PCA, GPR, and templates.
- BYOST.visualize.hist_2d(df_conditions, bins_condition1=None, bins_condition2=None)[source]#
- Input:
df_conditions: pandas dataframe of the conditions corresponding to df_spectra, e.g., epochs and sBVs bins_condition1: the bins of the hist for condition 1 bins_condition2: the bins of the hist for condition 2
- Output:
fig of the 2D histogram of the given conditions
- BYOST.visualize.plot_PCA(df_buildingblock, df_conditions, n_components=None, PC_vector_sigma=1)[source]#
- Input:
df_buildingblock: pandas dataframe contains resulting PCA and GPR df_conditions: pandas dataframe of the conditions corresponding to df_spectra, e.g., epochs and sBVs n_components: number of PCs to plot, default all of PCs PC_vector_sigma: default 1, the PC projection sigma when plotting the variance represented by the PC vectors
- Output:
Fig of PCA results (first row is PC vectors and its variation, second row is PC projections vs given conditions)
- BYOST.visualize.plot_GPR(df_buildingblock, df_conditions, Wave_bin_ID=0, PC='PC1', view_angle=[32, 300])[source]#
- Input:
df_buildingblock: pandas dataframe contains resulting PCA and GPR df_conditions: pandas dataframe of the conditions corresponding to df_spectra, e.g., epochs and sBVs Wave_bin_ID: default 0, the row index of the df_buildingblock PC: default ‘PC1’ view_angle: default [32,300],the viewing angle of the 3D plot
- Output:
Fig of GPR results, a 3D illustration of the GP fits and the 2D projections on the back
- BYOST.visualize.plot_GPR_score(df_buildingblock)[source]#
- Input:
df_buildingblock: pandas dataframe contains resulting PCA and GPR
- Output:
Fig of GPR scores R^2 (range from 0 to 1, closer to 1 is better)
- BYOST.visualize.plot_template(df_buildingblock, df_conditions, matching_wave_position=None, y_offset_gap=1.0, condition1_sample=None, condition2_sample=None, condition1_colormap='rainbow', condition2_colormap='viridis', log_x=True, log_y=True)[source]#
- Input:
df_buildingblock: pandas dataframe contains resulting PCA and GPR df_conditions: pandas dataframe of the conditions corresponding to df_spectra, e.g., epochs and sBVs matching_wave_position: default will match the flux at the median wavelength postion y_offset_gap: the offset in yaxis between the sampling template condition1_sample: default will sample the mean-std, mean, mean+std of the condition1 values while varying condition2 condition2_sample: default will sample the mean-std, mean, mean+std of the condition2 values while varying condition1 condition1_colormap: the color secheme for varying condition1, default rainbow condition2_colormap: the color secheme for varying condition1, default viridis log_x: default True, wavelength is plotted in log scale log_y: default True, flux is plotted in log scale
- Output:
- Fig of template variation, with 2 panels:
left panel: variation within condition1 while keeping condition2 fixed at certain values right panel: variation within condition2 while keeping condition1 fixed at certain values
- BYOST.visualize.comp_template_with_sample(df_buildingblock, df_sample_with_conditions, label_cols=['cond1', 'cond2'], legend_label='sample', co_comp_Hsiao_temp=False, log_x=True, log_y=True, fig_ax=None, plot_gap=0.7, ymax_shift=0)[source]#
- Input:
df_buildingblock: pandas dataframe contains resulting PCA and GPR df_sample_with_conditions: pandas dataframe contains [‘wave’,’flux’,’cond1’,’cond2’] in columns label_cols: default [‘cond1’,’cond2’], the lables shows at the end of the each spectrum legend_label: default ‘sample’ co_comp_Hsiao_temp: if True, compare with the Hsiao template as well (Hsiao et al., 2007, 2009) log_x: default True, wavelength is plotted in log scale log_y: default True, flux is plotted in log scale fig_ax: if None, a new fig and ax will be created, if not None, then input [fig,ax] plot_gap: the yaxis-gap between each spectrum, default 0.5 ymax_shift: the overall yaxis-shift, default 0
- Output:
fig of template comparison with given sample