| corbetw2mat | R Documentation |
For matrices x and y, calculate the correlation between columns of x and columns of y.
corbetw2mat(
x,
y,
what = c("paired", "bestright", "bestpairs", "all"),
corthresh = 0.9
)
x |
A numeric matrix. |
y |
A numeric matrix with the same number of rows as |
what |
Indicates which correlations to calculate and return. See value, below. |
corthresh |
Threshold on correlations if |
Missing values (NA) are ignored, and we calculate the correlation
using all complete pairs, as in stats::cor() with
use="pairwise.complete.obs".
If what="paired", the return value is a vector of
correlations, between columns of x and the corresponding column of
y. x and y must have the same number of columns.
If what="bestright", we return a data frame of size ncol(x) by
3, with the ith row being the maximum correlation between
column i of x and a column of y, and then the
y-column index and y-column name with that correlation. (In
case of ties, we give the first one.)
If what="bestpairs", we return a data frame with five columns,
containing all pairs of columns (with one in x and one in y)
with correlation \ge corthresh. Each row corresponds to a
column pair, and contains the correlation and then the x- and
y-column indices followed by the x- and y-column names.
If what="all", the output is a matrix of size ncol(x) by
ncol(y), with all correlations between columns of x and
columns of y.
Karl W Broman, broman@wisc.edu
distee(), findCommonID()
data(expr1, expr2)
# correlations with paired columns
r <- corbetw2mat(expr1, expr2)
# top 10, by absolute value
r[order(abs(r), decreasing=TRUE)[1:10]]
# all pairs of columns with correlation >= 0.8
r_allpairs <- corbetw2mat(expr1, expr2, what="bestpairs", corthresh=0.6)
# for each column in left matrix, most-correlated column in right matrix
r_bestright <- corbetw2mat(expr1, expr2, what="bestright")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.