Skip to contents

Plot a genomic region

Usage

mct_plot_region(
  mct,
  intervals,
  detect_dca = FALSE,
  downsample = TRUE,
  downsample_n = NULL,
  metacells = NULL,
  colors = c("white", "gray", "black", "gold"),
  color_breaks = c(0, 6, 12, 18, 24),
  hc = NULL,
  force_cell_type = TRUE,
  gene_annot = FALSE,
  n_smooth = 10,
  n_pixels = 1000,
  ...
)

Arguments

mct

an McTracks object.

intervals

an intervals set with the genomic region to plot (a data frame with a single line). Note that if the start or end coordinates are not divisible by the resolution, the region will be extended to the next resolution interval.

detect_dca

mark regions with differential cluster accessibility (DCA)

downsample

return a downsampled matrix. See description.

downsample_n

total coverage goal. See description. Default: lower 5th percentile of the total coverage)

metacells

a vector of metacells to plot. If NULL, all metacells will be plotted.

colors

color pallette for the ATAC signal

color_breaks

a vector of breaks for the color palette

hc

an hclust object to use for the hierarchical clustering of the metacells when detect_dcs=TRUE. If NULL, metacells will be clustered using mc_hclust_rna.

force_cell_type

do not split cell types when ordering the metacells. Default: TRUE

gene_annot

whether to add gene annotations; these annotations rely on the existence of an annots/refGene.txt file in the genome's misha directory, and on the existence of an intervals set called "intervs.global.tss" in the genome's misha directory. (optional)

n_smooth

number of genomic bins to use for smoothing the signal. Signal is smoothed by a rolling sum for each metacell (optional). Default is 20.

n_pixels

number of pixels in the plot. The DCA regions would be extended by ceiling(2 * nrow(mat) / n_pixels) (optional).

...

Arguments passed on to mct_diff_access_on_hc

mat

a matrix where rows are coordinates and columns are metacells

sz_frac_for_peak

maximal fraction of metacells in a peak or trough. Default is 0.25.

peak_lf_thresh1,peak_lf_thresh2,trough_lf_thresh1,trough_lf_thresh2

thresholds for the log fold change of the peaks and troughs

u_reg

regularization factor

Value

None. The plot is displayed in a new device.

Examples

if (FALSE) {
intervs <- gintervals(5, 54974252, 55074253)
mct_plot_region(mct, intervs, gene_annot = TRUE)
mct_plot_region(mct, intervs, detect_dca = TRUE, gene_annot = TRUE)

get_gene_promoter("GZMK", downstream = 1e5, upstream = 1e5, unify = TRUE) %>%
    mct_plot_region(mct, intervs, detect_dca = TRUE, gene_annot = TRUE)

intervs %>%
    gintervals.zoom_in(4) %>%
    mct_plot_region(mct, ., detect_dca = TRUE, gene_annot = TRUE)
intervs %>%
    gintervals.zoom_out(2) %>%
    mct_plot_region(mct, ., detect_dca = TRUE, gene_annot = TRUE)
intervs %>%
    gintervals.shift_left(1e5) %>%
    mct_plot_region(mct, ., detect_dca = TRUE, gene_annot = TRUE)
intervs %>%
    gintervals.shift_right(1e5) %>%
    mct_plot_region(mct, ., detect_dca = TRUE, gene_annot = TRUE)
}