Skip to content

Commit 7a2420e

Browse files
authored
Merge pull request #91 from AlexandrovLab/i77
I77
2 parents 4344db5 + 3f6fe01 commit 7a2420e

File tree

4 files changed

+71
-54
lines changed

4 files changed

+71
-54
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
dist: xenial
22
language: python
33

4-
vm:
5-
size: 2x-large
6-
74
python:
85
- '3.8'
96

SigProfilerAssignment/decompose_subroutines.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def signature_decomposition(signatures, mtype, directory, genome_build="GRCh37",
480480
def make_final_solution(processAvg, allgenomes, allsigids, layer_directory, m, index, allcolnames, process_std_error = "none", signature_stabilities = " ", \
481481
signature_total_mutations= " ", signature_stats = "none", cosmic_sigs=False, attribution= 0, denovo_exposureAvg = "none", add_penalty=0.05, \
482482
remove_penalty=0.01, initial_remove_penalty=0.05, de_novo_fit_penalty=0.02, background_sigs=0, genome_build="GRCh37", sequence="genome", export_probabilities=True, export_probabilities_per_mutation=False, \
483-
refit_denovo_signatures=True, collapse_to_SBS96=True, connected_sigs=True, pcawg_rule=False, verbose=False,make_plots = True, samples='./', input_type='matrix', denovo_refit_option=True):
483+
refit_denovo_signatures=True, collapse_to_SBS96=True, connected_sigs=True, pcawg_rule=False, verbose=False,make_plots = True, samples='./', input_type='matrix', denovo_refit_option=True, exome=False):
484484

485485
if processAvg.shape[0]==allgenomes.shape[0] and processAvg.shape[0] != 96:
486486
collapse_to_SBS96=False
@@ -794,7 +794,7 @@ def make_final_solution(processAvg, allgenomes, allsigids, layer_directory, m, i
794794
if export_probabilities==True:
795795
if input_type=='vcf':
796796
if m=='96' or m=='78' or m=='83':
797-
probability_per_mutation, samples_prob_per_mut = probabilities_per_mutation(probability, samples, m)
797+
probability_per_mutation, samples_prob_per_mut = probabilities_per_mutation(probability, samples, m, exome)
798798

799799
if denovo_refit_option==True:
800800
if refit_denovo_signatures==True:
@@ -941,7 +941,7 @@ def probabilities(W, H, index, allsigids, allcolnames):
941941

942942

943943
################################################### Generation of probabilities for each processes given to A mutation ############################################
944-
def probabilities_per_mutation(probability_matrix, samples_path, m):
944+
def probabilities_per_mutation(probability_matrix, samples_path, m, exome=False):
945945
#
946946
probability_matrix=probability_matrix.reset_index()
947947
#
@@ -963,11 +963,15 @@ def probabilities_per_mutation(probability_matrix, samples_path, m):
963963
#
964964
all_mutations = pd.DataFrame()
965965
for file in seqinfo_files:
966-
try:
967-
new = pd.read_csv(seqinfo_path + file, sep='\t',header=None)
968-
all_mutations = pd.concat([all_mutations, new])
969-
except (pd.errors.EmptyDataError):
970-
pass
966+
if 'exome' in file:
967+
exome_df = pd.read_csv(seqinfo_path + file, sep='\t',header=None)
968+
else:
969+
try:
970+
new = pd.read_csv(seqinfo_path + file, sep='\t',header=None)
971+
all_mutations = pd.concat([all_mutations, new])
972+
except (pd.errors.EmptyDataError):
973+
pass
974+
971975
all_mutations[3] = all_mutations[3].str[interval_low:interval_high]
972976
if m=='96' or m=='78':
973977
del all_mutations[4]
@@ -977,6 +981,14 @@ def probabilities_per_mutation(probability_matrix, samples_path, m):
977981
del all_mutations[4]
978982

979983
all_mutations.columns = ['Sample Names', 'Chr', 'Pos', 'MutationType']
984+
if exome==True:
985+
del exome_df[2]
986+
del exome_df[3]
987+
del exome_df[4]
988+
exome_df.columns = ['Chr', 'Pos']
989+
exome_df['Chr'] = [str(x) for x in (exome_df['Chr']).to_list()]
990+
all_mutations['Chr'] = [str(x) for x in (all_mutations['Chr']).to_list()]
991+
all_mutations = pd.merge(all_mutations, exome_df)
980992
#
981993
all_samples_mutations = [y for x, y in all_mutations.groupby('Sample Names')]
982994
#

SigProfilerAssignment/decomposition.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def spa_analyze(samples, output, input_type='matrix', context_type="96", signatu
412412
add_penalty=nnls_add_penalty, remove_penalty=nnls_remove_penalty,
413413
initial_remove_penalty=init_rem_denovo,connected_sigs=connected_sigs,refit_denovo_signatures=False,
414414
make_plots=make_plots,export_probabilities=export_probabilities, export_probabilities_per_mutation=export_probabilities_per_mutation,
415-
samples=samples, input_type=input_type, denovo_refit_option=denovo_refit_option)
415+
samples=samples, input_type=input_type, denovo_refit_option=denovo_refit_option, exome=exome)
416416

417417
else:
418418
signature_stabilities=devopts['signature_stabilities']
@@ -426,7 +426,7 @@ def spa_analyze(samples, output, input_type='matrix', context_type="96", signatu
426426
background_sigs=background_sigs, verbose=verbose, genome_build=genome_build, signature_total_mutations = signature_total_mutations,
427427
add_penalty=nnls_add_penalty, remove_penalty=nnls_remove_penalty, process_std_error = processSTE, signature_stabilities = signature_stabilities,
428428
initial_remove_penalty=init_rem_denovo,connected_sigs=connected_sigs,refit_denovo_signatures=True,export_probabilities=export_probabilities,
429-
export_probabilities_per_mutation=export_probabilities_per_mutation, samples=samples, input_type=input_type, denovo_refit_option=denovo_refit_option)
429+
export_probabilities_per_mutation=export_probabilities_per_mutation, samples=samples, input_type=input_type, denovo_refit_option=denovo_refit_option, exome=exome)
430430

431431
if make_metadata:
432432
with open(os.path.join(output,"JOB_METADATA_SPA.txt"),"a") as sysdata:
@@ -541,7 +541,7 @@ def spa_analyze(samples, output, input_type='matrix', context_type="96", signatu
541541
make_plots=make_plots,
542542
export_probabilities=export_probabilities,
543543
export_probabilities_per_mutation=export_probabilities_per_mutation,
544-
samples=samples, input_type=input_type, denovo_refit_option=denovo_refit_option)
544+
samples=samples, input_type=input_type, denovo_refit_option=denovo_refit_option, exome=exome)
545545

546546
if make_metadata:
547547
with open(os.path.join(output,"JOB_METADATA_SPA.txt"),"a") as sysdata:
@@ -659,7 +659,7 @@ def spa_analyze(samples, output, input_type='matrix', context_type="96", signatu
659659
make_plots =make_plots,
660660
export_probabilities=export_probabilities,
661661
export_probabilities_per_mutation=export_probabilities_per_mutation,
662-
samples=samples, input_type=input_type, denovo_refit_option=denovo_refit_option)
662+
samples=samples, input_type=input_type, denovo_refit_option=denovo_refit_option, exome=exome)
663663
if make_metadata:
664664
with open(os.path.join(output,"JOB_METADATA_SPA.txt"),"a") as sysdata:
665665
current_time_end = datetime.datetime.now()

setup.py

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,65 @@
22
import shutil
33
import os
44

5-
#remove the dist folder first if exists
5+
# remove the dist folder first if exists
66
if os.path.exists("dist"):
77
shutil.rmtree("dist")
88

9-
VERSION = '0.0.30'
9+
VERSION = "0.0.31"
1010

1111

12-
def write_version_py(filename='SigProfilerAssignment/version.py'):
12+
def write_version_py(filename="SigProfilerAssignment/version.py"):
1313
# Copied from numpy setup.py
1414
cnt = """
1515
# THIS FILE IS GENERATED FROM SigProfilerAssignment SETUP.PY
1616
short_version = '%(version)s'
1717
version = '%(version)s'
18-
Update = 'v0.0.30: Sample reconstruction plot fix and pandas version fix.'
18+
Update = 'v0.0.31: Resolve issue with export probability per mutation for exome data'
1919
2020
2121
"""
22-
fh = open(filename, 'w')
23-
fh.write(cnt % {'version': VERSION,})
22+
fh = open(filename, "w")
23+
fh.write(
24+
cnt
25+
% {
26+
"version": VERSION,
27+
}
28+
)
2429
fh.close()
2530

26-
with open('README.md') as f:
27-
long_description = f.read()
28-
29-
requirements=[
30-
'scipy>=1.6.3',
31-
'numpy>=1.21.2',
32-
'pandas>=1.2.4,<2.0.0',
33-
'SigProfilerMatrixGenerator>=1.2.14',
34-
'sigProfilerPlotting>=1.3.11',
35-
'statsmodels>=0.9.0',
36-
'scikit-learn>=0.24.2',
37-
'psutil>=5.6.1',
38-
'reportlab>=3.5.42',
39-
'PyPDF2>=3.0.0',
40-
'alive_progress>=2.4.1',
41-
'pdf2image>=1.16.0',
42-
'PyMuPDF>=1.21.0'
43-
]
44-
45-
write_version_py()
46-
setup(name='SigProfilerAssignment',
47-
version=VERSION,
48-
description='Mutational signatures attribution and decomposition tool',
49-
long_description=long_description,
50-
long_description_content_type='text/markdown', # This is important!
51-
url="https://github.com/AlexandrovLab/SigProfilerAssignment.git",
52-
author='Raviteja Vangara',
53-
author_email='[email protected]',
54-
license='UCSD',
55-
packages=['SigProfilerAssignment'],
56-
install_requires=requirements,
57-
include_package_data=True,
58-
zip_safe=False)
31+
32+
with open("README.md") as f:
33+
long_description = f.read()
34+
35+
requirements = [
36+
"scipy>=1.6.3",
37+
"numpy>=1.21.2",
38+
"pandas>=1.2.4,<2.0.0",
39+
"SigProfilerMatrixGenerator>=1.2.14",
40+
"sigProfilerPlotting>=1.3.11",
41+
"statsmodels>=0.9.0",
42+
"scikit-learn>=0.24.2",
43+
"psutil>=5.6.1",
44+
"reportlab>=3.5.42",
45+
"PyPDF2>=3.0.0",
46+
"alive_progress>=2.4.1",
47+
"pdf2image>=1.16.0",
48+
"PyMuPDF>=1.21.0",
49+
]
50+
51+
write_version_py()
52+
setup(
53+
name="SigProfilerAssignment",
54+
version=VERSION,
55+
description="Mutational signatures attribution and decomposition tool",
56+
long_description=long_description,
57+
long_description_content_type="text/markdown", # This is important!
58+
url="https://github.com/AlexandrovLab/SigProfilerAssignment.git",
59+
author="Raviteja Vangara",
60+
author_email="[email protected]",
61+
license="UCSD",
62+
packages=["SigProfilerAssignment"],
63+
install_requires=requirements,
64+
include_package_data=True,
65+
zip_safe=False,
66+
)

0 commit comments

Comments
 (0)