corrPairsMSI: Calculate correlations of pairs of mass peaks from MSI data

Description Usage Arguments Details Value See Also Examples

View source: R/corrPairsMSI.R

Description

Calculate correlations of pairs of mass peaks from MSI data (imported to R with the msimat function). The list of pairs is supplied as a data.frame with the parameter pairs.

Usage

1
2
3
corrPairsMSI(d, diff, p.val = 0.05, method = c("pearson", "kendall",
  "spearman"), alternative = c("two.sided", "less", "greater"),
  how = c("apply", "parallel", "loop"), ncores = NULL, ...)

Arguments

d

msimat; MSI data with peaks as columns and pixels as rows, output from msimat function

diff

massdiff; List of mass differences, parent and putative adduct ions, as produced by function massdiff

p.val

numeric; p-value cutoff (before Bonferroni correction) (default: 0.05)

method

string; Method to use for cor.test (default: "pearson")

alternative

string; Which alternative for cor.test (default: "greater")

how

string; How to implement the multiple correlation tests. Options: "loop" (for loop - slow), "parallel" (multiple processors, using mclapply from package parallel), or "apply" (vectorized lapply function - default). Option "parallel" uses forking processes and is therefore not suitable for Windows systems.

ncores

integer; Number of cores if using how="parallel". Default is total number of cores minus one.

...

Other parameters to pass to cor.test

Details

Example usage scenario for this function: Mass differences for all pairwise combinations of masses are tabulated with massdiff, and the peak pairs corresponding to a specific adduct of interest are extracted with diffGetPeaks. Check which peaks are significantly correlated to each other with this function.

Correlation is calculated with cor.test function and by default uses the Pearson method (two-sided, because correlations can be both positive and negative). The Bonferroni correction is applied to the p-values before assessing significance, but the original p-value is reported in column "P.value" and can be used e.g. for false discovery rate analysis.

Value

Object of class data.frame with the following fields:

A - First peak mass in each pair

B - Second peak mass in the pair

Estimate - Estimated correlation

P.value - P-value for the correlation (uncorrected)

Significance - Whether p-value meets cutoff (specified by "p.val", with Bonferroni correction)

See Also

corrPairsMSIchunks to split input data into manageable sizes to avoid going over available memory. Suggested if using the standard corrPairsMSI function causes R to run out of memory and crash.

Examples

1
2
3
4
5
d <- msimat(csv=system.file("extdata","msi.csv",package="mass2adduct"),sep=";")
d.diff <- massdiff(d) # Calculate mass differences from imported MSI data
d.diff.annot <- adductMatch(d.diff,add=adducts2) # Find mass diffs matching adducts
# Perform correlation tests on annotated peak pairs
d.diff.annot.cor <- corrPairsMSI(d,d.diff.annot,how="apply")

kbseah/mass2adduct documentation built on June 9, 2021, 9:20 p.m.