Compute per-position delta between two conditions.
Source:R/read-bcerror.R
compute_bcerror_delta.RdTake a summarized bcerror tibble (with columns for reference, position, condition, and a value such as mean error rate) and compute the difference between two conditions at each position.
Arguments
- data
A summarized bcerror tibble with at least
ref,pos, and columns named byvalue_colandcondition_col.- delta
A bare expression of the form
lhs - rhs, wherelhsandrhsare condition levels. The result islhs - rhs.- value_col
Column name (string) containing the values to pivot. Default
"mean_error".- condition_col
Column name (string) containing condition labels. Default
"condition".
Value
A tibble with columns ref, pos, one column per condition
level, and delta (the computed difference).
Examples
df <- tidyr::expand_grid(
ref = c("tRNA-Ala", "tRNA-Gly"),
pos = 1:5,
condition = c("wt", "mut")
)
df$mean_error <- runif(nrow(df), 0, 0.3)
compute_bcerror_delta(df, delta = wt - mut)
#> # A tibble: 10 × 5
#> ref pos wt mut delta
#> <chr> <int> <dbl> <dbl> <dbl>
#> 1 tRNA-Ala 1 0.152 0.198 -0.0458
#> 2 tRNA-Ala 2 0.154 0.251 -0.0971
#> 3 tRNA-Ala 3 0.213 0.262 -0.0496
#> 4 tRNA-Ala 4 0.00344 0.266 -0.263
#> 5 tRNA-Ala 5 0.299 0.150 0.149
#> 6 tRNA-Gly 1 0.108 0.232 -0.125
#> 7 tRNA-Gly 2 0.175 0.190 -0.0149
#> 8 tRNA-Gly 3 0.258 0.170 0.0875
#> 9 tRNA-Gly 4 0.0759 0.276 -0.200
#> 10 tRNA-Gly 5 0.260 0.0746 0.186