plot_correlation: Correlations among replicates/groups

Description Usage Arguments Value Examples

View source: R/plot_correlation.R

Description

Function to calculate correlations of ChIP/ATAC-seq enrichment among replicates/samples or groups. The function is compatible with the output of multiBigwig_summary or any custom data.frame with the similar format.

Usage

1
2
3
plot_correlation(enrichments_df, log_transform = TRUE,
  method = "pearson", plot_type = "replicate_level", sample_metadata,
  ...)

Arguments

enrichments_df

dataframe of enrichments, usually in the form of the output from function multiBigwig_summary, default NULL

log_transform

logical, whether to log2 transform enrichments_df

method

method to calculate correlation coefficient, one of 'pearson' (default), 'spearman' or 'kendall'

plot_type

whether to plot replicate_level correlations or group_level correlations. replicate_level plot represents the pairwise correlation values among all the samples/columns, where as the group_level plot is a paired plot of genomic regions after averaging of all samples in a group. Default replicate_level

sample_metadata

a data.frame required if plot_type = 'group_level'. The data.frame must contain columns sample_id and group

...

additional arguments either to corrplot::corrplot or GGally::ggpairs depending on arg plot_type

Value

corrplot or ggplot2 object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## load example data
## load example data

chr21_data_table <- system.file('extdata/bw', 'ALPS_example_datatable.txt', package = 'ALPS', mustWork = TRUE)

## attach path to bw_path and bed_path
d_path <- dirname(chr21_data_table)

chr21_data_table <- read.delim(chr21_data_table, header = TRUE)
chr21_data_table$bw_path <- paste0(d_path, '/', chr21_data_table$bw_path)
chr21_data_table$bed_path <- paste0(d_path, '/', chr21_data_table$bed_path)

enrichments <- multiBigwig_summary(data_table = chr21_data_table,
                                   summary_type = 'mean',
                                   parallel = TRUE)

## replicate_level correlation plot
plot_correlation(enrichments_df = enrichments,
log_transform = TRUE, plot_type = 'replicate_level',
sample_metadata = chr21_data_table)

## group_level correlation plot
plot_correlation(enrichments_df = enrichments,
log_transform = TRUE, plot_type = 'group_level',
sample_metadata = chr21_data_table)

ALPS documentation built on Nov. 8, 2020, 5:52 p.m.