@@ -105,19 +105,22 @@ def scatter(
105105 return []
106106 plots_made = []
107107 idx = np .random .choice (x .index , min (10000 , len (x )), replace = False )
108+ downsampled = len (x ) > 10000
108109 maxvalx = xmax or np .amax (x [idx ])
109110 maxvaly = ymax or np .amax (y [idx ])
110111
111112 if plots ["dot" ]:
112113 if log :
113114 dot_plot = Plot (
114115 path = path + "_loglength_dot.html" ,
115- title = f"{ names [0 ]} vs { names [1 ]} plot using dots "
116- "after log transformation of read lengths" ,
116+ title = f"{ names [0 ]} vs { names [1 ]} dot plot "
117+ + ( "( log-transformed, downsampled)" if downsampled else "(log-transformed)" ) ,
117118 )
118119 else :
119120 dot_plot = Plot (
120- path = path + "_dot.html" , title = f"{ names [0 ]} vs { names [1 ]} plot using dots"
121+ path = path + "_dot.html" ,
122+ title = f"{ names [0 ]} vs { names [1 ]} dot plot"
123+ + (" (downsampled)" if downsampled else "" ),
121124 )
122125
123126 fig = px .scatter (
@@ -150,7 +153,8 @@ def scatter(
150153 if plots ["kde" ]:
151154 kde_plot = Plot (
152155 path = path + "_loglength_kde.html" if log else path + "_kde.html" ,
153- title = f"{ names [0 ]} vs { names [1 ]} kde plot" ,
156+ title = f"{ names [0 ]} vs { names [1 ]} kde plot"
157+ + (" (downsampled)" if downsampled else "" ),
154158 )
155159
156160 col = hex_to_rgb_scale_0_1 (color )
@@ -317,17 +321,19 @@ def scatter_legacy(
317321
318322 if plots ["kde" ]:
319323 if len (x ) > 2 :
324+ kde_downsampled = len (x ) > 2000
320325 idx = np .random .choice (x .index , min (2000 , len (x )), replace = False )
321326 if log :
322327 kde_plot = Plot (
323328 path = path + "_loglength_kde." + figformat [0 ],
324- title = "{ } vs {} plot using a kernel density estimation "
325- "after log transformation of read lengths" . format ( names [ 0 ], names [ 1 ] ),
329+ title = f" { names [ 0 ] } vs { names [ 1 ] } kde plot "
330+ + ( "( log-transformed, downsampled)" if kde_downsampled else "(log-transformed)" ),
326331 )
327332 else :
328333 kde_plot = Plot (
329334 path = path + "_kde." + figformat [0 ],
330- title = f"{ names [0 ]} vs { names [1 ]} plot using a kernel density estimation" ,
335+ title = f"{ names [0 ]} vs { names [1 ]} kde plot"
336+ + (" (downsampled)" if kde_downsampled else "" ),
331337 )
332338 plot = sns .jointplot (
333339 x = x [idx ],
@@ -349,7 +355,10 @@ def scatter_legacy(
349355 plot .ax_marg_x .set_xticks (np .log10 (ticks ))
350356 plot .ax_joint .set_xticklabels (ticks )
351357 plt .subplots_adjust (top = 0.90 )
352- plot .fig .suptitle (title or "{} vs {} plot" .format (names [0 ], names [1 ]), fontsize = 25 )
358+ _suptitle = "{} vs {} plot{}" .format (
359+ names [0 ], names [1 ], " (downsampled)" if kde_downsampled else ""
360+ )
361+ plot .fig .suptitle (title or _suptitle , fontsize = 25 )
353362 kde_plot .fig = plot
354363 kde_plot .save (settings )
355364 plots_made .append (kde_plot )
@@ -494,11 +503,14 @@ def dynamic_histogram(array, name, path, settings, title=None, color="#4CB391"):
494503 Use plotly to a histogram
495504 Return html code, but also save as png
496505 """
506+ is_downsampled = len (array ) > 10000
497507 dynhist = Plot (
498508 path = path + f"Dynamic_Histogram_{ name [0 ].lower () + name [1 :].replace (' ' , '_' )} .html" ,
499- title = "Dynamic histogram of {}" .format (name [0 ].lower () + name [1 :]),
509+ title = "Dynamic histogram of {}{}" .format (
510+ name [0 ].lower () + name [1 :], " (downsampled)" if is_downsampled else ""
511+ ),
500512 )
501- ylabel = "Number of reads" if len ( array ) <= 10000 else "Downsampled number of reads"
513+ ylabel = "Number of reads" if not is_downsampled else "Downsampled number of reads"
502514 dynhist .html , dynhist .fig = plotly_histogram (
503515 array = array .sample (min (len (array ), 10000 )),
504516 color = color ,
0 commit comments