Beispiel #1
0
 def test_priors_no_columns(self):
     self.setup_one_column()
     self.drop_prior()
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp)
     # assert that there are no columns in the output activities matrix
     self.assertEqual(activities.shape[1], 0)
Beispiel #2
0
 def test_tfa_default_one_column(self):
     self.setup_one_column()
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp)
     np.testing.assert_array_almost_equal_nulp(
         activities.expression_data.T, np.array([[1, 3]]),
         units_in_the_last_place_tolerance)
Beispiel #3
0
 def test_tfa_default_three_columns_dup_self_false(self):
     self.setup_three_columns()
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp)
     np.testing.assert_allclose(activities.expression_data.T,
                                np.array([[0, 0.5], [1, 2], [0, 0.5]]),
                                atol=1e-15)
Beispiel #4
0
 def test_tfa_default_three_columns(self):
     self.setup_three_columns()
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp, keep_self=True)
     np.testing.assert_allclose(activities.expression_data.T,
                                np.array([[.5, 1], [.5, 1], [0, 1]]),
                                atol=1e-15)
Beispiel #5
0
 def test_duplicate_removal_keeps_self_interaction_two_column(self):
     self.setup_one_column()
     self.priors['g3'] = self.priors['tf1']
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp, keep_self=True)
     np.testing.assert_array_almost_equal_nulp(
         activities.expression_data.T, np.array([[.5, 1.25], [.5, 1.25]]),
         units_in_the_last_place_tolerance)
Beispiel #6
0
 def setup_one_column(self):
     tau = 1
     exp = pd.DataFrame(np.array([[1, 3], [1, 2], [0, 3]]))
     exp.columns = ['s1', 's2']
     exp.index = ['g1', 'tf1', 'g3']
     priors = pd.DataFrame(np.array([[1], [1], [0]]))
     priors.columns = ['tf1']
     priors.index = exp.index
     self.tfa_object = tfa.TFA(priors, exp, exp / tau)
Beispiel #7
0
 def test_duplicate_removal_does_not_happen_with_dupes_flag_false_two_column(
         self):
     self.setup_one_column()
     self.priors['g3'] = self.priors['tf1']
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp)
     np.testing.assert_allclose(activities.expression_data.T,
                                np.array([[0, 1], [1, 2]]),
                                atol=1e-15)
Beispiel #8
0
 def test_tfa_default_all_zero_prior_no_expression_data(self):
     self.setup_one_column()
     self.priors['tf2'] = [0, 0, 0]
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp)
     # Assert that the all-zero no-expression tf was dropped from the activity matrix
     np.testing.assert_array_almost_equal_nulp(
         activities.expression_data.T, np.array([[1, 3]]),
         units_in_the_last_place_tolerance)
Beispiel #9
0
 def test_tfa_default_using_mouse_th17(self):
     self.setup_mouse_th17()
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp)
     np.testing.assert_allclose(
         activities.expression_data.T,
         np.array([[1.706100, 1.765225, 1.739675, 1.791075, 1.70055],
                   [8.160000, 8.553600, 7.765000, 7.890300, 8.08710],
                   [-1.257265, -1.611675, -1.348145, -1.196210, -1.35857],
                   [1.706100, 1.765225, 1.739675, 1.791075, 1.70055]]),
         atol=1e-15)
Beispiel #10
0
 def setup_mouse_th17(self):
     tau = 1
     exp = pd.DataFrame(
         np.array([[12.28440, 12.55000, 11.86260, 11.86230, 11.88100],
                   [8.16000, 8.55360, 7.76500, 7.89030, 8.08710],
                   [10.47820, 11.08340, 10.52270, 10.34180, 10.38780],
                   [5.46000, 5.48910, 4.90390, 4.69800, 5.07880],
                   [7.96367, 7.86005, 7.82641, 7.94938, 7.67066]]))
     exp.columns = ['s1', 's2', 's3', 's4', 's5']
     exp.index = ['g1', 't2', 'g3', 'g4', 'g5']
     priors = pd.DataFrame(
         np.array([[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, -1, 0],
                   [-1, 0, 0, -1], [0, 0, 1, 0]]))
     priors.columns = ['t1', 't2', 't3', 't4']
     priors.index = ['g1', 't2', 'g3', 'g4', 'g5']
     self.tfa_object = tfa.TFA(priors, exp, exp / 1)
Beispiel #11
0
 def test_when_prior_is_zero_vector_activity_is_expression_one_column(self):
     self.setup_one_column()
     self.priors['tf1'] = [0, 0, 0]
     activities = tfa.TFA().compute_transcription_factor_activity(
         self.priors, self.exp)
     np.testing.assert_equal(activities.expression_data.T, [[1, 2]])