Skip to content
Snippets Groups Projects
Commit d4c6916b authored by Blaise Li's avatar Blaise Li
Browse files

Moved stuff to common libraries, test size factor.

parent 4d3532cc
No related branches found
No related tags found
No related merge requests found
from .libhts import do_deseq2, median_ratio_to_pseudo_ref_size_factors, size_factor_correlations, status_setter
from .libhts import do_deseq2, median_ratio_to_pseudo_ref_size_factors, plot_counts_distribution, plot_norm_correlations, size_factor_correlations, status_setter
......@@ -13,6 +13,7 @@ import pandas as pd
from scipy.stats.stats import pearsonr
# To compute geometric mean
from scipy.stats.mstats import gmean
import seaborn as sns
from rpy2.robjects import r, pandas2ri, Formula, StrVector
as_df = r("as.data.frame")
from rpy2.rinterface import RRuntimeError
......@@ -115,6 +116,31 @@ def size_factor_correlations(counts_data, summaries, normalizer):
return (counts_data / size_factors).apply(compute_pearsonr_with_size_factor, axis=1)
def plot_norm_correlations(correlations):
#fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1, sharex=True)
#correlations.plot.kde(ax=ax1)
#sns.violinplot(data=correlations, orient="h", ax=ax2)
#ax2.set_xlabel("Pearson correlation coefficient")
ax = sns.violinplot(data=correlations, cut=0)
ax.set_ylabel("Pearson correlation coefficient")
def plot_counts_distribution(data, xlabel):
# TODO: try to plot with semilog x axis
#ax = data.plot.kde(legend=None)
#ax.set_xlabel(xlabel)
#ax.legend(ncol=len(REPS))
try:
ax = data.plot.kde()
except ValueError as e:
msg = "".join([
"There seems to be a problem with the data.\n",
"The data matrix has %d lines and %d columns.\n" % (len(data), len(data.columns))])
warnings.warn(msg)
raise
ax.set_xlabel(xlabel)
def status_setter(lfc_cutoffs=None):
if lfc_cutoffs is None:
lfc_cutoffs = [0.5, 1, 2]
......
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