pkgdown/extra.css

Skip to contents

create_corr_heatmap() calculates the correlation matrix of the input dataset. It creates a heatmap of the correlation matrix. It also filters the protein pairs with correlation values above the threshold and returns them in a tibble.

Usage

create_corr_heatmap(
  x,
  y = NULL,
  use = "pairwise.complete.obs",
  method = "pearson",
  threshold = 0.8,
  cluster_rows = TRUE,
  cluster_cols = TRUE,
  show_heatmap = TRUE
)

Arguments

x

A numeric vector, matrix or data frame.

y

A numeric vector, matrix or data frame with compatible dimensions with x. Default is NULL.

use

A character string. The method to use for computing correlations. Default is "pairwise.complete.obs".

method

A character string. The correlation method to use. Default is "pearson".

threshold

The reporting protein-protein correlation threshold. Default is 0.8.

cluster_rows

Whether to cluster the rows. Default is TRUE.

cluster_cols

Whether to cluster the columns. Default is TRUE.

show_heatmap

Whether to show the heatmap. Default is TRUE.

Value

A list containing the following elements:

  • cor_matrix: A matrix of protein-protein correlations.

  • cor_results: A tibble with the filtered protein pairs and their correlation values.

  • cor_plot: A heatmap of protein-protein correlations.

Examples

# Prepare data
df <- example_data |>
  dplyr::select(DAid, Assay, NPX) |>
  tidyr::pivot_wider(names_from = "Assay", values_from = "NPX") |>
  dplyr::select(-DAid)

# Correlate proteins
results <- create_corr_heatmap(df, threshold = 0.7)

# Print results
results$cor_plot  # Heatmap of protein-protein correlations


results$cor_matrix[1:5, 1:5]  # Subset of the correlation matrix
#>        AARSD1  ABL1 ACAA1  ACAN ACE2
#> AARSD1   1.00  0.47  0.19 -0.06 0.04
#> ABL1     0.47  1.00  0.46 -0.01 0.13
#> ACAA1    0.19  0.46  1.00  0.03 0.32
#> ACAN    -0.06 -0.01  0.03  1.00 0.07
#> ACE2     0.04  0.13  0.32  0.07 1.00

results$cor_results  # Filtered protein pairs exceeding correlation threshold
#>   Protein1 Protein2 Correlation
#> 1  ATP5IF1    AIFM1        0.76
#> 2    AXIN1 ARHGEF12        0.76
#> 3    AIFM1  ATP5IF1        0.76
#> 4 ARHGEF12    AXIN1        0.76
#> 5 ARHGEF12    AIFM1        0.71
#> 6    AIFM1 ARHGEF12        0.71