Commit 2807a83a authored by Blaise Li's avatar Blaise Li
Browse files

More explicit handling of absence of data to plot.

parent 17f3b0bc
...@@ -409,7 +409,14 @@ def plot_histo(outfile, data, title=None): ...@@ -409,7 +409,14 @@ def plot_histo(outfile, data, title=None):
plt.setp(ax.get_xticklabels(), rotation=90) plt.setp(ax.get_xticklabels(), rotation=90)
if title is not None: if title is not None:
plt.title(title) plt.title(title)
plt.savefig(outfile) ## debug
try:
plt.savefig(outfile)
except RuntimeError as e:
print(data.index)
print(title)
raise
##
def plot_boxplots(data, ylabel): def plot_boxplots(data, ylabel):
...@@ -597,6 +604,8 @@ def plot_MA(res, ...@@ -597,6 +604,8 @@ def plot_MA(res,
"""*fold_type* is "log2FoldChange" by default. """*fold_type* is "log2FoldChange" by default.
It can also be "lfcMLE", which is based on uncorrected values. It can also be "lfcMLE", which is based on uncorrected values.
This may not be good for genes with low expression levels.""" This may not be good for genes with low expression levels."""
if not len(res):
raise ValueError("No data to plot.")
fig, ax = plt.subplots() fig, ax = plt.subplots()
# Make a column indicating whether the gene is DE or NS # Make a column indicating whether the gene is DE or NS
data = res.assign(is_DE=res.apply(set_de_status, axis=1)) data = res.assign(is_DE=res.apply(set_de_status, axis=1))
...@@ -684,6 +693,8 @@ def plot_scatter(data, ...@@ -684,6 +693,8 @@ def plot_scatter(data,
x_range=None, x_range=None,
y_range=None, y_range=None,
axes_style=None): axes_style=None):
if not len(data):
raise ValueError("No data to plot.")
fig, ax = plt.subplots() fig, ax = plt.subplots()
# ax.set_adjustable('box') # ax.set_adjustable('box')
# First plot the data in grey # First plot the data in grey
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment