Draws a barcode plot for a gene, as
barcodeplot but with ggplot2: all the barcodes
are ranked by their log2 fold change (computed with edgeR for the
given contrast) and the barcodes of the gene are shown as vertical
bars. If most of the bars are on the left (negative log2 fold change)
the gene is depleted, if they are on the right it is enriched. It is
useful to check the hits of find_camera_hit and
find_roast_hit.
Arguments
- screenR_Object
The ScreenR object obtained using
create_screenr_object, normalized withnormalize_data. The model uses its raw counts with its effective library sizes as offsets, the same normalization as the plots and the data table (seecreate_edger_obj).- matrix_model
The design matrix of the linear model, for example created with
create_design_matrix(or withmodel.matrix). Rows must be named with sample identifiers in object order (seecreate_design_matrix); mismatched names or order are errors. Named contrast coefficients are aligned to design columns.- contrast
The comparison to plot: the name or index of a column of matrix_model, a numeric contrast vector (for example created with
create_contrast) or a one-column matrix created withmakeContrasts.- number_barcode
The gene must have more than number_barcode barcodes (default 3), as in
find_camera_hit.- gene
The name of the gene to plot.
- quantile
The two log2 fold change values that delimit the central (grey) region of the plot. Default c(-0.5, 0.5).
- labels
The labels of the left and right ends of the plot.
- show_log2fc
Whether to add the panel with the log2 fold change of all the barcodes (default TRUE).
Value
A ggplot object (a patchwork of the panels), which can be printed,
saved with ggsave or combined with other
plots. No theme is applied: add one to all the panels with &,
for example plot_barcode_hit(...) & ggplot2::theme_classic().
Details
The plot has up to three panels, which share the ranking of the barcodes on the x axis:
the enrichment line: the density of the barcodes of the gene along the ranking divided by their average density (computed as in
barcodeplot, with a tricube moving average). Values above 1 (dashed line) mean that the barcodes of the gene are concentrated there;the barcodes of the gene as vertical bars, colored by their log2 fold change, on three regions: below, between and above the two values of quantile;
(when show_log2fc = TRUE) the log2 fold change of all the barcodes, in order, with the barcodes of the gene as points. It shows how strong the effect is, which the ranks alone do not.
Examples
object <- get0("object", envir = asNamespace("ScreenR"))
matrix_model <- create_design_matrix(object)
contrast <- create_contrast(matrix_model,
treatment = "Treated", control = "Control"
)
plot_barcode_hit(object, matrix_model,
contrast = contrast,
gene = "Gene_300"
)
# Without the panel of the log2 fold changes
plot_barcode_hit(object, matrix_model,
contrast = contrast,
gene = "Gene_300", show_log2fc = FALSE
)
