Create a heatmap reporting standardized residuals from chi-square test between two variables of interest

ResidualPlot(
  seurat = NULL,
  var.1 = NULL,
  var.2 = NULL,
  limits = c(-20, 20),
  pval = T,
  perm = 1000,
  padj.thresh = 0.01,
  alternative = c("two.sided", "less", "greater"),
  return.df = F
)

Arguments

seurat

a Seurat object containing Kandinsky data

var.1

character string, name of the first variable

var.2

character string, name of the second variable

limits

lower and upper residual caps for heatmap colour gradient

pval

boolean, whether returning heatmap with cells annotated for significance or not (based on normal distribution fitting)

perm

numeric, number of var.1 and var.2 reshuffling to estimate enrichment pvalue between var.1 and var.2 via permutation test. Default is set to 1000

padj.thresh

numeric, adjusted pvalue threshold to define significant var.1/var.2 chisquare residuals. Default value is set to 0.01

alternative

character string specifying the alternative hypothesis, must be one of "two.sided", "greater" (default) or "less".

return.df

boolean, whether returning only residual plot (FALSE) or also a dataframe containing permutation-based chi-squared test results

Value

residual heatmap created with ggplot2