Skip to content

Commit a066212

Browse files
authored
Merge pull request #48 from AlexandrovLab/plots1
import decomp plots from assignment, update MANIFEST, fix column name…
2 parents c73bb9f + ca36143 commit a066212

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+357
-154128
lines changed

.gitignore

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ coverage.xml
5151
.hypothesis/
5252
.pytest_cache/
5353
cover/
54-
test/
54+
SigProfilerAssignment/data/tests/vcf_input/input/
55+
SigProfilerAssignment/data/tests/vcf_input/logs/
56+
SigProfilerAssignment/data/tests/vcf_input/output/
57+
output_vcf_example/
58+
output_txt_example/
59+
60+
5561

5662
# Translations
5763
*.mo
@@ -84,24 +90,6 @@ target/
8490
profile_default/
8591
ipython_config.py
8692

87-
# pyenv
88-
# For a library or package, you might want to ignore these files since the code is
89-
# intended to run in multiple environments; otherwise, check them in:
90-
# .python-version
91-
92-
# pipenv
93-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
95-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
96-
# install all needed dependencies.
97-
#Pipfile.lock
98-
99-
# poetry
100-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101-
# This is especially recommended for binary packages to ensure reproducibility, and is more
102-
# commonly ignored for libraries.
103-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104-
#poetry.lock
10593

10694
# pdm
10795
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
@@ -154,9 +142,3 @@ dmypy.json
154142
# Cython debug symbols
155143
cython_debug/
156144

157-
# PyCharm
158-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160-
# and can be added to the global gitignore or merged into this file. For a more nuclear
161-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162-
#.idea/

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ language: python
44
python:
55
- '3.8'
66

7+
before_install:
8+
if ! [ -f ./src/GRCh37.tar.gz ]; then
9+
wget ftp://alexandrovlab-ftp.ucsd.edu/pub/tools/SigProfilerMatrixGenerator/GRCh37.tar.gz -P ./src/;
10+
fi
11+
712
install:
813
- pip install .
914

15+
cache:
16+
directories:
17+
- $TRAVIS_BUILD_DIR/src/
18+
19+
before_script:
20+
- python3 install_genome.py $TRAVIS_BUILD_DIR/src/
21+
1022
script: python3 test.py

MANIFEST.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ include SigProfilerAssignment/data/Reference_Signatures/mm9/*
77
include SigProfilerAssignment/data/Reference_Signatures/mm10/*
88
include SigProfilerAssignment/data/Reference_Signatures/rn6/*
99
include SigProfilerAssignment/DecompositionPlots/reference_files/Fonts/*
10-
include SigProfilerAssignment/DecompositionPlots/reference_files/*
10+
include SigProfilerAssignment/DecompositionPlots/reference_files/*
11+
include SigProfilerAssignment/DecompositionPlots/*
12+
include SigProfilerAssignment/data/tests/vcf_input/*
13+
include SigProfilerAssignment/data/tests/txt_input/*
14+
include SigProfilerAssignment/data/tests/cnv_input/*

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,17 @@ Analyze.cosmic_fit( samples,
180180
#import modules
181181
import SigProfilerAssignment as spa
182182
from SigProfilerAssignment import Analyzer as Analyze
183+
import os
183184

184185
#set directories and paths to signatures and samples
185-
dir_inp = spa.__path__[0]+'/data/Examples/'
186-
samples = spa.__path__[0]+'/data/vcftest/' #directory of vcf files
187-
output = "output_example/"
188-
signatures = dir_inp+"Results_scenario_8/SBS96/All_Solutions/SBS96_3_Signatures/Signatures/SBS96_S3_Signatures.txt"
189-
sigs = "COSMIC_v3_SBS_GRCh37_noSBS84-85.txt" #Custom Signature Database
186+
dir_inp = os.path.join(spa.__path__[0], '/data/Examples/')
187+
# directory of vcf files
188+
samples = os.path.join(spa.__path__[0], '/data/tests/vcf_input/')
189+
output = "output_example/"
190+
signatures = os.path.join(dir_inp, \
191+
"Results_scenario_8/SBS96/All_Solutions/SBS96_3_Signatures/Signatures/" \
192+
+ "SBS96_S3_Signatures.txt")
193+
sigs = "COSMIC_v3_SBS_GRCh37_noSBS84-85.txt" #Custom Signature Database
190194

191195
#Analysis of SP Assignment
192196
Analyze.cosmic_fit( samples,
@@ -212,11 +216,14 @@ Analyze.cosmic_fit( samples,
212216
#import modules
213217
import SigProfilerAssignment as spa
214218
from SigProfilerAssignment import Analyzer as Analyze
219+
import os
215220

216221
#set directories and paths to signatures and samples
217-
dir_inp = spa.__path__[0]+'/data/Examples/'
218-
samples = spa.__path__[0]+'/data/cnvtest/all.breast.ascat.summary.sample.tsv' # segmentation file
219-
output = "output_example/"
222+
dir_inp = os.path.join(spa.__path__[0], 'data/Examples/')
223+
# segmentation file
224+
samples = os.path.join(spa.__path__[0], \
225+
'/data/tests/cnv_input/all.breast.ascat.summary.sample.tsv')
226+
output = "output_example/"
220227

221228
#Analysis of SP Assignment
222229
Analyze.cosmic_fit( samples,

SigProfilerAssignment/DecompositionPlots/PlotDecomposition.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ def gen_reconstructed_png(denovo_name, basis_mtx, basis_names, weights, output_p
202202
elif mtype in ID_CONTEXTS:
203203
reconstruction_plot=sigPlt.plotID(reconstruction_mtx, output_path, "reconstruction_" + project, mtype, True)
204204
elif mtype in CNV_CONTEXTS:
205-
reconstruction_plot = pltCNV.plotCNV(reconstruction_mtx, output_path, "reconstruction_"+project, plot_type="pdf", \
206-
percentage=True, aggregate=False, read_from_file=False, write_to_file=False)
205+
reconstruction_plot = pltCNV.plotCNV(reconstruction_mtx, output_path, "reconstruction_"+project, plot_type="pdf", \
206+
percentage=True, aggregate=False, read_from_file=False, write_to_file=False)
207207
else:
208208
print("ERROR: mtype is " + mtype + " and is not yet supported.")
209209

@@ -323,14 +323,11 @@ def run_PlotDecomposition(denovo_mtx, denovo_name, basis_mtx, basis_names, \
323323
denovo_plots_dict,basis_plots_dict=gen_sub_plots(denovo_mtx, basis_mtx, output_path, project, mtype)
324324
reconstructed_mtx,reconstruction_plot_dict = gen_reconstructed_png(denovo_name, basis_mtx, basis_names, \
325325
weights, output_path, project, mtype)
326-
327326
present_sigs=np.array(basis_mtx[basis_names])
328327
reconstructed_mtx = np.dot(present_sigs,nonzero_exposures)
329-
330328
denovo_plots_dict = open_byte_to_img_dict(denovo_plots_dict)
331329
basis_plots_dict = open_byte_to_img_dict(basis_plots_dict)
332330
reconstruction_plot_dict = open_byte_to_img_dict(reconstruction_plot_dict)
333-
334331
statistics=calculate_similarities(denovo_mtx, denovo_name, reconstructed_mtx)
335332
byte_plot = gen_decomposition(denovo_name, basis_names, weights, output_path, project, \
336333
mtype, denovo_plots_dict, basis_plots_dict, reconstruction_plot_dict, \

SigProfilerAssignment/DecompositionPlots/PlotDecomposition_CNV48.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
from PIL import Image
1818
# imports for dashed line
1919
from reportlab.lib.colors import black
20-
paths = spa_path.__path__[0]
21-
# Page Formatting
22-
inch = 72
20+
PATHS = spa_path.__path__[0]
21+
2322
# USING LETTER PORTRAIT DIMENSIONS
2423
WIDTH_LETTER = 965
2524
HEIGHT_LETTER = 755
@@ -44,8 +43,8 @@
4443
TEXT_X_COORD = GRAPH_X_COORD + WIDTH_GRAPH - 50
4544
TEXT_Y_COORD = (HEIGHT_LETTER - HEIGHT_GAP) + 55.75
4645

47-
FONTS_DIR = os.path.join(paths+'decomposition_plots/reference_files/Fonts/')
48-
BRACKET_PATH=os.path.join(paths+"/decomposition_plots/reference_files/Accolade_fermante.png")
46+
FONTS_DIR = os.path.join(PATHS, "DecompositionPlots/reference_files/Fonts/")
47+
BRACKET_PATH=os.path.join(PATHS, "DecompositionPlots/reference_files/Accolade_fermante.png")
4948
reportlab.rl_config.TTFSearchPath.append(FONTS_DIR)
5049
pdfmetrics.registerFont(TTFont('Arial-Bold', 'Arial Bold.ttf'))
5150

@@ -217,8 +216,6 @@ def draw_statistics(c_draw, statistics, sig_version, custom_text):
217216
# num_bases - (Integer) The number of bases to be plotted.
218217
# c_draw - (Canvas) The canvas to draw the graph decomposition on.
219218
def draw_bracket(num_bases, c_draw):
220-
paths = cosmic.__path__[0]
221-
222219
num_plts = num_bases - 1
223220

224221
if(num_bases >= 5):

SigProfilerAssignment/DecompositionPlots/PlotDecomposition_DBS78.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
from PIL import Image
1818
# imports for dashed line
1919
from reportlab.lib.colors import black
20-
paths = spa_path.__path__[0]
20+
PATHS = spa_path.__path__[0]
2121
# Page Formatting
22-
inch = 72
22+
INCH = 72
2323
# USING LETTER LANDSCAPE DIMENSIONS
24-
WIDTH_LETTER = 11 * inch
25-
HEIGHT_LETTER = 8.5 * inch
24+
WIDTH_LETTER = 11 * INCH
25+
HEIGHT_LETTER = 8.5 * INCH
2626
MID_WIDTH_LETTER = 396
2727
MID_HEIGHT_LETTER = HEIGHT_LETTER/2
2828

@@ -41,8 +41,8 @@
4141
TEXT_X_COORD = GRAPH_X_COORD + WIDTH_GRAPH - 50
4242
TEXT_Y_COORD = (HEIGHT_LETTER - HEIGHT_GAP) + 63.75
4343

44-
FONTS_DIR = os.path.join(paths+'decomposition_plots/reference_files/Fonts/')
45-
BRACKET_PATH=os.path.join(paths+"/decomposition_plots/reference_files/Accolade_fermante.png")
44+
FONTS_DIR = os.path.join(PATHS, "DecompositionPlots/reference_files/Fonts/")
45+
BRACKET_PATH=os.path.join(PATHS, "DecompositionPlots/reference_files/Accolade_fermante.png")
4646
reportlab.rl_config.TTFSearchPath.append(FONTS_DIR)
4747
pdfmetrics.registerFont(TTFont('Arial-Bold', 'Arial Bold.ttf'))
4848

SigProfilerAssignment/DecompositionPlots/PlotDecomposition_ID83.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
from PIL import Image
1818
# imports for dashed line
1919
from reportlab.lib.colors import black
20-
paths = spa_path.__path__[0]
20+
PATHS = spa_path.__path__[0]
2121
# Page Formatting
22-
inch = 72
22+
INCH = 72
2323
# USING LETTER LANDSCAPE DIMENSIONS
24-
WIDTH_LETTER = 11 * inch
25-
HEIGHT_LETTER = 8.5 * inch
24+
WIDTH_LETTER = 11 * INCH
25+
HEIGHT_LETTER = 8.5 * INCH
2626
MID_WIDTH_LETTER = 396
2727
MID_HEIGHT_LETTER = HEIGHT_LETTER/2
2828

@@ -41,8 +41,8 @@
4141
TEXT_X_COORD = GRAPH_X_COORD + WIDTH_GRAPH - 50
4242
TEXT_Y_COORD = (HEIGHT_LETTER - HEIGHT_GAP) + 40.75
4343

44-
FONTS_DIR = os.path.join(paths+'decomposition_plots/reference_files/Fonts/')
45-
BRACKET_PATH=os.path.join(paths+"/decomposition_plots/reference_files/Accolade_fermante.png")
44+
FONTS_DIR = os.path.join(PATHS, "DecompositionPlots/reference_files/Fonts/")
45+
BRACKET_PATH=os.path.join(PATHS, "DecompositionPlots/reference_files/Accolade_fermante.png")
4646
reportlab.rl_config.TTFSearchPath.append(FONTS_DIR)
4747
pdfmetrics.registerFont(TTFont('Arial-Bold', 'Arial Bold.ttf'))
4848

SigProfilerAssignment/DecompositionPlots/PlotDecomposition_SBS1536.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
from PIL import Image
1818
# imports for dashed line
1919
from reportlab.lib.colors import black
20-
paths = spa_path.__path__[0]
20+
PATHS = spa_path.__path__[0]
2121
# Page Formatting
22-
inch = 72
22+
INCH = 72
2323
# USING LETTER LANDSCAPE DIMENSIONS
24-
WIDTH_LETTER = 11 * inch
25-
HEIGHT_LETTER = 8.5 * inch
24+
WIDTH_LETTER = 11 * INCH
25+
HEIGHT_LETTER = 8.5 * INCH
2626
MID_WIDTH_LETTER = 396
2727
MID_HEIGHT_LETTER = HEIGHT_LETTER/2
2828

@@ -41,8 +41,8 @@
4141
TEXT_X_COORD = GRAPH_X_COORD + WIDTH_GRAPH - 50
4242
TEXT_Y_COORD = (HEIGHT_LETTER - HEIGHT_GAP) + 63.75
4343

44-
FONTS_DIR = os.path.join(paths+'decomposition_plots/reference_files/Fonts/')
45-
BRACKET_PATH=os.path.join(paths+"/decomposition_plots/reference_files/Accolade_fermante.png")
44+
FONTS_DIR = os.path.join(PATHS, "DecompositionPlots/reference_files/Fonts/")
45+
BRACKET_PATH=os.path.join(PATHS, "DecompositionPlots/reference_files/Accolade_fermante.png")
4646
reportlab.rl_config.TTFSearchPath.append(FONTS_DIR)
4747
pdfmetrics.registerFont(TTFont('Arial-Bold', 'Arial Bold.ttf'))
4848

SigProfilerAssignment/DecompositionPlots/PlotDecomposition_SBS288.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
from PIL import Image
1818
# imports for dashed line
1919
from reportlab.lib.colors import black
20-
paths = spa_path.__path__[0]
20+
PATHS = spa_path.__path__[0]
2121
# Page Formatting
22-
inch = 72
22+
INCH = 72
2323
# USING LETTER LANDSCAPE DIMENSIONS
24-
WIDTH_LETTER = 11 * inch
25-
HEIGHT_LETTER = 8.5 * inch
24+
WIDTH_LETTER = 11 * INCH
25+
HEIGHT_LETTER = 8.5 * INCH
2626
MID_WIDTH_LETTER = 396
2727
MID_HEIGHT_LETTER = HEIGHT_LETTER/2
2828

@@ -41,8 +41,8 @@
4141
TEXT_X_COORD = GRAPH_X_COORD + WIDTH_GRAPH - 50
4242
TEXT_Y_COORD = (HEIGHT_LETTER - HEIGHT_GAP) + 63.75
4343

44-
FONTS_DIR = os.path.join(paths+'decomposition_plots/reference_files/Fonts/')
45-
BRACKET_PATH=os.path.join(paths+"/decomposition_plots/reference_files/Accolade_fermante.png")
44+
FONTS_DIR = os.path.join(PATHS, "DecompositionPlots/reference_files/Fonts/")
45+
BRACKET_PATH=os.path.join(PATHS, "DecompositionPlots/reference_files/Accolade_fermante.png")
4646
reportlab.rl_config.TTFSearchPath.append(FONTS_DIR)
4747
pdfmetrics.registerFont(TTFont('Arial-Bold', 'Arial Bold.ttf'))
4848
#print(pdfmetrics.sorted_list())
@@ -201,8 +201,6 @@ def draw_statistics(c_draw, statistics, sig_version, custom_text):
201201
# num_bases - (Integer) The number of bases to be plotted.
202202
# c_draw - (Canvas) The canvas to draw the graph decomposition on.
203203
def draw_bracket(num_bases, c_draw):
204-
paths = cosmic.__path__[0]
205-
206204
num_plts = num_bases - 1
207205

208206
if(num_bases >= 5):

0 commit comments

Comments
 (0)