Exemple #1
0
 def __compute_cluster_score_means(self, network_score):
     """compute the score means on the given network score"""
     result = {}
     for cluster in xrange(1, self.num_clusters() + 1):
         cluster_scores = [network_score[cluster][gene]
                           if gene in network_score[cluster] else 0.0
                           for gene in self.rows_for_cluster(cluster)]
         result[cluster] = util.trim_mean(cluster_scores, 0.05)
     return result
Exemple #2
0
def compute_iteration_scores(network_iteration_scores):
    """called 'cluster.ns' in the original cMonkey"""
    result = {}
    for cluster in network_iteration_scores:
        cluster_scores = []
        for _, score in network_iteration_scores[cluster].items():
            cluster_scores.append(score)
        result[cluster] = util.trim_mean(cluster_scores, 0.05)
    return result
 def log_subresult(self, score_function, matrix):
     """output an accumulated subresult to the log"""
     scores = []
     mvalues = matrix.values
     for cluster in xrange(1, matrix.num_columns + 1):
         cluster_rows = self.membership.rows_for_cluster(cluster)
         for row in xrange(matrix.num_rows):
             if matrix.row_names[row] in cluster_rows:
                 scores.append(mvalues[row][cluster - 1])
     logging.debug("function '%s', trim mean score: %f", score_function.id,
                   util.trim_mean(scores, 0.05))
Exemple #4
0
 def __compute_cluster_score_means(self, network_score):
     """compute the score means on the given network score"""
     result = {}
     for cluster in xrange(1, self.num_clusters() + 1):
         cluster_scores = [
             network_score[cluster][gene]
             if gene in network_score[cluster] else 0.0
             for gene in self.rows_for_cluster(cluster)
         ]
         result[cluster] = util.trim_mean(cluster_scores, 0.05)
     return result
Exemple #5
0
 def log_subresult(self, score_function, matrix):
     """output an accumulated subresult to the log"""
     scores = []
     mvalues = matrix.values
     for cluster in xrange(1, matrix.num_columns + 1):
         cluster_rows = self.membership.rows_for_cluster(cluster)
         for row in xrange(matrix.num_rows):
             if matrix.row_names[row] in cluster_rows:
                 scores.append(mvalues[row][cluster - 1])
     logging.info("function '%s', trim mean score: %f",
                  score_function.name(),
                  util.trim_mean(scores, 0.05))
 def __compute_cluster_score_means(self, network_score):
     """compute the score means on the given network score"""
     result = {}
     for cluster in xrange(1, self.num_clusters() + 1):
         cluster_scores = []
         for gene in sorted(self.rows_for_cluster(cluster)):
             if gene in network_score[cluster].keys():
                 cluster_scores.append(network_score[cluster][gene])
             else:
                 cluster_scores.append(0.0)
         result[cluster] = util.trim_mean(cluster_scores, 0.05)
     return result
Exemple #7
0
 def __compute_cluster_score_means(self, network_score):
     """compute the score means on the given network score"""
     result = {}
     for cluster in xrange(1, self.num_clusters() + 1):
         ## TODO: we can rewrite this as a list comprehension. Check whether that
         ## will be faster
         cluster_scores = []
         for gene in sorted(self.rows_for_cluster(cluster)):
             if gene in network_score[cluster].keys():
                 cluster_scores.append(network_score[cluster][gene])
             else:
                 cluster_scores.append(0.0)
         result[cluster] = util.trim_mean(cluster_scores, 0.05)
     return result
 def test_trim_mean_real(self):
     values = [0.0, 0.0, -8.7520618359684352, -8.7520618359684352, 0.0, 0.0,
               0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
     self.assertAlmostEqual(-1.4586770, util.trim_mean(values, 0.05))
 def test_trim_mean_no_values(self):
     self.assertEqual(0, util.trim_mean([], 0.05))
 def test_trim_mean_median(self):
     self.assertAlmostEqual(3.5, util.trim_mean([.1, .2, 3, 4, 5, 6], 0.5))
 def test_trim_mean_nonmedian(self):
     self.assertAlmostEqual(
         40.625,
         util.trim_mean([2, 4, 6, 7, 11, 21, 81, 90, 105, 121], 0.1))