scimilarity.visualizations#
- scimilarity.visualizations.aggregate_counts(data, levels)[source]#
Aggregates cell counts on sample metadata and compiles it into circlify format.
- Parameters:
data (pandas.DataFrame) – A pandas dataframe containing sample metadata.
levels (List[str]) – Specify the groupby columns for grouping the sample metadata.
- Returns:
A circlify format dictionary containing grouped sample metadata.
- Return type:
dict
Examples
>>> circ_dict = aggregate_counts(sample_metadata, ["tissue", "disease"])
- scimilarity.visualizations.assign_colors(data_dict, data, levels, color_column, name_column)[source]#
Assigns circle name and color to a circlify format dictionary.
- Parameters:
data_dict (dict) – A circlify format dictionary.
data (pandas.DataFrame) – A pandas dataframe containing sample metadata.
levels (List[str]) – Specify the groupby columns for grouping the sample metadata.
color_column (str) – The name of the column that will be used for the circle color.
name_column (str) – The name of the column that will be used for circle name.
- Returns:
A circlify format dictionary.
- Return type:
dict
Examples
>>> circ_dict = assign_colors(circ_dict, sample_metadata, ["tissue", "disease"], color_column="cells", name_column="study")
- scimilarity.visualizations.assign_size(data_dict, data, levels, size_column, name_column)[source]#
Assigns circle sizes to a circlify format dictionary.
- Parameters:
data_dict (dict) – A circlify format dictionary.
data (pandas.DataFrame) – A pandas dataframe containing sample metadata.
levels (List[str]) – Specify the groupby columns for grouping the sample metadata.
size_column (str) – The name of the column that will be used for circle size.
name_column (str) – The name of the column that will be used for circle name.
- Returns:
A circlify format dictionary.
- Return type:
dict
Examples
>>> circ_dict = assign_size(circ_dict, sample_metadata, ["tissue", "disease"], size_column="cells", name_column="study")
- scimilarity.visualizations.assign_suffix(data_dict, data, levels, suffix_column, name_column)[source]#
Assigns circle name and suffix to a circlify format dictionary.
- Parameters:
data_dict (dict) – A circlify format dictionary.
data (pandas.DataFrame) – A pandas dataframe containing sample metadata.
levels (List[str]) – Specify the groupby columns for grouping the sample metadata.
suffix_column (str) – The name of the column that will be used for the circle name suffix.
name_column (str) – The name of the column that will be used for circle name.
- Returns:
A circlify format dictionary.
- Return type:
dict
Examples
>>> circ_dict = assign_suffix(circ_dict, sample_metadata, ["tissue", "disease"], suffix_column="cells", name_column="study")
- scimilarity.visualizations.circ_dict2data(circ_dict)[source]#
Convert a circlify format dictionary to the list format expected by circlify.
- Parameters:
data_dict (dict) – A circlify format dictionary
circ_dict (dict) –
- Returns:
A list of circle data.
- Return type:
List[dict]
Examples
>>> circ_data = circ_dict2data(circ_dict)
- scimilarity.visualizations.draw_circles(circ_data, title='', figsize=(10, 10), filename=None, use_colormap=None, use_suffix=None, use_suffix_as_color=False)[source]#
Draw the circlify plot.
- Parameters:
circ_data (List[dict]) – A circlify format list.
title (str, default: "") – The figure title.
figsize (Tuple[int, int], default: (10, 10)) – The figure size in inches.
filename (str, optional, default: None) – Filename to save the figure.
use_colormap (str, optional, default: None) – The colormap identifier.
use_suffix (dict, optional, default: None) – A mapping of suffix to color using a dictionary in the form {suffix: float}
use_suffix_as_color (bool, default: False) – Use the suffix as the color. This expects the suffix to be a float.
Examples
>>> draw_circles(circ_data)
- scimilarity.visualizations.get_children_data(data_dict)[source]#
Recursively get all children data for a given circle.
- Parameters:
data_dict (dict) – A circlify format dictionary
- Returns:
A list of children data.
- Return type:
List[dict]
Examples
>>> children = get_children_data(circ_dict[i]["children"])
- scimilarity.visualizations.hits_circles(metadata, levels=['tissue', 'disease'], figsize=(10, 10), filename=None)[source]#
Visualize sample metadata as circle plots for tissue and disease.
- Parameters:
metadata (pandas.DataFrame) – A pandas dataframe containing sample metadata for nearest neighbors with at least columns: [“study”, “cells”], that represent the number of circles and circle size respectively.
levels (list, default: ["tissue", "disease"]) – The columns to uses as group levels in the circles hierarchy.
figsize (Tuple[int, int], default: (10, 10)) – Figure size, width x height
filename (str, optional) – Filename to save the figure.
Examples
>>> hits_circles(metadata)
- scimilarity.visualizations.hits_heatmap(sample_metadata, x, y, count_type='cells', figsize=(10, 10), filename=None)[source]#
Visualize a list of sample metadata objects as a heatmap.
- Parameters:
sample_metadata (Dict[str, pandas.DataFrame]) – A dict where keys are cluster names and values are pandas dataframes containing sample metadata for each cluster centroid with columns: [“tissue”, “disease”, “study”, “sample”].
x (str) – x-axis label key. This corresponds to cluster name values.
y (str) – y-axis label key. This corresponds to the dataframe column to visualize.
count_type ({"cells", "fraction"}, default: "cells") – Count type to color in the heatmap.
figsize (Tuple[int, int], default: (10, 10)) – Figure size, width x height
filename (str, optional) – Filename to save the figure.
Examples
>>> hits_heatmap(sample_metadata, "time", "disease")