b2slab / FELLA

FELLA: an R package for Metabolomics data enrichment through diffusion
21 stars 2 forks source link

Multiplicity correction for pathway enrichment not working in enrich function for hypergeometric analysis #16

Closed billy-s-lab closed 1 year ago

billy-s-lab commented 3 years ago

Hello,

Is it to possible to adjust the p-values from hypergeometric analysis for multiple testing? I see on page 8 of the package documentation (https://bioconductor.org/packages/release/bioc/manuals/FELLA/man/FELLA.pdf) that there is a p.adjust argument for the enrich function. However, when I pass different options to the p.adjust argument (fdr, bonferroni, etc), it does not change the p-values for pathway enrichment. Should I calculate adjusted pvalues manually on the hypergeometric results table? Code I am running is below. Thank you.

analysis.hypergeometric <- enrich( compounds = cpd.kegg.id, data = fella.data, method = "hypergeom", p.adjust = "fdr", approx = "normality")

table.hypergeometric <- generateResultsTable( #FELLA github issue 14 - try to identify CompoundHits for each pathway: https://github.com/b2slab/FELLA/issues/14 object = analysis.hypergeometric, plimit = 30, threshold = 0.05, data = fella.data, method = "hypergeom", NamesAsLabels = TRUE)

table.hypergeometric$p.adjust <- p.adjust(table.hypergeometric$p.value, method="BH")

table.hypergeometric$p.adjust <- p.adjust(table.hypergeometric$p.value, method="bonferroni")

SergiPicart commented 3 years ago

Hi, the p-values are fdr-adjusted by default. The ellipsis in enrich() only passes on its arguments to runDiffusion() and runPagerank(). You can still use runHypergeom() with your preferred adjustment. Below is an example. We can check for the future if it is possible to make enrich() pass on arguments to runHypergeom().

# example on how to change p-value adjustment in hypergeom
library(FELLA)
library(magrittr)

data("FELLA.sample")
data("input.sample")

# enrich does not pass the p.adjust argument to runHypergeom
# see ?enrich (only passes ellipsis along to runDiffusion, runPagerank)
myAnalysis <- enrich(
  compounds = input.sample, 
  method = "hypergeom", 
  data = FELLA.sample)

df.default <- generateResultsTable(
  method = "hypergeom", 
  object = myAnalysis, 
  data = FELLA.sample, 
  threshold = 1) 

df.fdr <- defineCompounds(compounds = input.sample, data = FELLA.sample) %>%
  runHypergeom(data = FELLA.sample, p.adjust = "fdr") %>%
  generateResultsTable(
    object = .,
    method = "hypergeom", 
    data = FELLA.sample, 
    threshold = 1) 

df.none <- defineCompounds(compounds = input.sample, data = FELLA.sample) %>%
  runHypergeom(data = FELLA.sample, p.adjust = "none") %>%
  generateResultsTable(
    object = .,
    method = "hypergeom", 
    data = FELLA.sample, 
    threshold = 1) 

# default is fdr 
df.default$p.value

# same as manually setting fdr
df.fdr$p.value

# or manually adjusting "none"
p.adjust(df.none$p.value, method = "fdr")

# unadjusted p-values
df.none$p.value