error in density plot - methylation EPIC data
1
1
Entering edit mode
2.7 years ago
junehicks0 ▴ 10

I am creating densityplot for methylation EPIC data using minfi package in R

Below is my code for plotting density plot

rgsetAll <- read.metharray.exp(targets = Targets, force=TRUE)
densityPlot(preprocessRaw(rgsetAll), main = "Methylation")

However i'm getting this error:

Error in density.default(newX[, i], ...) : 
  need at least 2 points to select a bandwidth automatically
Calls: densityPlot -> apply -> FUN -> FUN -> density.default

I checked beta values and there is a lot of missing values (NA) for couple of samples. Could missing values be causing error?

Did anyone face this problem while dealing with methylation array data.

Any help is appreciated

R bioconductor • 1.9k views
ADD COMMENT
1
Entering edit mode
9 months ago

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.

bv<-getBeta(rgSet)

head(bv)

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

keep<-colMeans(bv,na.rm=TRUE)>0

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

keep["NOPTSD_N.202908540170_R06C01"]=FALSE

rgSet<-rgSet[,keep] targets <- targets[keep,]

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

ADD COMMENT
0
Entering edit mode

Thanks, removing the NA worked for me :)

ADD REPLY

Login before adding your answer.

Traffic: 2067 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6