def Main(): args = parser.parse_args() cty_type = args.cty cty_list = args.cty_list data_path = os.path.join(os.path.dirname(man_opt.__file__), os.pardir, 'assets', 'aggregated_data') mouse_data_filename = os.path.join(data_path, 'Mouse_class_data.csv') mouse_datatype_filename = os.path.join(data_path, 'Mouse_class_datatype.csv') me_ttype_map_path = os.path.join(data_path, 'me_ttype.pkl') sdk_data_filename = os.path.join(data_path, 'sdk.csv') sdk_datatype_filename = os.path.join(data_path, 'sdk_datatype.csv') sdk_data = man_utils.read_csv_with_dtype(sdk_data_filename, sdk_datatype_filename) if cty_type == 'ttype': mouse_data = man_utils.read_csv_with_dtype(mouse_data_filename, mouse_datatype_filename) me_ttype_map = utility.load_pickle(me_ttype_map_path) metype_cluster = mouse_data.loc[ mouse_data.hof_index == 0, ['Cell_id', 'Dendrite_type', 'me_type']] sdk_me = pd.merge(sdk_data, metype_cluster, how='left', on='Cell_id').dropna(how='any', subset=['me_type']) sdk_me['ttype'] = sdk_me['me_type'].apply(lambda x: me_ttype_map[x]) cell_df = sdk_me.loc[sdk_me.ttype.isin(cty_list), ] elif cty_type == 'Cre_line': cell_df = sdk_data.loc[sdk_data.line_name.isin(cty_list), ] cell_ids = cell_df.Cell_id.unique().tolist() rc = Client(profile=os.getenv('IPYTHON_PROFILE')) logger.debug('Using ipyparallel with %d engines', len(rc)) lview = rc.load_balanced_view() lview.map_sync(get_efeatures, cell_ids)
data_path = os.path.join(os.getcwd(), os.pardir, os.pardir, 'assets', 'aggregated_data') mouse_data_filename = os.path.join(data_path, 'Mouse_class_data.csv') mouse_datatype_filename = os.path.join(data_path, 'Mouse_class_datatype.csv') train_ephys_max_amp_filename = os.path.join( data_path, 'train_ephys_max_amp.csv') train_ephys_max_amp_dtype_filename = os.path.join( data_path, 'train_ephys_max_amp_dtype.csv') train_ephys_max_amp_fields_filename = os.path.join( data_path, 'train_ephys_max_amp_fields.json') hof_model_ephys_max_amp_filename = os.path.join( data_path, 'hof_model_ephys_max_amp.csv') hof_model_ephys_max_amp_dtype_filename = os.path.join(data_path, 'hof_model_ephys_max_amp_datatype.csv') mouse_data_df = man_utils.read_csv_with_dtype( mouse_data_filename, mouse_datatype_filename) ephys_data = man_utils.read_csv_with_dtype(train_ephys_max_amp_filename, train_ephys_max_amp_dtype_filename) model_ephys_data = man_utils.read_csv_with_dtype(hof_model_ephys_max_amp_filename, hof_model_ephys_max_amp_dtype_filename) # %% Fix the cell-type label for coloring layer_cty = 1 me_cty = 0 if layer_cty: cty_cluster = mouse_data_df.loc[mouse_data_df.hof_index == 0, ['Cell_id', 'Layer', 'Broad_Cre_line', ]] cty_cluster.dropna(axis=0, inplace=True, how='any') cty_cluster['cty_layer'] = cty_cluster.apply(
# %% Data path data_path = os.path.join(os.getcwd(), os.pardir, os.pardir, 'assets', 'aggregated_data') mouse_data_filename = os.path.join(data_path, 'Mouse_class_data.csv') mouse_datatype_filename = os.path.join(data_path, 'Mouse_class_datatype.csv') param_data_filename = os.path.join(data_path, 'allactive_params.csv') param_datatype_filename = os.path.join(data_path, 'allactive_params_datatype.csv') broad_subclass_colors_filename = os.path.join(data_path, 'broad_subclass_colors.pkl') me_ttype_map_path = os.path.join(data_path, 'me_ttype.pkl') # %% Loading data mouse_data_df = man_utils.read_csv_with_dtype(mouse_data_filename, mouse_datatype_filename) mouse_data_df = man_utils.add_transcriptomic_subclass(mouse_data_df, me_ttype_map_path) mouse_data_df = man_utils.add_broad_subclass(mouse_data_df) hof_param_data = man_utils.read_csv_with_dtype(param_data_filename, param_datatype_filename) subclass_cluster = mouse_data_df.loc[mouse_data_df.hof_index == 0, ['Cell_id', 'Broad_subclass']] hof_param_subclass = pd.merge(hof_param_data, subclass_cluster, how='left', on='Cell_id') broad_subclass_color_dict = utility.load_pickle(broad_subclass_colors_filename)
def shorten_channel_name(param_name): sec = param_name.split('.')[-1] shortened_name = replace_channel_name(param_name) if sec in shortened_name: return shortened_name else: return shortened_name + f'.{sec}' # %% Model paths data_path = Path( man_opt.__file__).parent.parent.joinpath('assets/aggregated_data') mouse_data_filename = Path(data_path / 'Mouse_class_data.csv') mouse_datatype_filename = Path(data_path / 'Mouse_class_datatype.csv') mouse_data_df = man_utils.read_csv_with_dtype(mouse_data_filename, mouse_datatype_filename) cell_list = [ "327962063", "473564515", "478793814", "481001895", "483101699", "484635029", "485058595", "486560376", "584682764" ] cell_type_df = mouse_data_df.loc[(mouse_data_df.hof_index == 0) & (mouse_data_df.Cell_id.isin(cell_list)), ["Cell_id", "dendrite_type"]].reset_index( drop=True) original_model_path = "/allen/aibs/mat/ateam_shared/Mouse_Model_Fit_Metrics" model_refit_path = "/allen/programs/celltypes/workgroups/humancolumn_ephysmodeling/"\ "anin/Optimizations_HPC/Mouse_Benchmark" # %% Load Models
return diff_ephys_df # %% Data paths data_path = os.path.join(os.path.dirname(man_opt.__file__), os.pardir, 'assets', 'aggregated_data') mouse_data_filename = os.path.join(data_path, 'Mouse_class_data.csv') mouse_datatype_filename = os.path.join(data_path, 'Mouse_class_datatype.csv') broad_subclass_colors_filename = os.path.join( data_path, 'broad_subclass_colors.pkl') sdk_data_filename = os.path.join(data_path, 'sdk.csv') sdk_datatype_filename = os.path.join(data_path, 'sdk_datatype.csv') me_ttype_map_path = os.path.join(data_path, 'me_ttype.pkl') mouse_data = man_utils.read_csv_with_dtype(mouse_data_filename, mouse_datatype_filename) mouse_data = man_utils.add_transcriptomic_subclass( mouse_data, me_ttype_map_path) broad_subclass_color_dict = utility.load_pickle(broad_subclass_colors_filename) transcriptomic_subclass = mouse_data.loc[mouse_data.hof_index == 0, ['Cell_id', 'ttype']] sdk_data = man_utils.read_csv_with_dtype(sdk_data_filename, sdk_datatype_filename) inh_subclasses = ["Vip", "Sst", "Pvalb"] palette = {inh_subclass: broad_subclass_color_dict[inh_subclass] for inh_subclass in inh_subclasses} sdk_data = pd.merge(sdk_data, transcriptomic_subclass, on='Cell_id', how='left') sdk_data = sdk_data.rename(columns={'ef__threshold_i_long_square': 'rheobase', 'ef__f_i_curve_slope': 'fi_slope'}) sdk_data = sdk_data.loc[sdk_data.ttype.isin(inh_subclasses), ['Cell_id', 'ttype', 'rheobase', 'fi_slope']]
train_ephys_max_amp_fname = os.path.join(data_path, 'train_ephys_max_amp.csv') train_ephys_max_amp_dtype_fname = os.path.join( data_path, 'train_ephys_max_amp_dtype.csv') train_ephys_max_amp_fields_fname = os.path.join( data_path, 'train_ephys_max_amp_fields.json') cre_coloring_filename = os.path.join(data_path, 'cre_color_tasic16.pkl') bcre_coloring_filename = os.path.join(data_path, 'bcre_color_tasic16.pkl') cre_ttype_filename = os.path.join(data_path, 'cre_ttype_map.pkl') filtered_me_inh_cells_filename = os.path.join( data_path, 'filtered_me_inh_cells.pkl') filtered_me_exc_cells_filename = os.path.join( data_path, 'filtered_me_exc_cells.pkl') mouse_data_df = man_utils.read_csv_with_dtype( mouse_data_filename, mouse_datatype_filename) morph_data = man_utils.read_csv_with_dtype( morph_data_filename, morph_datatype_filename) # morph_data = morph_data.loc[:,[morph_feature for morph_feature in morph_data.columns # if not any(sec in morph_feature for sec in['apical','axon'])]] morph_fields = man_utils.get_data_fields(morph_data) ephys_data = man_utils.read_csv_with_dtype(train_ephys_max_amp_fname, train_ephys_max_amp_dtype_fname) ephys_fields = utility.load_json(train_ephys_max_amp_fields_fname) hof_param_data = man_utils.read_csv_with_dtype( param_data_filename, param_datatype_filename) cre_color_dict = utility.load_pickle(cre_coloring_filename) bcre_color_dict = utility.load_pickle(bcre_coloring_filename)