Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'''
Filter a network's rows or columns based on the sum across rows or columns.
'''
if axis is None:
axis = inst_rc
print('warning inst_rc argument will be deprecated, please use axis')
if inst_rc is None:
print('please provide axis argument')
inst_df = self.dat_to_df()
if axis == 'row':
inst_df = run_filter.df_filter_row_sum(inst_df, threshold, take_abs)
elif axis == 'col':
inst_df = run_filter.df_filter_col_sum(inst_df, threshold, take_abs)
self.df_to_dat(inst_df)
check_keep_num = -1
if check_keep_num < len(rows_sorted):
tmp_net = deepcopy(Network())
if inst_keep != 'all':
keep_rows = rows_sorted[0:inst_keep]
tmp_df['mat'] = tmp_df['mat'].loc[keep_rows]
if 'mat_orig' in tmp_df:
tmp_df['mat_orig'] = tmp_df['mat_orig'].loc[keep_rows]
tmp_df = run_filter.df_filter_col_sum(tmp_df, 0.001)
tmp_net.df_to_dat(tmp_df)
else:
tmp_net.df_to_dat(tmp_df)
try:
try:
calc_clust.cluster_row_and_col(tmp_net, dist_type, run_clustering=True)
except:
calc_clust.cluster_row_and_col(tmp_net, dist_type, run_clustering=False)
# add view
inst_view = {}
inst_view['N_row_' + rank_type] = inst_keep
inst_view['dist'] = 'cos'
inst_view['nodes'] = {}