calc_cor: Correlation between Sample Counts of 'AnyHermesData'

correlate,AnyHermesData-methodR Documentation

Correlation between Sample Counts of AnyHermesData

Description

[Experimental]

The correlate() method can calculate the correlation matrix between the sample vectors of counts from a specified assay. This produces a HermesDataCor object, which is an extension of a matrix with additional quality flags in the slot flag_data (containing the tech_failure_flag and low_depth_flag columns describing the original input samples).

An autoplot() method then afterwards can produce the corresponding heatmap.

Usage

## S4 method for signature 'AnyHermesData'
correlate(object, assay_name = "counts", method = "pearson", ...)

## S4 method for signature 'HermesDataCor'
autoplot(
  object,
  flag_colors = c(`FALSE` = "green", `TRUE` = "red"),
  cor_colors = circlize::colorRamp2(c(0, 0.5, 1), c("red", "yellow", "green")),
  ...
)

Arguments

object

(AnyHermesData)
object to calculate the correlation.

assay_name

(string)
the name of the assay to use.

method

(string)
the correlation method, see stats::cor() for details.

...

other arguments to be passed to ComplexHeatmap::Heatmap().

flag_colors

(named character)
a vector that specifies the colors for TRUE and FALSE flag values.

cor_colors

(function)
color scale function for the correlation values in the heatmap, produced by circlize::colorRamp2().

Value

A HermesDataCor object.

Functions

  • autoplot(HermesDataCor): This autoplot() method uses the ComplexHeatmap::Heatmap() function to plot the correlations between samples saved in a HermesDataCor object.

Examples

object <- hermes_data

# Calculate the sample correlation matrix.
correlate(object)

# We can specify another correlation coefficient to be calculated.
result <- correlate(object, method = "spearman")

# Plot the correlation matrix.
autoplot(result)

# We can customize the heatmap.
autoplot(result, show_column_names = FALSE, show_row_names = FALSE)

# Including changing the axis label text size.
autoplot(
  result,
  row_names_gp = grid::gpar(fontsize = 8),
  column_names_gp = grid::gpar(fontsize = 8)
)

insightsengineering/hermes documentation built on July 17, 2024, 1:01 p.m.