This function takes two identical annotations (e.g, two cluster calls for the same cells) and updates the levels of the match cluster to correspond to the levels of the reference cluster. This is useful to run prior to `compare_plot` if clusters are not already ordered.

`clRef` and `clMatch` should be factors, but can be coerced from characters if needed.

reorder_factor(clMatch, clRef)

Arguments

clMatch

A cluster factor object to compare to a reference

clRef

A cluster factor object for the reference clusters

Value

The `clMatch` vector with levels rearranged to match `clRef` in a reasonable way.