error in density plot – methylation EPIC data

Hey Mate it may be too little too late but I had the same issue while analyzing EPIC arrays and this is what I did (In hope that someone having the same issue and this could help):
I got the following error

"Error in density.default(as.vector(x), na.rm = TRUE) :
need at least 2 points to select a bandwidth automatically"

while running this line of code

qcReport(rgSet, sampNames=targets$ID, sampGroups=targets$Sample_Group, pdf="qcReport.pdf").

This ment that one of the samples used in plot does not have enough values to do density plot. Since I was doing Density plot of Beta values I extracted the Beta values for a closer look.



revelaed that one sample has NaN vlues “NOPTSD_N.202908540170_R06C01”.
To look into that all Beta values in the sample are NaN, I ran the code colMeans(bv,na.rm=TRUE). This output values for all the samples expect our trouble sample “NOPTSD_N.202908540170_R06C01”. That has value NaN.
So decided to remove the sample from analysis by using the the code


All samples have TRUE value and our troubled friend has NA.
To change from NA to FALSE to help subset dataset.


targets <- targets[keep,]

The last 2 line of code updated my dataset by removing the problem sample. After this plots ran like dream.

Read more here: Source link