R/plotAlphaDistributionOneChr.R

Defines functions plotAlphaDistributionOneChr

Documented in plotAlphaDistributionOneChr

plotAlphaDistributionOneChr <-
function(m, chr.sel, pdfFilename = NULL, num.cores = 1, nCGbin = 101){

  message("determining alpha distribution for chromosome: ", chr.sel)
  
  indx <- as.character(seqnames(m))==chr.sel
  if(sum(indx)<nCGbin)
    stop(sprintf("Error: less than %d covered CpGs on chromosome %s", nCGbin, chr.sel))
  
  T <- as.numeric(values(m[indx])[, 1])
  M <- as.numeric(values(m[indx])[, 2])

  score <- calculateAlphaDistr(M, T, nCGbin, num.cores)

  if(!is.null(pdfFilename)){
    pdf(pdfFilename, width=5, height=5)
  }
  
  hist(score, probability=TRUE, breaks=30, xlab=sprintf("posterior mean of alpha (%s)", chr.sel), main="")
  if(!is.null(pdfFilename))
  dev.off()

}

Try the MethylSeekR package in your browser

Any scripts or data that you put into this service are public.

MethylSeekR documentation built on Nov. 8, 2020, 6:57 p.m.