def make_viz_from_df(df, filename): from clustergrammer import Network net = Network() net.df_to_dat(df) net.swap_nan_for_zero() # zscore first to get the columns distributions to be similar net.normalize(axis='col', norm_type='zscore', keep_orig=True) # filter the rows to keep the perts with the largest normalizes values net.filter_N_top('row', 2000) num_coluns = net.dat['mat'].shape[1] if num_coluns < 50: # views = ['N_row_sum', 'N_row_var'] views = ['N_row_sum'] net.make_clust(dist_type='cos', views=views) filename = 'json/' + filename.split('/')[1].replace('.gct', '') + '.json' net.write_json_to_file('viz', filename)
def make_viz_json(inst_df, name): from clustergrammer import Network net = Network() filename = 'json/'+name load_df = {} load_df['mat'] = inst_df net.df_to_dat(load_df) net.swap_nan_for_zero() net.make_clust(views=[]) net.write_json_to_file('viz', filename, 'no-indent')
def process_GCT_and_export_tsv(): from clustergrammer import Network filename = 'gcts/LDS-1003.gct' print('exporting processed GCT as tsv file') df = load_file(filename) net = Network() net.df_to_dat(df) net.swap_nan_for_zero() # zscore first to get the columns distributions to be similar net.normalize(axis='col', norm_type='zscore', keep_orig=True) # filter the rows to keep the perts with the largest normalizes values net.filter_N_top('row', 200) net.write_matrix_to_tsv('txt/example_gct_export.txt')
def process_GCT_and_export_tsv(): from clustergrammer import Network filename = 'gcts/LDS-1003.gct' print('exporting processed GCT as tsv file') df = load_file(filename) net = Network() net.df_to_dat(df) net.swap_nan_for_zero() # zscore first to get the columns distributions to be similar net.normalize(axis='col', norm_type='zscore', keep_orig=True) # filter the rows to keep the perts with the largest normalizes values net.filter_N_top('row', 200) net.write_matrix_to_tsv('txt/example_gct_export.txt')
def make_viz_from_df(df, filename): from clustergrammer import Network net = Network() net.df_to_dat(df) net.swap_nan_for_zero() # zscore first to get the columns distributions to be similar net.normalize(axis='col', norm_type='zscore', keep_orig=True) # filter the rows to keep the perts with the largest normalizes values net.filter_N_top('row', 2000) num_coluns = net.dat['mat'].shape[1] if num_coluns < 50: # views = ['N_row_sum', 'N_row_var'] views = ['N_row_sum'] net.make_clust(dist_type='cos', views=views) filename = 'json/' + filename.split('/')[1].replace('.gct','') + '.json' net.write_json_to_file('viz', filename)
print(new_rows) for inst_row in new_rows: inst_row.append('something') print('\n\n\n') print(new_rows) new_rows = [tuple(x) for x in new_rows] print('\n\n\n') print(new_rows) df['mat'].index = new_rows net.df_to_dat(df) # for inst_row in all_rows: # inst_row = list(inst_row) # inst_row.append('something') # inst_row = tuple(inst_row) # print(all_rows) # cat_list = [tuple(x) for x in cat_list] # print(net.dat['node_info']) # net.dat['nodes']['row'] = []