hucira.plot_communication#
- hucira.plot_communication(df_src, df_tgt, frac_expressing_cells_sender=0.05, frac_expressing_cells_receiver=0.05, mean_cytokine_gene_expression_sender=None, mean_cytokine_gene_expression_receiver=None, df_enrichment=None, all_celltypes=None, cytokine2color=None, celltype2color=None, figsize=(5, 5), show_legend=True, save_path=None, lw=1.0, fontsize=6, loc='upper left', bbox_to_anchor=(1, 1))#
Generate a Circos plot of cytokine-mediated cell-cell communication.
Filters the input DataFrames based on thresholds for fraction of expressing cells and mean cytokine gene expression, then creates a circular layout with cell-type partitions and draws directed links representing cytokine communication between producers and receivers.
- Parameters:
df_src (pandas.DataFrame) – Producer cell-type cytokine expression statistics from
get_all_senders_and_receivers(). Must have"celltype","cytokine","mean_X", and"frac_X"columns.df_tgt (pandas.DataFrame) – Receiver cell-type cytokine expression statistics from
get_all_senders_and_receivers(). Must have"celltype","cytokine","mean_X", and"frac_X"columns.frac_expressing_cells_sender (float or None) – Minimum fraction of cells expressing the cytokine gene for a producer cell type. If None, no filtering is applied.
frac_expressing_cells_receiver (float or None) – Minimum fraction of cells expressing the cytokine gene for a receiver cell type. If None, no filtering is applied.
mean_cytokine_gene_expression_sender (float or None) – Minimum mean expression for a producer cell type. If None, no filtering is applied.
mean_cytokine_gene_expression_receiver (float or None) – Minimum mean expression for a receiver cell type. If None, no filtering is applied.
df_enrichment (pandas.DataFrame or None) – Optional DataFrame with enrichment information to filter links.
all_celltypes (list of str or None) – List of all cell types. If None, inferred from df_src and df_tgt.
cytokine2color (dict or None) – Mapping from cytokine names to colors.
celltype2color (dict or None) – Mapping from cell-type names to colors.
show_legend (bool) – Whether to show the legend.
save_path (str or None) – Path to save the figure. If None, figure is not saved.
lw (float) – Line width for links.
fontsize (int) – Font size for labels.
loc (str) – Legend location.
bbox_to_anchor (tuple of (float, float)) – Bounding box anchor for the legend.
- Return type:
- Returns:
- -legend_handles (
list) Matplotlib line handles for the legend.
- legend_labelslist of str
Cytokine names corresponding to each legend handle.
- -legend_handles (