computeFeatureFreq

computeFeatureFreq(df, df_fisher, target)

Arguments

df

The input matrix with binary features and the phenotype column

df_fisher

The post-BH fisher results with gene names to annotate

target

The binarized AMR phenotype "target" output from before

Value

The BH Fisher data table with added feature frequency columns

Examples

df <- tibble::tibble(
  genome_id = paste0("g", 1:10),
  genome_drug.resistant_phenotype = rep(c("Resistant", "Susceptible"), each = 5),
  gene_a = c(1, 1, 1, 1, 0, 0, 0, 0, 0, 0),
  gene_b = c(0, 0, 0, 1, 1, 1, 1, 1, 1, 0)
)
encoded <- encodePhenotype(df)
fisher <- applyBenjaminiHochberg(
  runFisherTests(encoded$df, encoded$target),
  Q = 0.05
)
computeFeatureFreq(encoded$df, fisher, encoded$target)
#> # A tibble: 2 × 8
#>   gene   p_value adj_p_value sig_after_bh alternative     Q
#>   <chr>    <dbl>       <dbl> <lgl>        <chr>       <dbl>
#> 1 gene_a  0.0476      0.0952 FALSE        two.sided    0.05
#> 2 gene_b  0.524       0.524  FALSE        two.sided    0.05
#> # ℹ 2 more variables: freq_susceptible_gene_pres <dbl>,
#> #   freq_resistant_gene_pres <dbl>