tacco.plots.contribution¶
- contribution(adata, value_key, group_key, sample_key=None, basis_adata=None, basis_value_key=None, basis_group_key=None, basis_sample_key=None, fillna=None, restrict_groups=None, restrict_values=None, basis_restrict_groups=None, basis_restrict_values=None, reduction='sum', normalization='gmean', assume_counts=None, reads=False, colors=None, axsize=None, log=True, ax=None)[source]¶
Plot contribution to groups. In contrast to
composition()
, contributions dont 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.
sample_key – The .obs key with categorical sample information. If None, only the aggregated data is plotted. Otherwise the data is aggregated per sample and total and per-sample values are plotted.
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.
basis_sample_key – The .obs key with categorical sample information for basis_adata. If None, sample_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.
reduction –
The reduction to apply on each (group,sample) subset of the data. Possible values are:
’sum’: sum of the values over observations
’mean’: mean of the values over observations
’median’: median of the values over observations
a callable mapping a
DataFrame
to its reduced counterpart
normalization –
The normalization to apply on each reduced (group,sample) subset of the data. Possible values are:
’sum’: normalize values by their sum (yields fractions)
’percent’: like ‘sum’ scaled by 100 (yields percentages)
’gmean’: normalize values by their geometric mean (yields contributions which make more sense for enrichments than fractions, due to zero-sum issue; see
enrichments()
)’clr’: “Center logratio transform”; like ‘gmean’ with additional log transform; makes the distribution more normal and better suited for t tests
None: no normalization
a value name from value_key: all values are normalized to this contribution
a callable mapping a
DataFrame
to its normalized counterpart
assume_counts – Ony relevant for normalization==’gmean’ and normalization==’clr’; whether to regularize zeros by adding a pseudo count of 1 or by replacing them by 1e-3 of the minimum value. If None, check whether the data are consistent with count data and assume counts accordingly, except if reads==True, then also assume_counts==True.
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.
axsize – Tuple of width and size of a single axis. If None, use automatic values.
log – Whether to plot on the log scale.
ax – The
Axes
to plot on. If None, creates a fresh figure for plotting.
- Returns:
A
Figure
if ax is None, else None.