methylKit icon indicating copy to clipboard operation
methylKit copied to clipboard

Fisher-test option for adjust.methylC

Open avilella opened this issue 9 years ago • 6 comments

This is a feature request against the development version, which contains an adjust.methylC feature that does subtraction of an oxBS and mkBS (mock-BS or BS sample). See the code below.

With this optional Fisher-test filtering, those entries where the 4 counts don't pass the t test with a given threshold are excluded, and the rest of entries are included. One could leave the default of not using fisher-test filtering as it is now.

fisher.test(matrix(c(mkBS_methylated, mkBS_unmethylated, oxBS_methylated, oxBS_unmethylated),nrow=2,dimnames=list(mkBS=c("methylated","unmethylated"),oxBS=c("methylated","unmethylated"))))
setMethod("adjust.methylC", c("methylRaw","methylRaw"),function(mc,hmc){

  lst=new("methylRawList",list(mc,hmc),treatment=c(1,0))
  data=getData(unite(lst))

  diff=(data$numCs1)-round(data$coverage1*(data$numCs2/data$coverage2))
  diff[diff<0]=0
  data$numCs1=diff
  data$numTs1=data$coverage1-data$numCs1
  colnames(data)[5:7]=c("coverage","numCs","numTs")
  new("methylRaw",data[,1:7],[email protected],  assembly=mc@assembly, 
                             context =mc@context,     resolution=mc@resolution)

})

avilella avatar Jan 27 '16 15:01 avilella

Where is the t-test applied here in the code? Do you have a reference where a similar filtering method applied ?

al2na avatar Jan 28 '16 21:01 al2na

The paper from Booth et al (http://www.sciencemag.org/content/336/6083/934/suppl/DC1) used the Fishers-Exact test to measure the detectability of 5hmC at a single cytosine position at different coverage levels (Figure S15) and correlates this confidence to coverage level. A False Discovery Rate (FDR) correction filter can also be applied using Benjamini-Hochberg test.

darogan avatar Jan 29 '16 10:01 darogan

Ok, but where is the t-test ?

On Friday, 29 January 2016, Russell Hamilton [email protected] wrote:

The paper from Booth et al ( http://www.sciencemag.org/content/336/6083/934/suppl/DC1) used the Fishers-Exact test to measure the detectability of 5hmC at a single cytosine position at different coverage levels (Figure S15) and correlates this confidence to coverage level. A False Discovery Rate (FDR) correction filter can also be applied using Benjamini-Hochberg test.

— Reply to this email directly or view it on GitHub https://github.com/al2na/methylKit/issues/26#issuecomment-176678418.

Sent from mobile, excuse the brevity

al2na avatar Jan 29 '16 10:01 al2na

There is no t-test - the Fishers-Exact test is the correct one to use

darogan avatar Jan 29 '16 10:01 darogan

Apologies, I wrongly wrote t-test in the description but then copied the fisher.test line of code. Corrected now.

avilella avatar Jan 29 '16 10:01 avilella

This can already be done with existing functions, it would be more convenient to have it in adjust.methylC() function but until that happens (eta unknown). you can first treat hmc and mc samples as as mc samples use unite() and calculateDiffMeth() to get fisher's exact test values, get the coordinates that passes the test, then filter adjust.methylC results based on those coordinates

al2na avatar Feb 14 '16 10:02 al2na