xxxxxxxxxx
import numpy as np
def clr_transform(matrix, offset=1e-10):
def geometric_mean(row):
return np.exp(np.mean(np.log(row + offset))
gm = np.apply_along_axis(geometric_mean, axis=1, arr=matrix)
clr_matrix = np.log((matrix + offset) / gm[:, np.newaxis])
return clr_matrix