Is there a Bioconductor solution of comparing discrete variables to PCs to figure out associations. I'm looking for the discrete version of PCAtools' eigencor plot.
Hey Kristoffer, I developed PCAtools, as you know - is eigencorplot not what you need? PCAtools has been in Bioconductor for > 1 year.
Note that these are the exact same:
As I show here:
continuous <- c(45, 67, 12, 65, 75, 3, 44, 90)
categorical <- factor(c(0,0,0,0,1,1,1,1))
cor(continuous, as.numeric(categorical)) ^ 2
summary(lm(continuous ~ categorical))$r.squared
I did try eigencorplot() but got this error when using a categorical (text or factor) variable:
Error in cor(xvals, yvals, use = corUSE, method = corFUN) :
'y' must be numeric
In addition: Warning message:
In eigencorplot(myPca, metavars = c("barcode")) :
barcode is not numeric - please check the source data as everything will be converted to a matrix
Turns out it can be solved by convert them to numerical values before using pca().
Thanks for pointing out it could be done.
Oh, I thought that issue was addressed in the previous Bioc release, i.e., it should automatically convert factors to numeric and give a warning, like above. I have not yet come across the other error thrown by cor() internally.
Login before adding your answer.
Use of this site constitutes acceptance of our User Agreement and Privacy