Identify covariates that significantly, as defined by a false discovery rate (FDR) threshold, correlate with PCs computed from gene counts. This function wraps `plot_pcs_with_covariates()` to return a heatmap to visualize this relationship.

correlate_and_plot(
  principal_components,
  clean_metadata,
  correlation_type,
  weights = NULL,
  to_plot = FALSE,
  exclude_missing_data = NULL,
  maximum_fdr = 0.1
)

Arguments

principal_components

Center, scaled and rotated principal components matrix.

clean_metadata

A data frame with sample identifiers as rownames and variables as factors or numeric as determined by "sageseqr::clean_covariates()".

correlation_type

Allowed values are "pearson", "spearman" and "kendall". See "psych::corr.test(method)".

weights

A numeric vector of the proportion of variance explained (PVE). Defaults to NULL.

to_plot

Logical indicating whether correlation values should be plotted. Defaults to FALSE.

exclude_missing_data

A vector with column names to exclude from `clean_metadata`.

maximum_fdr

Maximum allowable false discovery rate (FDR). Defaults to 0.1.

Value

A list.

  • plot - A customized heatmap of significant covariates and PCs correlated.

  • significant_covariates - A vector of covariates where correlation p-value meets the FDR threshold.

  • effects_significant_vars - A vector correlation values.