corr.matrix {brainGraph} | R Documentation |
Calculate correlation matrix and threshold
Description
corr.matrix
calculates the correlation between all column pairs of a
given data frame, and thresholds the resultant correlation matrix based on a
given density (e.g., 0.1
if you want to keep only the 10% strongest
correlations). If you want to threshold by a specific correlation coefficient
(via the thresholds
argument), then the densities
argument is
ignored.
The plot
method will plot “heat maps” of the correlation
matrices.
Usage
corr.matrix(resids, densities, thresholds = NULL, what = c("resids",
"raw"), exclude.reg = NULL, type = c("pearson", "spearman"),
rand = FALSE)
## S3 method for class 'corr_mats'
x[i, g = NULL]
## S3 method for class 'corr_mats'
plot(x, mat.type = c("thresholded", "raw"),
thresh.num = 1L, ordered = TRUE, order.by = "lobe",
graphs = NULL, grp.names = NULL, legend.title = NULL, ...)
## S3 method for class 'corr_mats'
region.names(object)
## S3 method for class 'corr_mats'
nregions(object)
Arguments
resids |
An object of class |
densities |
Numeric vector indicating the resultant network densities; keeps the top X% of correlations |
thresholds |
Numeric; absolute correlation value to threshold by
(default: |
what |
Character string indicating whether to correlate the residuals or
the raw structural MRI values (default: |
exclude.reg |
Character vector of regions to exclude (default:
|
type |
Character string indicating which type of correlation coefficient
to calculate (default: |
rand |
Logical indicating whether the function is being called for
permutation testing; not intended for general use (default: |
x , object |
A |
i |
Integer for subsetting by density/threshold |
g |
Integer, character, or logical for subsetting by group |
mat.type |
Character string indicating whether to plot raw or thresholded
(binarized) matrices. Default: |
thresh.num |
Integer specifying which threshold to plot (if
|
ordered |
Logical indicating whether to order the vertices by some
grouping. Default: |
order.by |
Character string indicating how to group vertices. Default:
|
graphs |
A |
grp.names |
Character vector specifying the names of each group of
vertices. Default: |
legend.title |
Character string for the legend title. Default is to leave blank |
... |
Unused |
Details
If you wish to exclude regions from your analysis, you can give the indices
of their columns with the exclude.reg
argument.
By default, the Pearson correlation coefficients are calculated, but you can
return Spearman by changing the type
argument.
Value
A corr_mats
object containing the following components:
R , P |
Numeric arrays of correlation coefficients and P-values. The length of the 3rd dimension equals the number of groups |
r.thresh |
A list of 3-d binary arrays indicating correlations that are above a certain threshold. The length of the list equals the number of groups, and the length of the 3rd dimension equals the number of thresholds/densities. |
thresholds |
Numeric matrix of the thresholds supplied. The number of columns equals the number of groups. |
what |
Residuals or raw values |
exclude.reg |
Excluded regions (if any) |
type |
Pearson or Spearman |
atlas |
The brain atlas used |
densities |
Numeric vector; the densities of the resulting graphs, if you chose to threshold each group to have equal densities. |
Plotting correlation matrices
There are several ways to control the plot appearance. First, you may plot
the “raw” correlations, or only those of the thresholded (binarized)
matrices. Second, you may order the vertices by a given vertex attribute; by
default, they will be ordered by lobe, but you may also choose to
order by, e.g., network (for the dosenbach160
atlas) or by
community membership. In the latter case, you need to pass a
brainGraphList
object to the graphs
argument; each graph in the
object must have a vertex attribute specified in order.by
. Finally,
you can control the legend text with grp.names
.
Author(s)
Christopher G. Watson, cgwatson@bu.edu
See Also
Other Structural covariance network functions: Bootstrapping
,
IndividualContributions
,
Residuals
,
brainGraph_permute
,
import_scn
, plot_volumetric
Examples
## Not run:
myResids <- get.resid(lhrh, covars)
corrs <- corr.matrix(myResids, densities=densities)))
## End(Not run)
## Not run:
corrs <- corr.matrix(myResids, densities)
plot(corrs, order.by='comm', graphs=g.list, grp.names='Community')
## End(Not run)