Skip to contents

Test the same modification-against-charging association as compute_charging_odds_ratios(), but from a table that already holds each site's 2x2 counts rather than from per-read calls.

Usage

charging_odds_ratios_from_counts(
  counts,
  min_reads = 10,
  min_margin = 1,
  max_p = 1,
  p_method = "BH"
)

Arguments

counts

Per-site counts, either a path to a {sample}.charging_error.tsv.gz file or a tibble. Requires columns ref, pos, err_charged, err_uncharged, match_charged and match_uncharged.

min_reads

Minimum reads at a site for it to be tested. Default 10.

min_margin

Minimum count in each margin of the 2x2 table. Default 1.

max_p

Skip sites whose margins put this p-value out of reach. Default 1, which tests everything.

p_method

Method for p-value adjustment, passed to stats::p.adjust(). Default "BH".

Value

A tibble with the same columns as compute_charging_odds_ratios().

Details

The aa-tRNA-seq pipeline accumulates these counts during the BAM walk it performs anyway, writing {sample}.charging_error.tsv.gz with one row per site instead of one row per read and position. That is the same information as far as this test is concerned – the statistics are identical – and it turns a table of tens of millions of rows into tens of thousands, so prefer this entry point unless you need read-level flexibility such as re-thresholding the charging call or joining other per-read features.

The caveats on compute_charging_odds_ratios() apply unchanged, in particular that sites near the 3' end are not interpretable.

Examples

counts <- tibble::tibble(
  ref = "tRNA-Ala-AGC-1-1",
  pos = c(34L, 58L),
  err_charged = c(120, 40),
  err_uncharged = c(30, 45),
  match_charged = c(200, 280),
  match_uncharged = c(400, 385)
)
charging_odds_ratios_from_counts(counts)
#> # A tibble: 2 × 13
#>   ref     pos   n11   n10   n01   n00 total_obs mod_freq charged_freq odds_ratio
#>   <chr> <int> <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>        <dbl>      <dbl>
#> 1 tRNA…    34   120    30   200   400       750    0.2          0.427       8   
#> 2 tRNA…    58    40    45   280   385       750    0.113        0.427       1.22
#> # ℹ 3 more variables: log_odds_ratio <dbl>, p_value <dbl>, p_adjusted <dbl>