# ==============================================================================
offset <- rbind(data.frame(list(sample = "sgeIF5A-rep1",
qwidth = 25:32,
rel_pos = -13)),
data.frame(list(sample = "sgeIF5A-rep2",
qwidth = 25:32,
rel_pos = -13)),
data.frame(list(sample = "wt-rep1",
qwidth = 25:32,
rel_pos = -13)),
data.frame(list(sample = "wt-rep2",
qwidth = 25:32,
rel_pos = -13))
)
# assign offset info
obj0@reads_offset_info <- offset
Offset correction
Intro
Accurate offset correction is a critical preprocessing step in ribosome profiling data analysis. Because ribosome-protected fragments are heterogeneous in length, the precise location of the ribosomal P-site varies depending on fragment size. Without correcting for this bias, downstream analyses such as metagene profiles, translation initiation site identification, and codon-level ribosome occupancy patterns may be distorted or misinterpreted.
By assigning the correct P-site position for each read, offset correction ensures that signals from ribosome footprints are properly aligned with annotated coding features. This improves the resolution of translation dynamics and enables more accurate characterization of start site selection, elongation patterns, and termination efficiency.
Based on the results of the relative_offset_plot() and length_plot() functions, users can selectively retain reads of appropriate fragment lengths and strong 3-nt periodicity for downstream analysis. For each read length (e.g., 28–32 nt), an optimal P-site offset (relative position from the 5′ end of the read to the start codon) should be determined.
To manually specify the offset values for different read lengths, users can create a custom data frame and store it in the reads_offset_info slot of the ribotrans object. This data frame must contain the following three columns:
sample: the sample name (must match names defined in the ribotrans object)
qwidth: read length (integer)
rel_pos: P-site offset relative to the start codon (e.g., -12, -13)
Once the reads_offset_info slot is filled, downstream functions that support offset correction will apply these offsets when the argument do_offset = TRUE is set.
Example
Below is an example of how to create an offset data frame and assign it back to the ribotrans object: