Skip to content

Commit

Permalink
Changed legends for all TSB plots
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbergstrom authored and erikbergstrom committed Jun 21, 2021
1 parent eee762d commit dd4899d
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 66 deletions.
60 changes: 30 additions & 30 deletions build/lib/sigProfilerPlotting/sigProfilerPlotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,19 +775,19 @@ def plotSBS(matrix_path, output_path, project, plot_type, percentage=False, cust
xlabels.append(seq[0]+seq[2]+seq[6])
if percentage:
if total_count > 0:
trans = plt.bar(x, mutations[sample][key][seq][0]/total_count*100,width=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.bar(x, mutations[sample][key][seq][0]/total_count*100,width=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
x += 0.75
untrans = plt.bar(x, mutations[sample][key][seq][1]/total_count*100,width=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.bar(x, mutations[sample][key][seq][1]/total_count*100,width=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
x += .2475
if mutations[sample][key][seq][0]/total_count*100 > ymax:
ymax = mutations[sample][key][seq][0]/total_count*100
if mutations[sample][key][seq][1]/total_count*100 > ymax:
ymax = mutations[sample][key][seq][1]/total_count*100

else:
trans = plt.bar(x, mutations[sample][key][seq][0],width=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.bar(x, mutations[sample][key][seq][0],width=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
x += 0.75
untrans = plt.bar(x, mutations[sample][key][seq][1],width=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.bar(x, mutations[sample][key][seq][1],width=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
x += .2475
if mutations[sample][key][seq][0] > ymax:
ymax = mutations[sample][key][seq][0]
Expand Down Expand Up @@ -1062,11 +1062,11 @@ def plotSBS(matrix_path, output_path, project, plot_type, percentage=False, cust
xlabels.append(seq[0]+seq[2]+seq[6])
if percentage:
if total_count > 0:
trans = plt.bar(x, mutations[sample][key][seq][0]/total_count*100,width=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.bar(x, mutations[sample][key][seq][0]/total_count*100,width=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
x += 0.75
untrans = plt.bar(x, mutations[sample][key][seq][1]/total_count*100,width=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.bar(x, mutations[sample][key][seq][1]/total_count*100,width=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
x += 0.75
nontrans = plt.bar(x, mutations[sample][key][seq][2]/total_count*100,width=0.75,color='green',align='center', zorder=1000, label='Nontranscribed')
nontrans = plt.bar(x, mutations[sample][key][seq][2]/total_count*100,width=0.75,color='green',align='center', zorder=1000, label='Intergenic')
x += .2475
if mutations[sample][key][seq][0]/total_count*100 > ymax:
ymax = mutations[sample][key][seq][0]/total_count*100
Expand All @@ -1076,11 +1076,11 @@ def plotSBS(matrix_path, output_path, project, plot_type, percentage=False, cust
ymax = mutations[sample][key][seq][2]/total_count*100

else:
trans = plt.bar(x, mutations[sample][key][seq][0],width=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.bar(x, mutations[sample][key][seq][0],width=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
x += 0.75
untrans = plt.bar(x, mutations[sample][key][seq][1],width=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.bar(x, mutations[sample][key][seq][1],width=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
x += 0.75
nontrans = plt.bar(x, mutations[sample][key][seq][2],width=0.75,color='green',align='center', zorder=1000, label='Nontranscribed')
nontrans = plt.bar(x, mutations[sample][key][seq][2],width=0.75,color='green',align='center', zorder=1000, label='Intergenic')
x += .2475
if mutations[sample][key][seq][0] > ymax:
ymax = mutations[sample][key][seq][0]
Expand Down Expand Up @@ -1475,19 +1475,19 @@ def plotSBS(matrix_path, output_path, project, plot_type, percentage=False, cust
for key in mutations[sample]:
if percentage:
if total_count > 0:
trans = plt.barh(y, mutations[sample][key][0]/total_count*100,height=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.barh(y, mutations[sample][key][0]/total_count*100,height=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
y -= 0.75
untrans = plt.barh(y, mutations[sample][key][1]/total_count*100,height=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.barh(y, mutations[sample][key][1]/total_count*100,height=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
y -= .2475
if mutations[sample][key][0]/total_count*100 > xmax:
xmax = mutations[sample][key][0]/total_count*100
if mutations[sample][key][1]/total_count*100 > xmax:
xmax = mutations[sample][key][1]/total_count*100

else:
trans = plt.barh(y, mutations[sample][key][0],height=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.barh(y, mutations[sample][key][0],height=0.75,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
y -= 0.75
untrans = plt.barh(y, mutations[sample][key][1],height=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.barh(y, mutations[sample][key][1],height=0.75,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
y -= .2475
if mutations[sample][key][0] > xmax:
xmax = mutations[sample][key][0]
Expand Down Expand Up @@ -2831,11 +2831,11 @@ def plotSBS(matrix_path, output_path, project, plot_type, percentage=False, cust
i = 0
for tsb in mutations_TSB[sample][mut]:
if tsb == "T":
label = "Transcribed"
label = "Genic-transcribed"
elif tsb == "U":
label = "Untranscribed"
label = "Genic-untranscribed"
else:
label = "Nontranscribed"
label = "Intergenic"
if percentage:
if total_count > 0:
panel5.barh(yp2, mutations_TSB[sample][mut][tsb]/total_count*100,color=tsbColors[i], label=label)
Expand Down Expand Up @@ -3543,14 +3543,14 @@ def plotSBS(matrix_path, output_path, project, plot_type, percentage=False, cust
labels.append(mut)
if True:
totalMuts = sum([mutations_TSB[sample][mut][x] for x in mutations_TSB[sample][mut]])
panel2.barh(yp2, mutations_TSB[sample][mut]["N"]/totalMuts*100, 1.25, color=tsbColors[2], label="Nontranscribed", zorder=0)
panel2.barh(yp2, (mutations_TSB[sample][mut]["N"] + mutations_TSB[sample][mut]["T"] + mutations_TSB[sample][mut]["U"])/totalMuts*100, 1.25, color="purple", label="Transcribed Regions", zorder=-1)
panel2.barh(yp2, mutations_TSB[sample][mut]["N"]/totalMuts*100, 1.25, color=tsbColors[2], label="Intergenic", zorder=0)
panel2.barh(yp2, (mutations_TSB[sample][mut]["N"] + mutations_TSB[sample][mut]["T"] + mutations_TSB[sample][mut]["U"])/totalMuts*100, 1.25, color="purple", label="Genic-transcribed Regions", zorder=-1)

yp2 -= 1.25

transcribedTotal = mutations_TSB[sample][mut]["T"] + mutations_TSB[sample][mut]["U"]
panel2.barh(yp2, mutations_TSB[sample][mut]["T"]/transcribedTotal*100, 1.25, color=tsbColors[0], label="Transcribed strand", zorder=0)
panel2.barh(yp2, (mutations_TSB[sample][mut]["T"] + mutations_TSB[sample][mut]["U"])/transcribedTotal*100, 1.25, color=tsbColors[1], label="Untranscribed strand", zorder=-1)
panel2.barh(yp2, (mutations_TSB[sample][mut]["T"] + mutations_TSB[sample][mut]["U"])/transcribedTotal*100, 1.25, color=tsbColors[1], label="Genic-untranscribed strand", zorder=-1)

yp2 -= 1.25
yp2 -=1.25
Expand Down Expand Up @@ -4562,18 +4562,18 @@ def plotID(matrix_path, output_path, project, plot_type, percentage=False, custo
xlabels.append(l)
if percentage:
if total_count > 0:
trans = plt.bar(x, seq[0]/total_count*100,width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.bar(x, seq[0]/total_count*100,width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
x += 0.2
untrans = plt.bar(x, seq[1]/total_count*100,width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.bar(x, seq[1]/total_count*100,width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
if seq[0]/total_count*100 > ymax:
ymax = seq[0]/total_count*100
if seq[1]/total_count*100 > ymax:
ymax = seq[1]/total_count*100

else:
trans = plt.bar(x, seq[0],width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.bar(x, seq[0],width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
x += 0.2
untrans = plt.bar(x, seq[1],width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.bar(x, seq[1],width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
if seq[0] > ymax:
ymax = seq[0]
if seq[1] > ymax:
Expand Down Expand Up @@ -5168,22 +5168,22 @@ def plotDBS(matrix_path, output_path, project, plot_type, percentage=False, cust
xlabels.append(seq)
if percentage:
try:
trans = plt.bar(x, mutations[sample][key][seq][0]/total_count*100,width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.bar(x, mutations[sample][key][seq][0]/total_count*100,width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
x += 0.2
untrans = plt.bar(x, mutations[sample][key][seq][1]/total_count*100,width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.bar(x, mutations[sample][key][seq][1]/total_count*100,width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
x += .8
if mutations[sample][key][seq][0]/total_count*100 > ymax:
ymax = mutations[sample][key][seq][0]/total_count*100
if mutations[sample][key][seq][1]/total_count*100 > ymax:
ymax = mutations[sample][key][seq][1]/total_count*100
except:
trans = plt.bar(x, 0,width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
untrans = plt.bar(x, 0, width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
trans = plt.bar(x, 0,width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
untrans = plt.bar(x, 0, width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')

else:
trans = plt.bar(x, mutations[sample][key][seq][0],width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Transcribed Strand')
trans = plt.bar(x, mutations[sample][key][seq][0],width=0.2,color=[1/256,70/256,102/256],align='center', zorder=1000, label='Genic-transcribed Strand')
x += 0.2
untrans = plt.bar(x, mutations[sample][key][seq][1],width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Untranscribed Strand')
untrans = plt.bar(x, mutations[sample][key][seq][1],width=0.2,color=[228/256,41/256,38/256],align='center', zorder=1000, label='Genic-untranscribed Strand')
x += .8
if mutations[sample][key][seq][0] > ymax:
ymax = mutations[sample][key][seq][0]
Expand Down
4 changes: 2 additions & 2 deletions build/lib/sigProfilerPlotting/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# THIS FILE IS GENERATED FROM SIGPROFILERPLOTTING SETUP.PY
short_version = '1.1.16'
version = '1.1.16'
short_version = '1.1.17'
version = '1.1.17'


2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def readme():
with open('README.rst') as f:
return(f.read())

VERSION = '1.1.16'
VERSION = '1.1.17'

def write_version_py(filename='sigProfilerPlotting/version.py'):
# Copied from numpy setup.py
Expand Down
2 changes: 1 addition & 1 deletion sigProfilerPlotting.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: sigProfilerPlotting
Version: 1.1.16
Version: 1.1.17
Summary: SigProfiler plotting tool
Home-page: UNKNOWN
Author: Erik Bergstrom
Expand Down
Loading

0 comments on commit dd4899d

Please sign in to comment.