Skip to content

Commit f8a80c2

Browse files
author
gentzian
committed
Ensure that boxplot x-limit is not zero
1 parent 42c95cd commit f8a80c2

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

SIRVsuite/Pipeline/Concentration/SIRV_concentration.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,16 @@ def create_sirvsuite_boxplot(self, relative_abundance):
232232

233233
limit_x = heatmap_matrix.max()
234234

235-
ax1.set_xlim([np.min(relative_conc)-np.min(relative_conc)*0.8,limit_x])
235+
# The relative concentration can be zero, which is not allowed in log scale plot.
236+
# Thus, we determine a non-zero minimum, with margin to make all non-zero counts visible.
237+
relative_conc_margin = relative_conc * 0.8
238+
relative_conc_wo_zero = np.delete(relative_conc_margin, np.where(relative_conc_margin == 0.0))
239+
if len(relative_conc_wo_zero) > 0:
240+
min_relative_conc = np.min(relative_conc_wo_zero)
241+
else:
242+
min_relative_conc = 10**(-6)
243+
x_limits = [min_relative_conc, limit_x]
244+
ax1.set_xlim(x_limits)
236245

237246
ax1.set_yticklabels(relative_abundance.keys())
238247
plt.xlabel("relative SIRV transcript concentration")

0 commit comments

Comments
 (0)