Skip to content

Commit

Permalink
Minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
francois-a committed Oct 29, 2024
1 parent 6465cb4 commit 7ea6544
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions python/rnaseqc/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ def mismatch_rates(metrics_df, cohort_s=None, cohort_order=None, cohort_colors=N

x = metrics_df['End 1 Mismatch Rate'].copy()
y = metrics_df['End 2 Mismatch Rate'].copy()
x[x>end1_limit] = end1_limit
y[y>end2_limit] = end2_limit
x[x > end1_limit] = end1_limit
y[y > end2_limit] = end2_limit

sorted_ix = sort_samples(metrics_df.index, cohort_s=cohort_s, cohort_order=cohort_order)
cohorts = cohort_s.loc[sorted_ix].unique()
if cohort_colors is None:
cohort_colors = get_cohort_colors(cohorts)

for t in cohorts:
ix = cohort_s[cohort_s==t].index
ix = cohort_s[cohort_s == t].index
ax.scatter(x[ix], y[ix], s=ms, edgecolor='none', label=t,
c=[cohort_colors[t]], alpha=alpha, clip_on=False, rasterized=True)

Expand All @@ -79,7 +79,8 @@ def mismatch_rates(metrics_df, cohort_s=None, cohort_order=None, cohort_colors=N
ax.plot([0,0.02], 2*[end2_threshold], '--', color=[0.6]*3, zorder=0, lw=1, alpha=0.8)
if end1_threshold is not None or end2_threshold is not None:
ix = (x > end1_threshold) | (y > end2_threshold)
ax.scatter(x[ix], y[ix], c='none', edgecolor='k', s=ms, lw=1, label=None, clip_on=False, rasterized=True)
if any(ix):
ax.scatter(x[ix], y[ix], c='none', edgecolor='k', s=ms, lw=1, label=None, clip_on=False, rasterized=True)

qtl.plot.format_plot(ax, fontsize=10)
ax.set_xlim([0, end1_limit])
Expand Down Expand Up @@ -362,7 +363,7 @@ def _plot_cohort_labels(ax, cohort_s, cohort_colors=None, lax=None, legend=True,
if lax is None:
lax = ax
for k,i in cohort_index_dict.items():
lax.scatter([], [], marker='s', c=[cmap(i)], label=f'{k}')
lax.scatter(np.nan, np.nan, marker='s', c=[cmap(i)], label=f'{k}')
if legend:
lax.legend(loc='upper left', borderaxespad=None, bbox_to_anchor=(1,1), handlelength=1, title='Cohort')

Expand Down Expand Up @@ -592,4 +593,6 @@ def xy_expression(tpm_df, sex_s=None, flag_klinefelter=True, highlight_ids=None,
leg = ax.legend(loc='upper left', fontsize=12, handlelength=0.5, labelspacing=0.2, bbox_to_anchor=(1,1))
for lh in leg.legend_handles:
lh.set_alpha(1)
return res_s
return ax, res_s
else:
return ax
4 changes: 2 additions & 2 deletions python/rnaseqc/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def plot_qc_figures(metrics_df, cohort_s=None, cohort_order=None, cohort_colors=
if show_legend:
ax = qtl.plot.setup_figure(lw, lh, xspace=[0,0], yspace=[0,0])
for c in cohort_order:
ax.scatter([], [], s=48, marker='s', color=cohort_colors[c], label=c)
ax.scatter([], [], fc='w', ec='k', lw=1, s=30, label='Outliers')
ax.scatter(np.nan, np.nan, s=48, marker='s', color=cohort_colors[c], label=c)
ax.scatter(np.nan, np.nan, fc='w', ec='k', lw=1, s=30, label='Outliers')
ax.legend(loc='center left', handlelength=1, ncol=legend_cols)
plt.axis('off')
if output_dir is not None:
Expand Down

0 comments on commit 7ea6544

Please sign in to comment.