|
@@ -153,7 +153,11 @@ def plot_matrix(mat, legend=None, color_scale_type="YlGn", cbarlabel = "qt", tit
|
153
|
153
|
|
154
|
154
|
def plot(x, y, outfile = None, outfolder = None, ylab=None, xlab=None,
|
155
|
155
|
title=None, label = None, show=True, nb_subplots = None, subplot_init = False,
|
156
|
|
- subplot_id = None):
|
|
156
|
+ subplot_id = None, output = None, dpi = 300, width = 15, height = 15, plot_init = True):
|
|
157
|
+
|
|
158
|
+ # before fig is generated, set its dimensions
|
|
159
|
+ if plot_init:
|
|
160
|
+ plt.figure(figsize=(width, height))
|
157
|
161
|
if subplot_init:
|
158
|
162
|
# define a certain amount of subplots
|
159
|
163
|
fig, axs = plt.subplots(nb_subplots)
|
|
@@ -181,10 +185,10 @@ def plot(x, y, outfile = None, outfolder = None, ylab=None, xlab=None,
|
181
|
185
|
if title:
|
182
|
186
|
plt.title(title)
|
183
|
187
|
if outfile:
|
184
|
|
- plt.savefig(outfile)
|
185
|
|
- else:
|
186
|
|
- if show == True:
|
187
|
|
- plt.show()
|
|
188
|
+ plt.savefig(outfile, dpi = dpi)
|
|
189
|
+ if show == True:
|
|
190
|
+ plt.show()
|
|
191
|
+
|
188
|
192
|
|
189
|
193
|
def scatter(x, y, ylab=None, xlab=None, title=None):
|
190
|
194
|
plt.scatter(x, y)
|
|
@@ -208,7 +212,7 @@ def barplot(x, y, ylab=None, xlab=None, title=None):
|
208
|
212
|
|
209
|
213
|
def plot_chrom_continuity(vcf_entries, chr_id, x=None, y=None, outfile = None,
|
210
|
214
|
outfolder = None, returned=False, show=True, label=True, step=1, nb_subplots = None,
|
211
|
|
- subplot_init = False, subplot_id = None, title = None):
|
|
215
|
+ subplot_init = False, subplot_id = None, title = None, plot_init = False):
|
212
|
216
|
chr_name = list(vcf_entries.keys())[chr_id]
|
213
|
217
|
if label:
|
214
|
218
|
label = chr_name
|
|
@@ -226,10 +230,10 @@ def plot_chrom_continuity(vcf_entries, chr_id, x=None, y=None, outfile = None,
|
226
|
230
|
xlab = "pos. in ref.",
|
227
|
231
|
title = title,
|
228
|
232
|
outfile = outfile, outfolder = outfolder, show=show, label=label,
|
229
|
|
- nb_subplots = nb_subplots, subplot_init = subplot_init, subplot_id = subplot_id)
|
|
233
|
+ nb_subplots = nb_subplots, subplot_init = subplot_init, subplot_id = subplot_id, plot_init = plot_init)
|
230
|
234
|
|
231
|
235
|
def plot_whole_karyotype(recent_variants, mem_clean = False, step = 1, show = True, min_chr_id = 0,
|
232
|
|
- max_chr_id = None, stacked = False, title = None):
|
|
236
|
+ max_chr_id = None, stacked = False, title = None, outfile = None):
|
233
|
237
|
coords = []
|
234
|
238
|
if max_chr_id :
|
235
|
239
|
nb_iter = max_chr_id
|
|
@@ -246,7 +250,7 @@ def plot_whole_karyotype(recent_variants, mem_clean = False, step = 1, show = Tr
|
246
|
250
|
nb_subplots = None
|
247
|
251
|
subplot_init = False
|
248
|
252
|
vcf_utils.customgraphics.plot_chrom_continuity(recent_variants, chr_id = min_chr_id, show = False, returned = False, step = step,
|
249
|
|
- nb_subplots = nb_subplots, subplot_init = subplot_init, subplot_id = min_chr_id)
|
|
253
|
+ nb_subplots = nb_subplots, subplot_init = subplot_init, subplot_id = min_chr_id, plot_init = True)
|
250
|
254
|
else :
|
251
|
255
|
iter_start = 0
|
252
|
256
|
for chr in range(iter_start, nb_iter):
|
|
@@ -267,7 +271,9 @@ def plot_whole_karyotype(recent_variants, mem_clean = False, step = 1, show = Tr
|
267
|
271
|
vcf_utils.customgraphics.plot_chrom_continuity(recent_variants, chr_id = chr, show = False, returned = False, step = step, subplot_id = chr)
|
268
|
272
|
# last case
|
269
|
273
|
if show == True:
|
270
|
|
- vcf_utils.customgraphics.plot_chrom_continuity(recent_variants, chr_id = nb_iter, show = True, returned = False, step = step, subplot_id = nb_iter, title = title)
|
|
274
|
+ vcf_utils.customgraphics.plot_chrom_continuity(recent_variants, chr_id = nb_iter, show = True, returned = False, step = step, subplot_id = nb_iter,
|
|
275
|
+ title = title,
|
|
276
|
+ outfile = outfile, plot_init = False)
|
271
|
277
|
# maybe add a clean of recent_variants in extreme cases, before building the plots
|
272
|
278
|
if show == False:
|
273
|
279
|
return coords
|