tacco.plots.compositions

compositions(adata, value_key, group_key, basis_adata=None, basis_value_key=None, basis_group_key=None, fillna=None, restrict_groups=None, restrict_values=None, basis_restrict_groups=None, basis_restrict_values=None, reads=False, colors=None, horizontal=False, axsize=None, ax=None, legend=True)[source]

Plot compositions of groups. In contrast to contribution(), compositions have to add up to one.

Parameters:
  • adata – An AnnData with annotation in .obs.

  • value_key – The .obs or .obsm key with the values to determine the enrichment for.

  • group_key – The .obs key with categorical group information.

  • basis_adata – Another AnnData with annotation in .obs to compare. If None, only the adata composition is shown.

  • basis_value_key – The .obs or .obsm key for basis_adata with the values to determine the enrichment for. If None, value_key is used.

  • basis_group_key – The .obs key with categorical group information for basis_adata. If None, value_key is used.

  • fillna – If None, observation containing NA in the values are filtered. Else, NA values are replaced with this value.

  • restrict_groups – A list-like containing the groups within which the enrichment analysis is to be done. If None, all groups are included.

  • restrict_values – A list-like containing the values within which the enrichment analysis is to be done. If None, all values are included. Works only for categorical values.

  • basis_restrict_groups – Like restrict_groups but for basis_adata.

  • basis_restrict_values – Like restrict_values but for basis_adata.

  • reads – Whether to weight the values by the total count per observation

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

  • horizontal – Whether to plot the bar plot horizontally.

  • axsize – Tuple of width and size of a single axis. If None, use automatic values.

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

  • legend – Whether to include the legend

Returns:

A Figure if ax is None, else None.