Entering edit mode
6.8 years ago
Kevin Blighe
88k
Similar to how corrplot does it, but also different.
Major update September 10, 2018:
All code is now on GitHub with a vignette, and installation is streamlined: https://github.com/kevinblighe/CorLevelPlot
To install (R):
devtools::install_github("kevinblighe/CorLevelPlot")
library(CorLevelPlot)
Practical examples in Vignette:
Kevin
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,
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:
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
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
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:
thus, i should take care of them, or proceed as you suggested ?
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,
This will be transformed into 1, 2, 3 for correlation.
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.
Hey. I am not able to download it in current R version.
Is that the most information you can provide about this issue?