Tutorial:CorLevelPlot - Visualise correlation results, e.g., clinical parameter correlations
0
8
Entering edit mode
4.4 years ago

Similar to how corrplot does it, but also different.

## -------------------------------------------------

Major update September 10, 2018:

All code is now on GitHub with a vignette, and installatioin is streamlined: https://github.com/kevinblighe/CorLevelPlot

To install (R):

devtools::install_github("kevinblighe/CorLevelPlot")
library(CorLevelPlot)


Practical examples in Vignette:

Kevin

levlelplot correlation Tutorial • 2.1k views
0
Entering edit mode

Dear Kevin,

it looks a great and very useful function for visualizing and testing important putative correlations among multilayered data. Three important questions on the implementation (and please excuse me for any naive questions on this matter):

1) Regarding the type of variables that one can include in the df object, and in the x and y vectors respectively:

For example,

data("iris")
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa


if i have a relative data frame, with specific gene expressions in the columns as variables-like the Sepal Length from iris,regarding samples belonging in a specific cluster as you illustrated in the figure above-as also other clinical non-continuous variables, such as Tumor Grade, etc-like Species above:

i can still implement your function to compute putative associations of these continuous variables with any of the categorical ones? or my notion/approach is incorrect ?

2) If my approach is feasible, for a correct implementation, i should provide the names of the continuous variables in the x vector, and the names of the categorical ones in the y vector ?

3) Finally, a question concerning NA values: because in some of these categorical variables, like the following:

plyr::count(coad.exp$subtype_expression_subtype) x freq 1 CIN 55 2 Invasive 36 3 MSI/CIMP 58 4 NA 49 5 <NA> 258  which in this case, has both NA values, as also "NA" character strings in this categorical variable-i could still use the function, and it will utilize only the above levels like CIN, Invasive and MSI/CIMP ? Thank you in advance, Efstathios ADD REPLY 1 Entering edit mode Hi Efstathios, 1) Yes, categorical variables will be converted into ordered numerical factors (1, 2, 3, 4, etc), with the number 1 as the base / reference level. Thus, if you have factors, you may want to 'relevel' them prior to running this function. 2) Yes, that is the correct form to do it 3) If there is a NA vale, then the entire record will be removed due to the presence of the following parameter passed to cor.test in my function: cor.test(..., use="pairwise.complete.obs", ...) Kind regards, Kevin ADD REPLY 0 Entering edit mode Thanks Kevin for the confirmation and your suggestions !!! Just two extra important comments on this matter : 1) Conserning my first question of the categorical variables: because in some cases, for instance regardless of Tumor Stage which can be releveled (T1,T2 etc), some variables, like the subtype_expression_subtype i mentioned above, does not have a reference level-this is also due to the fact that in my analysis i have only cancer and not normal samples-thus your opinion about this ? i would just factorize the categorical variables i will include ? 2) Finally, concerning my third question about NAs: if you noticed, except actual NA values, i have also in some variables, "NA" character strings, like the below: plyr::count(coad.exp$subtype_expression_subtype)
x freq
1      CIN   55
2 Invasive   36
3 MSI/CIMP   58
4       **NA   49**
5     <NA>  258


thus, i should take care of them, or proceed as you suggested ?

1
Entering edit mode

Hi again,

For this, correlation, you do not require a true reference. You just need to ensure that you know how your categorical variables will be numerically encoded numerically. This encoding will b based on how you order them.

For example,

factor(tumourStage, levels=c("T1","T2","T3"))


This will be transformed into 1, 2, 3 for correlation.

factor(tumourStage, levels=c("T3","T2","T1"))


This will also be transformed into 1, 2, 3 for correlation.

## ----------------

On the other point, i recommend that you remove all extraneous and un-needed characters, such as **NA (convert to NA), leading and trailing spaces, etc.