Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion oncodriveclustl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,24 @@ def main(input_file,
logger.info('Validated elements with mutations: {}'.format(elem))
logger.info('Total substitution mutations: {}'.format(mut))
if not element_mutations_cutoff:
raise excep.UserInputError('No element found with enough mutations to perform analysis')
logger.warning('No element found with enough mutations to perform analysis. Writing empty results.')
sorted_list_elements = postp.write_element_results(
genome=genome,
results=({}, {}),
directory=output_directory,
file=elements_output_file,
is_gzip=gzip
)
postp.write_cluster_results(
genome=genome,
results=({}, {}),
directory=output_directory,
file=clusters_output_file,
sorter=sorted_list_elements,
is_gzip=gzip
)
logger.info('Finished')
return

# Signature
file_prefix = input_file.split('/')[-1].split('.')[0]
Expand Down
43 changes: 26 additions & 17 deletions oncodriveclustl/utils/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,31 @@ def write_element_results(genome, results, directory, file, is_gzip):
'P_ANALYTICAL',
'P_TOPCLUSTER',
'CGC']
column_order = ['SYMBOL',
'ENSID',
'CGC',
'CHROMOSOME',
'STRAND',
'LENGTH',
'TOTAL_MUT',
'CLUSTERED_MUT',
'CLUSTERS',
'SIM_CLUSTERS',
'SCORE',
'P_EMPIRICAL',
'Q_EMPIRICAL',
'P_ANALYTICAL',
'Q_ANALYTICAL',
'P_TOPCLUSTER',
'Q_TOPCLUSTER']

if not elements_results:
df = pd.DataFrame(columns=column_order)
if is_gzip is True:
df.to_csv(path_or_buf=file, sep='\t', na_rep='', index=False, compression='gzip')
else:
df.to_csv(path_or_buf=file, sep='\t', na_rep='', index=False)
return []

df = pd.DataFrame(columns=header, index=[i for i in range(len(elements_results))])

Expand Down Expand Up @@ -119,23 +144,7 @@ def write_element_results(genome, results, directory, file, is_gzip):
df = pd.concat([df_nonempty, df_empty])

# Reorder columns
df = df[['SYMBOL',
'ENSID',
'CGC',
'CHROMOSOME',
'STRAND',
'LENGTH',
'TOTAL_MUT',
'CLUSTERED_MUT',
'CLUSTERS',
'SIM_CLUSTERS',
'SCORE',
'P_EMPIRICAL',
'Q_EMPIRICAL',
'P_ANALYTICAL',
'Q_ANALYTICAL',
'P_TOPCLUSTER',
'Q_TOPCLUSTER']]
df = df[column_order]

# Create a sorted list of elements to order the clusters file
df.sort_values(by=['Q_ANALYTICAL', 'P_ANALYTICAL', 'SCORE', 'CGC'],
Expand Down