Skip to content

Commit 02daf6a

Browse files
committed
SPT version 1.0.73 Eliminated Warnings
1 parent 03cd4ac commit 02daf6a

File tree

9 files changed

+48
-33
lines changed

9 files changed

+48
-33
lines changed

.idea/SigProfilerTopography.iml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include SigProfilerTopography/source/transcriptionstrandbias/*
88
include SigProfilerTopography/source/processivity/*
99
include SigProfilerTopography/source/plotting/*
1010
include SigProfilerTopography/source/annotation/*
11+
include SigProfilerTopography/source/annotatedregion/*
1112
include SigProfilerTopography/lib/ucscgenome/hg19ChromSizesDict.txt
1213
include SigProfilerTopography/lib/ucscgenome/hg38ChromSizesDict.txt
1314
include SigProfilerTopography/lib/ucscgenome/mm9ChromSizesDict.txt

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[![License](https://img.shields.io/badge/License-BSD\%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)
22

3+
![schematic](SigProfilerTopography.png)
4+
35
# SigProfilerTopography
46
SigProfilerTopography provides topography analyses for mutations such as
57

SigProfilerTopography/__init__.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
from SigProfilerTopography.source.commons import *
2-
from SigProfilerTopography.source.occupancy import *
3-
from SigProfilerTopography.source.replicationtime import *
4-
from SigProfilerTopography.source.replicationstrandbias import *
5-
from SigProfilerTopography.source.transcriptionstrandbias import *
6-
from SigProfilerTopography.source.processivity import *
7-
from SigProfilerTopography.source.plotting import *
1+
from .source import *
2+
from .version import short_version as __version__

SigProfilerTopography/source/commons/TopographyCommons.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -655,10 +655,15 @@ def calculate_pvalue_teststatistics(observed_value,
655655
expected_values,
656656
alternative = 'two-sided'):
657657

658-
zstat, pvalue = ztest(expected_values, [observed_value], alternative=alternative) # pvalue 0.0115612696237375
658+
try:
659+
zstat, pvalue = ztest(expected_values, [observed_value], alternative=alternative) # pvalue 0.0115612696237375
660+
except RuntimeWarning as w:
661+
zstat = None
662+
pvalue = None
663+
# print('expected_values:', expected_values, 'observed_value:', observed_value, 'alternative:', alternative, 'w:', w)
664+
659665
# zstat, pvalue = ztest(expectedValues, value=observedValue) results in very small p-values therefore we are not calling in this way. # (-25.37854961568692, 4.351195335930552e-142)
660666
# stats.ttest_1samp(expected_values, observed_value) # Ttest_1sampResult(statistic=-25.378549615686918, pvalue=3.99359102646761e-45)
661-
662667
return zstat, pvalue
663668

664669
# sheet name must be less than 31 characters

SigProfilerTopography/source/plotting/OccupancyAverageSignalFigures.py

+28-19
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,8 @@ def compute_fold_change_with_combined_p_values_plot_heatmaps(combine_p_values_me
19191919
combine_p_values_method,
19201920
num_of_real_data_avg_overlap,
19211921
nucleosome_file,
1922-
epigenomics_dna_elements)
1922+
epigenomics_dna_elements,
1923+
log_file)
19231924

19241925
if plot_detailed_epigemomics_heatmaps:
19251926
# Plot heatmaps using step2 under epigenomics_occupancy/heatmaps/detailed
@@ -1942,7 +1943,8 @@ def compute_fold_change_with_combined_p_values_plot_heatmaps(combine_p_values_me
19421943
combine_p_values_method,
19431944
num_of_real_data_avg_overlap,
19441945
nucleosome_file,
1945-
epigenomics_dna_elements)
1946+
epigenomics_dna_elements,
1947+
log_file)
19461948

19471949
step3_sbs_signature2dna_element2avg_fold_change_dict, \
19481950
step3_dbs_signature2dna_element2avg_fold_change_dict, \
@@ -2104,16 +2106,16 @@ def calculate_fold_change_real_over_sim(center,
21042106
epigenomics_biosamples,
21052107
occupancy_type):
21062108

2107-
avg_real_signal=None
2108-
avg_sim_signal=None
2109+
avg_real_signal = None
2110+
avg_sim_signal = None
21092111
fold_change = None
2110-
min_sim_signal=None
2111-
max_sim_signal=None
2112-
pvalue=None
2113-
num_of_sims=None
2114-
num_of_sims_with_not_nan_avgs=None
2115-
real_data_avg_count=None
2116-
sim_avg_count=None
2112+
min_sim_signal = None
2113+
max_sim_signal = None
2114+
pvalue = None
2115+
num_of_sims = None
2116+
num_of_sims_with_not_nan_avgs = None
2117+
real_data_avg_count = None
2118+
sim_avg_count = None
21172119
simulationsHorizontalMeans = None
21182120

21192121
biosample=None
@@ -2138,7 +2140,7 @@ def calculate_fold_change_real_over_sim(center,
21382140
else:
21392141
real_data_avg_signal_array = readData(None, signature, SIGNATUREBASED, output_dir, jobname, occupancy_type, dna_element_to_be_read,AVERAGE_SIGNAL_ARRAY)
21402142

2141-
if real_data_avg_signal_array is not None:
2143+
if real_data_avg_signal_array is not None and (len(real_data_avg_signal_array) > 0) and (not np.isnan(real_data_avg_signal_array[start:end]).all()):
21422144
#If there is nan in the list np.mean returns nan.
21432145
avg_real_signal = np.nanmean(real_data_avg_signal_array[start:end])
21442146

@@ -2148,7 +2150,7 @@ def calculate_fold_change_real_over_sim(center,
21482150
else:
21492151
real_data_accumulated_count_array = readData(None, signature, SIGNATUREBASED, output_dir, jobname, occupancy_type, dna_element_to_be_read,ACCUMULATED_COUNT_ARRAY)
21502152

2151-
if real_data_accumulated_count_array is not None:
2153+
if real_data_accumulated_count_array is not None and (len(real_data_accumulated_count_array) > 0) and (not np.isnan(real_data_accumulated_count_array[start:end]).all()):
21522154
#If there is nan in the list np.mean returns nan.
21532155
real_data_avg_count = np.nanmean(real_data_accumulated_count_array[start:end])
21542156

@@ -2223,7 +2225,9 @@ def calculate_fold_change_real_over_sim(center,
22232225

22242226

22252227
if (avg_real_signal is not None) and (avg_sim_signal is not None):
2226-
fold_change = avg_real_signal / avg_sim_signal
2228+
2229+
if avg_sim_signal > 0:
2230+
fold_change = avg_real_signal / avg_sim_signal
22272231

22282232
if (simulationsHorizontalMeans is not None):
22292233
zstat, pvalue = calculate_pvalue_teststatistics(avg_real_signal, simulationsHorizontalMeans)
@@ -2345,7 +2349,6 @@ def step1_calculate_p_value(fold_change_window_size,
23452349
signature2Biosample2DNAElement2PValueDict = {}
23462350
plusorMinus = fold_change_window_size//2
23472351

2348-
23492352
def update_dictionary(complete_list):
23502353
# complete_list:[jobname, signature, biosample, dna_element, avg_real_signal, avg_sim_signal, fold_change, min_sim_signal,
23512354
# max_sim_signal, pvalue, num_of_sims, num_of_sims_with_not_nan_avgs, real_data_avg_count, sim_avg_count,
@@ -2415,7 +2418,8 @@ def step2_combine_p_value(signature2Biosample2DNAElement2PValueDict,
24152418
combine_p_values_method,
24162419
num_of_real_data_avg_overlap,
24172420
nucleosome_file,
2418-
epigenomics_dna_elements):
2421+
epigenomics_dna_elements,
2422+
log_file):
24192423

24202424
# Fill and return this dictionary
24212425
signature2biosample2pooled_dna_element2combined_p_value_list_dict = {}
@@ -2498,7 +2502,9 @@ def step2_combine_p_value(signature2Biosample2DNAElement2PValueDict,
24982502
try:
24992503
test_statistic, combined_p_value = scipy.stats.combine_pvalues(p_values_array, method=combine_p_values_method, weights=None)
25002504
except FloatingPointError:
2501-
print('signature:%s dna_element:%s fold_change_list:%s p_value_list:%s' %(signature,dna_element,fold_change_list,p_value_list))
2505+
log_out = open(log_file, 'a')
2506+
print('signature:%s dna_element:%s fold_change_list:%s p_value_list:%s' %(signature, dna_element, fold_change_list, p_value_list), file=log_out)
2507+
log_out.close()
25022508
if len(p_value_list)>0:
25032509
combined_p_value=p_value_list[0]
25042510

@@ -2537,7 +2543,8 @@ def step3_combine_p_value(signature2Biosample2DNAElement2PValueDict,
25372543
combine_p_values_method,
25382544
num_of_real_data_avg_overlap,
25392545
nucleosome_file,
2540-
epigenomics_dna_elements):
2546+
epigenomics_dna_elements,
2547+
log_file):
25412548

25422549
# Fill and return this dictionary
25432550
signature2dna_element2combined_p_value_list_dict = {}
@@ -2613,7 +2620,9 @@ def step3_combine_p_value(signature2Biosample2DNAElement2PValueDict,
26132620
try:
26142621
test_statistic, combined_p_value = scipy.stats.combine_pvalues(p_values_array, method=combine_p_values_method, weights=None)
26152622
except FloatingPointError:
2616-
print('signature:%s dna_element:%s fold_change_list:%s p_value_list:%s' %(signature,dna_element,fold_change_list,p_value_list))
2623+
log_out = open(log_file, 'a')
2624+
print('signature:%s dna_element:%s fold_change_list:%s p_value_list:%s' %(signature,dna_element,fold_change_list,p_value_list), file=log_out)
2625+
log_out.close()
26172626
if len(p_value_list)>0:
26182627
combined_p_value=p_value_list[0]
26192628

SigProfilerTopography/source/plotting/ProcessivityFigures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def plotRelationshipBetweenSignaturesandProcessiveGroupLengthsUsingDataframes(ou
233233
# Please note
234234
# If pvalue is np.nan e.g.: due to a few expected values like only one [1]
235235
# Then there must be cases when you may want to manually set minus_log10_qvalue to np.inf
236-
if np.isnan(pvalue):
236+
if (pvalue is not None) and np.isnan(pvalue):
237237
signature_processive_group_length_properties_df.loc[
238238
((signature_processive_group_length_properties_df['signature'] == signature) &
239239
(signature_processive_group_length_properties_df['processive_group_length'] == processive_group_length)), 'minus_log10_qvalue'] = np.inf

SigProfilerTopography/version.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
# THIS FILE IS GENERATED FROM SIGPROFILERTOPOGRAPHY SETUP.PY
3-
short_version = '1.0.71'
4-
version = '1.0.71'
3+
short_version = '1.0.73'
4+
version = '1.0.73'
55

66

setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def readme():
1010
with open('README.rst') as f:
1111
return(f.read())
1212

13-
VERSION = '1.0.71'
13+
VERSION = '1.0.73'
1414

1515
def write_version_py(filename='SigProfilerTopography/version.py'):
1616
# Copied from numpy setup.py
@@ -37,13 +37,15 @@ def write_version_py(filename='SigProfilerTopography/version.py'):
3737
install_requires=[
3838
"SigProfilerMatrixGenerator>=1.1.27",
3939
"SigProfilerSimulator>=1.1.2",
40+
"SigProfilerAssignment>=0.1.0",
4041
"XlsxWriter>=1.3.7",
4142
"pandas>=1.1.5",
4243
"numpy>=1.20.1",
4344
"matplotlib>=2.2.2",
4445
"scipy>=1.1.0",
4546
"statsmodels>=0.9.0",
4647
"fastrand>=1.2",
47-
"psutil>=5.6.3"],
48+
"psutil>=5.6.3",
49+
"intervaltree>=3.1.0"],
4850
include_package_data=True,
4951
zip_safe=False)

0 commit comments

Comments
 (0)