Skip to contents

This function plots a set of tracks in a certain locus. Tracks can be given as a vector (tracks), or retreived using track_regex. The intervals to be plotted can be chosen explicitly using the parameter intervals. Alternatively, one can specify the parameter gene; by default, the gene body (all exons) will be plotted, this can be modified using the parameters extend (how many bp to extend from each side of the gene features) and gene_feature, where the intervals can be centered around TSSs of the gene (gene_feature = 'tss').
Metacell annotations can be added using annotation_row and annotation_colors (phetamap-style annotations), which can/should be generated automatically by generate_pheatmap_annotation. RNA expression values of the gene of interest can be added by specifying an McPeaks object, atac, to which an RNA metacell object is attached (see the function add_mc_rna)

Usage

plot_tracks_at_locus(
  tracks = NULL,
  gene = NULL,
  intervals = NULL,
  iterator = 50,
  extend = 0,
  gene_feature = "exon",
  track_regex = NULL,
  chromosomes = gintervals.all() %>% filter(!grepl("_", chrom)) %>% pull(chrom),
  atac = NULL,
  order_rows = FALSE,
  row_order = NULL,
  log_transform = TRUE,
  gene_annot = TRUE,
  name = NULL,
  rna_vals = NULL,
  annotation_row = NULL,
  annotation_col = NULL,
  annotation_colors = NULL,
  silent = FALSE,
  scale_bar_length = NULL,
  rna_legc_eps = 0.00001,
  smooth_mcs = 1,
  smooth_bins = 1,
  colors = c("white", "lightblue", "blue", "darkred", "yellow"),
  color_breaks = NULL,
  use_raster = FALSE
)

Arguments

tracks

(optional) all tracks to plot; if not specified by order_rows or row_order, will be ordered by metacell number

gene

(optional) which gene to plot around; if no gene is found as a whole, partial matches are searched for

intervals

(optional) what genomic interval to plot

iterator

(optional; default - 50) misha iterator, determines the resolution at which the data is extracted and plotted

extend

(optional; default - 0) how much to extend intervals by on each side

gene_feature

(optional; default - "exon") whether to use the exon or tss as features of the gene on which to center the plot

track_regex

(optional) regular expression for matching tracks to plot

chromosomes

(optional) which set of chromosomes to use; mainly used to filter out contigs by default

atac

(optional) McPeaks object from which to extract peaks in locus, and possibly
RNA expression values (if an RNA metacell object is attached)

order_rows

whether to order the rows by cell_type annotation

row_order

an explicit ordering of rows/tracks to use

log_transform

transfrom the data to log2(1 + x). Default: TRUE

gene_annot

(optional) whether to add gene annotations; these annotations rely on the existence of an annots/refGene.txt file in the genome's misha directory

name

(optional; default - 'ATAC signal') name to give the legend of the heatmap

rna_vals

(optional) RNA expression values to plot (overrides RNA expression extracted from atac)

annotation_row

pheatmap-format annotation

annotation_col

pheatmap-format annotation

annotation_colors

pheatmap-format annotation

silent

(optional) whether to print generated plot

rna_legc_eps

(optional) what regularization value to add to mc_rna@e_gc when calculating log

smooth_mcs

number of mc's for smoothign window (Default 1)

smooth_bins

number of genomic bins for smoothing window (default 1)

colors

(optional) vector of colors out of which the shades of the heatmap will be generated

color_breaks

(optional) defining the absolute breaks of the colors. If NULL - this will be determined as uniform distribution with clipping on the 99 percentile of the smoothed value distribution.

use_raster

Whether render the heatmap body as a raster image. It helps to reduce file size when the matrix is huge. If number of rows or columns is more than 2000, it is by default turned on. Note if cell_fun is set, use_raster is enforced to be FALSE.

Value

a ComplexHeatmap figure

Examples

if (FALSE) {
atac_sc <- import_from_10x("pbmc_data", genome = "hg38", id = "PBMC", description = "PBMC from a healthy donor - granulocytes removed through cell sorting (10k)")
data(cell_to_metacell_pbmc_example)
atac_mc <- project_atac_on_mc(atac_sc, cell_to_metacell_pbmc_example)
data(mcmd)
atac_mc <- add_mc_metadata(atac_mc, mcmd)
data(rna_mc_mat)
atac_mc <- add_mc_rna(atac_mc, rna_mc_mat)
pbmc_tracks <- grep("unnorm", gtrack.ls("PBMC_10X.mc"), inv = TRUE, v = TRUE)
# plot gene-centered intervals
plot_tracks_at_locus(
    tracks = pbmc_tracks, extend = 5e+4,
    gene = "ATF3",
    atac = atac_mc,
    gene_annot = TRUE,
    order_rows = TRUE
)

# plot arbitrary intervals
plot_tracks_at_locus(
    tracks = pbmc_tracks,
    intervals = gintervals(2, 1e+7, 1.15e+7),
    atac = atac_mc,
    gene_annot = TRUE,
    order_rows = TRUE
)
}