tacco.plots.co_occurrence

co_occurrence(adata, analysis_key, score_key='log_occ', log_base=None, colors=None, show_only=None, show_only_center=None, axsize=(4, 3), sharex=True, sharey='col', wspace=0.15, hspace=0.3, legend=True, grid=True, merged=False, ax=None)[source]

Plot co-occurrence as determined by co_occurrence().

Parameters:
  • adata – An AnnData with the co-occurence analysis in .uns. Can also be a mapping of labels to AnnData to specify multiple datasets.

  • analysis_key – The .uns key with the co-occurence analysis result.

  • score_key

    The .uns[analysis_key] key of the score to use or the .uns[analysis_key][‘comparisons’] sub-key specifying the comparison to plot. Available keys .uns[analysis_key] include:

    • ’occ’: co-occurrence

    • ’log_occ’: logarithm of the co-occurrence

    • ’log2_occ’: base-2-logarithm of the co-occurrence; this is a not a real key but a convenience function to rescale the ‘log_occ’ values

    • ’z’: z-score of the log of the neighbourship counts with respect to random neighbourships

    • ’composition’: distance dependent composition, p(anno|center, dist)

    • ’log_composition’: log of ‘composition’

    • ’distance_distribution’: distribution of distances between anno and center ´p(dist|anno,center)´

    • ’log_distance_distribution’: log of ‘distance_distribution’

    • ’relative_distance_distribution’: ‘distance_distribution’ normalized to p(dist|*,center), the distance distribution of any annotation to the center

    • ’log_relative_distance_distribution’: log of ‘relative_distance_distribution’

  • log_base – The base of the logarithm to use for plotting if score_key is ‘log_occ’ or a comparison key. If None, use the natural logarithm.

  • colors – The mapping of value names to colors. If None, a set of standard colors is used.

  • show_only – A subset of annotation values to restrict the plotting to.

  • show_only_center – A subset of the center annotation values to restrict the plotting to.

  • axsize – Tuple of width and size of a single axis.

  • sharex – Whether and how to use common x/y axis. Options include True, False, “col”, “row”, “none”, and “all”.

  • sharey – Whether and how to use common x/y axis. Options include True, False, “col”, “row”, “none”, and “all”.

  • wspace – Control the spacing between the plots.

  • hspace – Control the spacing between the plots.

  • legend – Whether to include the legend

  • grid – Whether to plot a grid

  • merged – Whether to merge the plots for all AnnData instances into a single row of plots. This makes only sense if more instances are provided in adata.

  • ax – The Axes to plot on. If None, creates a fresh figure for plotting.

Returns:

A Figure.