feat(core): added compare_annotations function and unit tests #336
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduced a new utility function compare_annotations to the spac.transformations module. It computes pairwise similarity metrics between multiple clustering annotations in an AnnData object and visualize the results as a heatmap.
Write up:
spac.transformations.compare_annotations(adata: AnnData, annotation_list: list, metric: str = "adjusted_rand_score") → plotly.graph_objects.Figure
Compare multiple cluster annotations using a similarity metric and visualize the result as a heatmap.
This function computes pairwise similarity scores between specified cluster annotations in an AnnData object using either the Adjusted Rand Index or Normalized Mutual Information. It stores the resulting similarity matrix and the list of compared annotations in .uns and returns a heatmap of the scores.
Parameters adata (AnnData) – The input AnnData object containing cluster annotations in .obs.
annotation_list (list) – A list of column names from .obs representing different cluster annotations to compare.
metric (str, optional) – The metric used for comparison. Must be either "adjusted_rand_score" or "normalized_mutual_info_score". Default is "adjusted_rand_score".
Returns A heatmap figure visualizing the similarity scores between all pairs of annotations.
Return type plotly.graph_objects.Figure