def __compute_row_scores_for_submatrix(matrix, submatrix): """For a given matrix, compute the row scores. The second submatrix is used to calculate the column means on and should be derived from datamatrix filtered by the row names and column names of a specific cluster. matrix should be filtered by the columns of a specific cluster in order for the column means to be applied properly. The result is a DataMatrix with one row containing all the row scores""" colmeans = submatrix.column_means() return np.log( util.row_means(scoring.subtract_and_square(matrix, colmeans)) + 1e-99)
def test_subtract_and_square(self): matrix = dm.DataMatrix(2, 3, values=[[11.0, 12.0, 13.0], [14.0, 15.0, 16.0]]) result = scoring.subtract_and_square(matrix, [5.0, 6.0, 3.0]) self.assertTrue(([[36.0, 36.0, 100.0], [81.0, 81.0, 169.0]] == result).all())