changed code to precalculate matrices on the whole gene set