hansenlab / minfi

Devel repository for minfi
58 stars 70 forks source link

expose the PCs from preprocessFunnorm #54

Open kasperdanielhansen opened 8 years ago

kasperdanielhansen commented 8 years ago

From Maarten van Iterson mviterson@gmail.com

In a few analyses with >500 samples we noticed that often the number of PCs should be larger than the default of 2 for functional normalization. Now we extract some code from minfi, not exported, using the triple colon operator, to create such plots. It would be nice if there was a function to plot the variance explained of the first few pc of the control matrix. For example, something along the lines of:

controlMatrix <- .buildControlMatrix450k(.extractFromRGSet450k(RGset))
pc <- prcomp(controlMatrix)
##set nmax e.g. to 10 or so
nmax <- ifelse(nmax > nrow(controlMatrix), nrow(controlMatrix), nmax)
barplot(summary(pc)$importance[2,1:nmax], ylab="Proportion of Variance")

and optionally return the pc-object e.g. to correlate with known covariates for further inspection.

kasperdanielhansen commented 8 years ago

Very sensible suggestion; this has to be balanced with making the function easy to use and with limiting my maintenance responsibility. I don't think we have done a formal analysis of percent variance explained vs. funnorm's ability to correct the data along the lines laid out in our manuscript, so I'm not sure whether I think it is a good idea to look at for the casual user. But I can understand the desire for experts to tease the algorithm apart. Conclusion: I will have a closer look at this, but no promises.