From 849375f5293d09db21d975ec83e9a2ddb16b1470 Mon Sep 17 00:00:00 2001
From: Blaise Li <blaise.li__git@nsup.org>
Date: Mon, 22 Jan 2018 13:39:36 +0100
Subject: [PATCH] Plot paired scatterplots and compute RPM.

Made paired scatterplot plotting function part of libhts as
`plot_paired_scatters`. Modifications in small RNA-seq pipeline not
tested.
---
 libhts/__init__.py | 2 +-
 libhts/libhts.py   | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libhts/__init__.py b/libhts/__init__.py
index 4b8022b..efc99af 100644
--- a/libhts/__init__.py
+++ b/libhts/__init__.py
@@ -1 +1 @@
-from .libhts import do_deseq2, gtf_2_genes_exon_lengths, median_ratio_to_pseudo_ref_size_factors, plot_boxplots, plot_counts_distribution, plot_lfc_distribution, plot_MA, plot_norm_correlations, plot_scatter, repeat_bed_2_lengths, size_factor_correlations, spikein_gtf_2_lengths, status_setter
+from .libhts import do_deseq2, gtf_2_genes_exon_lengths, median_ratio_to_pseudo_ref_size_factors, plot_boxplots, plot_counts_distribution, plot_lfc_distribution, plot_MA, plot_norm_correlations, plot_paired_scatters, plot_scatter, repeat_bed_2_lengths, size_factor_correlations, spikein_gtf_2_lengths, status_setter
diff --git a/libhts/libhts.py b/libhts/libhts.py
index e708d35..edce5a9 100644
--- a/libhts/libhts.py
+++ b/libhts/libhts.py
@@ -506,3 +506,12 @@ def plot_scatter(data,
         else:
             ax.set_ylim(y_range)
     return ax
+
+def plot_paired_scatters(data, columns=None, hue=None):
+    """Alternative to pairplot, in order to avoid histograms on the diagonal."""
+    if columns is None:
+        columns = data.columns
+    g = sns.PairGrid(data, vars=columns, hue=hue, size=8)
+    #g.map_offdiag(plt.scatter, marker=".")
+    g.map_lower(plt.scatter, marker=".")
+    g.add_legend()
-- 
GitLab