campa.pl.get_intensity_change

get_intensity_change(adata, groupby, marker_dict=None, limit_to_groups=None, reference=None, reference_group=None, color='logfoldchange', size='mean_reference', group_sizes_barplot=None, pval='ttest', alpha=0.05, norm_by_group=None)[source]

Get data for plotting intensity comparison with plot_intensity_change().

Calculate mean intensity differences between perturbations or clusters. If no reference is given, use all other groups (except the current one) as reference. Colours show log2-foldchange / mean intensity changes / z-score changes, depending on the color argument. Dot size shows mean intensity of reference group that is compared to, or indicates the p-value, depending on the size argument.

Parameters
  • adata (AnnData) – Adata containing aggregated information by clusters. E.g. result of FeatureExtractor.get_intensity_adata().

  • groupby (str) – column in adata.obs containing the groups to compare.

  • marker_dict (Union[Mapping[str, Iterable[str]], Iterable[str], None]) – Limit/group vars that are shown, either by passing list or dict (adds annotations to plot).

  • limit_to_groups (Optional[Mapping[str, Union[str, List[str]]]]) – Dict with obs as keys and groups from obs as values, to subset adata before plotting.

  • reference (Union[List[str], str, None]) – Reference cluster/perturbation to compare to. If not defined, will compare each value in groupby against the rest.

  • reference_group (Optional[str]) – Obs entry that contains reference grouping (by default, groupby is used).

  • color (str) – Colour of dots, either logfoldchange or meanchange.

  • size (str) – sizes of dots, either mean_reference or pval (distinguish significant and non-significant dots).

  • group_sizes_barplot (Optional[str]) – Mean size of groups shown as a bar plot to the right. Either None (do not show), mean (mean size of groups), meanchange (mean difference of group size from reference), foldchange.

  • pval (str) – Type of test done to determine p-values. Either ttest or mixed_model. mixed_model calculates a mixed model using wells as random effects and should be preferred. Note that when using norm_by_group, the mixed model will be calculated on the normalised values, which differs from the model used in the original publication.

  • alpha (float) – pval threshold above which dots are not shown

  • norm_by_group (Optional[str]) – Divide all mean values by the mean values of this group. This is done separately for the reference and the values to compare to.

Returns

data to input to plot_intensity_change().

Return type

Mapping[str, Any]