def test_quantile(): """ Calls quantile normalization. Prints raw counts then normed counts. """ counts_fname = utils.load_testdata("pasilla") # Consider only a subset of the samples samples = OrderedDict() samples["Untreated 1"] = "untreated1" samples["Untreated 2"] = "untreated2" exp_obj = experiment.Experiment(counts_fname, samples) norm_counts_df = normalizers.norm_q(exp_obj) print "\nQuantile Testing:" print "--------------" print "Pre-normalized counts: " print exp_obj.counts_df.head() print "Normalized counts: " print norm_counts_df.head()
def test_quantile(): """ Calls quantile normalization. Prints raw counts then normed counts. """ counts_fname = utils.load_testdata("pasilla") # Consider only a subset of the samples samples = OrderedDict() samples["Untreated 1"] = "untreated1" samples["Untreated 2"] = "untreated2" exp_obj = experiment.Experiment(counts_fname, samples) norm_counts_df = normalizers.norm_q(exp_obj) print("\nQuantile Testing:") print("--------------") print("Pre-normalized counts: ") print(exp_obj.counts_df.head()) print("Normalized counts: ") print(norm_counts_df.head())
def test_quantile_vs_tmm(): """ Test quantile normalization versus TMM in rank correlation of genes. """ counts_fname = utils.load_testdata("pasilla") # Consider only a subset of the samples samples = OrderedDict() samples["Untreated 1"] = "untreated1" samples["Untreated 2"] = "untreated2" exp_obj = experiment.Experiment(counts_fname, samples) quantile_counts_df = normalizers.norm_q(exp_obj) tmm_counts_df = normalizers.norm_tmm(exp_obj) print("\nQuantile versus TMM Testing:") print("--------------") print("Normalized quantile counts: ") print(quantile_counts_df.head()) print("Normalized TMM counts: ") print(tmm_counts_df.head()) print("Correlating the genes.") # Merge the dataframes together, indexing by gene combined_df = pandas.merge(quantile_counts_df, tmm_counts_df, left_index=True, right_index=True, suffixes=["_q", "_tmm"], how="outer") # Get log of counts: get rid of infinite values log_counts_df = combined_df.apply(np.log2).replace([-np.inf, np.inf], np.nan) print("Combined dataframe: ") print(combined_df.head()) print("Combined log dataframe: ") print(log_counts_df.head()) # Plot correlation from pandas.tools.plotting import scatter_matrix scatter_matrix(log_counts_df, alpha=0.2, figsize=(8, 7)) plot_utils.save_fig("quantile_vs_tmm_corr", ext="png") sys.stderr.write("Test quantile vs tmm done!\n")
def test_quantile_vs_tmm(): """ Test quantile normalization versus TMM in rank correlation of genes. """ counts_fname = utils.load_testdata("pasilla") # Consider only a subset of the samples samples = OrderedDict() samples["Untreated 1"] = "untreated1" samples["Untreated 2"] = "untreated2" exp_obj = experiment.Experiment(counts_fname, samples) quantile_counts_df = normalizers.norm_q(exp_obj) tmm_counts_df = normalizers.norm_tmm(exp_obj) print "\nQuantile versus TMM Testing:" print "--------------" print "Normalized quantile counts: " print quantile_counts_df.head() print "Normalized TMM counts: " print tmm_counts_df.head() print "Correlating the genes." # Merge the dataframes together, indexing by gene combined_df = pandas.merge(quantile_counts_df, tmm_counts_df, left_index=True, right_index=True, suffixes=["_q", "_tmm"], how="outer") # Get log of counts: get rid of infinite values log_counts_df = combined_df.apply(np.log2).replace([-np.inf, np.inf], np.nan) print "Combined dataframe: " print combined_df.head() print "Combined log dataframe: " print log_counts_df.head() # Plot correlation from pandas.tools.plotting import scatter_matrix scatter_matrix(log_counts_df, alpha=0.2, figsize=(8, 7)) plot_utils.save_fig("quantile_vs_tmm_corr", ext="png")