Commit 785b0089 authored by Blaise Li's avatar Blaise Li
Browse files

Better handling of empty data in scatterplots.

parent 06c17d33
......@@ -396,9 +396,16 @@ def plot_MA(res,
else:
(status, colour) = group2colour
row_indices = data.index.intersection(grouping)
data.ix[row_indices].plot.scatter(
x=x_column, y=y_column, s=1, logx=True, c=colour,
label=f"{status} ({len(row_indices)})", ax=ax)
try:
data.ix[row_indices].plot.scatter(
x=x_column, y=y_column, s=1, logx=True, c=colour,
label=f"{status} ({len(row_indices)})", ax=ax)
except ValueError as e:
if str(e) != "scatter requires x column to be numeric":
print(data.ix[row_indices])
raise
else:
warnings.warn(f"Nothing to plot for {status}\n")
ax.axhline(y=1, linewidth=0.5, color="0.5", linestyle="dashed")
ax.axhline(y=-1, linewidth=0.5, color="0.5", linestyle="dashed")
# TODO: check data basemean range
......@@ -454,9 +461,16 @@ def plot_scatter(data,
# Apply a coulour to a list of genes
(status, colour) = group2colour
row_indices = data.index.intersection(grouping)
data.ix[row_indices].plot.scatter(
x=x_column, y=y_column, s=1, c=colour,
label=f"{status} ({len(row_indices)})", ax=ax)
try:
data.ix[row_indices].plot.scatter(
x=x_column, y=y_column, s=1, c=colour,
label=f"{status} ({len(row_indices)})", ax=ax)
except ValueError as e:
if str(e) != "scatter requires x column to be numeric":
print(data.ix[row_indices])
raise
else:
warnings.warn(f"Nothing to plot for {status}\n")
ax.axhline(y=0, linewidth=0.5, color="0.5", linestyle="dashed")
ax.axvline(x=0, linewidth=0.5, color="0.5", linestyle="dashed")
# Set axis limits
......
Supports Markdown
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