This function identifies the clusters to remove such that all remaining clusters have pairwise r2 below a given threshold. It is assumed the r2 matrix is ordered such that the first row/column corresponds to the most significant signal cluster, and so on. trimClusters either removes clusters correlated with the most significant cluster (first) and proceeds downwards, or removes clusters with correlation to more significant clusters and proceeds upwards. Moving downward tends to preserve more clusters. The function stops once the pairwise r2 are all below the threshold. It is recommended to run this function after extractForSlope.

trimClusters(r2, r2_threshold, direction = "down")

Arguments

r2

the matrix of r2 values

r2_threshold

the threshold on r2

direction

to proceed from the first cluster down ("down") or from the last cluster up ("up")

Value

a numeric vector (possibly length 0) of the signal clusters that should be trimmed/removed