netneurotools.cluster.reorder_assignments

netneurotools.cluster.reorder_assignments(assignments, consensus=None, col_sort=True, row_sort=True, return_index=True, seed=None)[source]

Relabel and reorders rows / columns of assignments to “look better”.

Relabels cluster solutions in assignments so that distinct clustering solutions have similar cluster labels. Then, swaps columns of assignments so that similar clustering solutions are placed near each other. Finally, swaps rows of assignments so that subjects with similar clustering profiles are placed near each other.

Uses hierarchical clustering to generate re-ordering of columns and rows

Parameters:
  • assignments ((N, M) array_like) – Array of M clustering assignments for N subjects

  • consensus ((N,) array_like, optional) – “Final” clustering solution for N subjects. If provided, reordering of rows will be constrained by cluster assignment. Default: None

  • {row (bool, optional) – If True, sort the {rows, columns}. Default: True

  • col}_sort (bool, optional) – If True, sort the {rows, columns}. Default: True

  • return_index (bool, optional) – Whether to return the row and column indices used to re-order assignments in addition to the re-ordered matrix. Default: True

  • seed ({int, np.random.RandomState instance, None}, optional) – Seed for random number generation. Default: None

Returns:

  • reordered ((N, M) numpy.ndarray) – Provided array with both rows and columns re-ordered

  • index (tuple) – Indices used to reorder assignments to generate reordered output