getExperimentCrossCorrelation {mia}R Documentation

Calculate cross-correlation

Description

Calculate cross-correlation

Usage

getExperimentCrossCorrelation(x, ...)

## S4 method for signature 'MultiAssayExperiment'
getExperimentCrossCorrelation(
  x,
  experiment1 = 1,
  experiment2 = 2,
  abund_values1 = "counts",
  abund_values2 = "counts",
  method = c("spearman", "categorical", "kendall", "pearson"),
  mode = "table",
  p_adj_method = c("fdr", "BH", "bonferroni", "BY", "hochberg", "holm", "hommel",
    "none"),
  p_adj_threshold = 0.05,
  cor_threshold = NULL,
  sort = FALSE,
  filter_self_correlations = FALSE,
  verbose = TRUE,
  ...
)

## S4 method for signature 'SummarizedExperiment'
getExperimentCrossCorrelation(x, experiment2 = x, ...)

testForExperimentCrossCorrelation(x, ...)

## S4 method for signature 'ANY'
testForExperimentCrossCorrelation(x, ...)

Arguments

x

A MultiAssayExperiment or SummarizedExperiment object.

...

Additional arguments:

  • test_significanceA single boolean value in function getExperimentCrossCorrelation for selecting whether to test significance or not. (By default: test_significance = FALSE)

experiment1

A single character or numeric value for selecting the experiment 1 from experiments(x) of MultiassayExperiment object. (By default: experiment1 = 1)

experiment2

A single character or numeric value for selecting the experiment 2 fromexperiments(x) of MultiAssayExperiment object or altExp(x) of SummarizedExperiment object. Alternatively, experiment2 can also be SE object when x is SE object. (By default: experiment2 = 2 when x is MAE and experiment2 = x when x is SE)

abund_values1

A single character value for selecting the assay of experiment 1 to be transformed. (By default: abund_values1 = "counts")

abund_values2

A single character value for selecting the assay of experiment 2 to be transformed. (By default: abund_values2 = "counts")

method

A single character value for selecting association method ('kendall', pearson', or 'spearman' for continuous/numeric; 'categorical' for discrete) (By default: method = "spearman")

mode

A single character value for selecting output format Available formats are 'table' and 'matrix'. (By default: mode = "table")

p_adj_method

A single character value for selecting adjustment method of p-values. Passed to p.adjust function. (By default: p_adj_method = "fdr")

p_adj_threshold

A single numeric value (from 0 to 1) for selecting adjusted p-value threshold. (By default: p_adj_threshold = 0.05)

cor_threshold

A single numeric absolute value (from 0 to 1]) for selecting correlation threshold to include features. (By default: cor_threshold = NULL)

sort

A single boolean value for selecting whether to sort features or not in result matrices. Used method is hierarchical clustering. Disabled when mode = "table". (By default: sort = FALSE)

filter_self_correlations

A single boolean value for selecting whether to filter out correlations between identical items. Applies only when correlation between experiment itself is tested, i.e., when assays are identical. (By default: filter_self_correlations = FALSE)

verbose

A single boolean value for selecting whether to get messages about progress of calculation.

Details

These functions calculates associations between features of two experiments. getExperimentCrossCorrelation calculates only associations by default. testForExperimentCrossCorrelation calculates also significance of associations.

Value

These functions return associations in table or matrix format. In table format, returned value is a data frame that includes features and associations (and p-values) in columns. In matrix format, returned value is a one matrix when only associations are calculated. If also significances are tested, then returned value is a list of matrices.

Author(s)

Leo Lahti and Tuomas Borman. Contact: microbiome.github.io

Examples

mae <- microbiomeDataSets::peerj32()

# Subset so that less observations / quicker to run, just for example
mae[[1]] <- mae[[1]][1:20, 1:10]
mae[[2]] <- mae[[2]][1:20, 1:10]
# Calculate cross-correlations
result <- getExperimentCrossCorrelation(mae, method = "pearson")
# Show first 5 entries
head(result, 5)

# Same can be done with SummarizedExperiment and altExp
# Create TreeSE with altExp
tse <- mae[[1]]
altExp(tse, "exp2") <- mae[[2]]
# Whe mode = matrix, matrix is returned
result <- getExperimentCrossCorrelation(tse,
                                        experiment2 = "exp2",
                                        method = "pearson", 
                                        mode = "matrix")
# Show first 5 entries
head(result, 5)

# testForExperimentCorrelation returns also significances
# filter_self_correlations = TRUE filters self correlations
result <- testForExperimentCrossCorrelation(tse,
                                            experiment2 = tse,
                                            method = "pearson",
                                            filter_self_correlations = TRUE)
# Show first 5 entries
head(result, 5)

# Also getExperimentCrossCorrelation returns significances when 
# test_signicance = TRUE
result <- getExperimentCrossCorrelation(mae[[1]],
                                        experiment2 = mae[[2]],
                                        method = "pearson",
                                        mode = "matrix",
                                        test_significance = TRUE)
# Returned value is a list of matrices
names(result)

[Package mia version 1.2.7 Index]