Description Usage Arguments Details Value References See Also Examples
cormap2()
generates pair-wise correlations from an input ExpressionSet object, a data.frame
or a
numerical matrix
. With the default options it also produces a heatmap.
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 26 27 | cormap2(
x,
cormat = NULL,
lab = NULL,
convert = TRUE,
biomart = FALSE,
cluster_correlations = TRUE,
main = "",
postfix = NULL,
cex = NULL,
na.frac = 0.1,
cor.cluster = 1,
cor.window = NULL,
cor.thr = NULL,
cor.mar = 0.5,
cut.thr = NULL,
cut.size = 5,
autoadj = TRUE,
labelheight = NULL,
labelwidth = NULL,
add.sig = FALSE,
genes2highl = NULL,
order.list = TRUE,
doPlot = TRUE,
updateProgress = NULL,
verbose = FALSE
)
|
x |
( |
cormat |
( |
lab |
( |
convert |
( |
biomart |
( |
cluster_correlations |
( |
main |
( |
postfix |
( |
cex |
( |
na.frac |
( |
cor.cluster |
( |
cor.window |
( |
cor.thr |
( |
cor.mar |
( |
cut.thr |
( |
cut.size |
( |
autoadj |
( |
labelheight |
( |
labelwidth |
( |
add.sig |
( |
genes2highl |
( |
order.list |
( |
doPlot |
( |
updateProgress |
( |
verbose |
( |
P-Values are calculated from the t-test value of the correlation coefficient: t = r x sqrt(n-2) / sqrt(1-r^2),
where r is the correlation coefficient, n is the number of samples with no missing values for each gene (row-wise
ncol(eset)
minus the number of columns that have an NA). P-Values are the calculated using pt
and
corrected account for the two-tailed nature of the test, i.e., the possibility of positive as well as negative correlation.
The approach to calculate correlation significance was adopted from Miles, J., & Banyard, P. (2007) on
"Calculating the exact significance of a Pearson correlation in MS Excel".
The asterisks encode significance as follows:
P < 0.05: * | |
P < 0.01: ** | |
P < 0.001: *** | |
The label measures (labelheight
, labelwidth
and cex
) are adjusted automatically by default
with argument autoadj=TRUE
and have default values which are hard coded into the helper function
heatmap.cor
. The values calculated by the helper function plotAdjust
can be overridden by setting
any of those arguments to a valid numeric
or lcm(numeric)
value.
Invisibly returns the correlation matrix, though the function is mainly called for its side-effect of producing
a heatmap (if doPlot = TRUE
which is the default).
Miles, J., & Banyard, P. (2007). Understanding and using statistics in psychology: A practical introduction. Sage Publications Ltd. https://psycnet.apa.org/record/2007-06525-000.
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 26 27 28 29 30 | # 1. Generate a random 10x10 matrix with two distinct sets and plot it with
# default settings without ID conversion since the IDs are made up:
set.seed(1234)
mat <- matrix(c(rnorm(100, mean = 1), rnorm(100, mean = -1)), nrow = 20)
rownames(mat) <- paste0("gene-", 1:20)
colnames(mat) <- paste0(c("A", "B"), rep(1:5, 2))
cormap2(mat, convert=FALSE, main="Random matrix")
# 2. Use a real-world dataset from TCGA (see README file in inst/extdata directory).
# Package 'convertid' is used to convert Ensembl Gene IDs to HGNC Symbols
## Read data and prepare input data frame
fl <- system.file("extdata", "PrCaTCGASample.txt", package = "coreheat", mustWork = TRUE)
dat0 <- read.delim(fl, stringsAsFactors=FALSE)
dat1 <- data.frame(dat0[, grep("TCGA", names(dat0))], row.names=dat0$ensembl_gene_id)
cormap2(dat1, main="TCGA data frame + ID conversion")
# 3. Use separately supplied IDs with a matrix created from the data frame of the
# previous example and highlight genes of interest
dat2 <- as.matrix(dat0[, grep("TCGA", names(dat0))])
sym <- dat0$hgnc_symbol
cormap2(dat1, convert=FALSE, lab=sym, genes2highl=c("GNAS","NCOR1","AR", "ATM"),
main="TCGA matrix + custom labels")
# 4. Use an ExpressionSet object and add significance asterisks
## For simplicity reasons we create the ExpressionSet from a matrix created
## from the data frame in the second example
expr <- Biobase::ExpressionSet(as.matrix(dat1))
cormap2(expr, add.sig=TRUE, main="TCGA ExpressionSet object + ID conversion")
# More examples can be found in the vignette.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.