Should be possible to replace:
x <- data.matrix(new_data[, transf_labels] - rep(cm_transf_df[, transf_labels], by = nrow(new_data)))
t_x <- data.matrix(as.matrix(t(x)))
With:
x <- data.matrix(new_data[, transf_labels] - cm_transf_df[, transf_labels]) # The "by" wasn't actually doing anything, but the operation is vectorised
t_x <- t(x)