pull_track: Use tracks inside and outside geom_* calls

View source: R/pull_tracks.R

featsR Documentation

Use tracks inside and outside ⁠geom_*⁠ calls

Description

Track selection works like dplyr::pull() and supports unquoted ids and positional arguments. ... can be used to subset the data in dplyr::filter() fashion. pull-prefixed variants return the specified track from a gggenome object. Unprefixed variants work inside ⁠geom_*⁠ calls.

Usage

feats(.track_id = 1, ..., .ignore = "genes", .geneify = FALSE)

feats0(.track_id = 1, ..., .ignore = NA, .geneify = FALSE)

genes(..., .gene_types = c("CDS", "mRNA", "tRNA", "tmRNA", "ncRNA", "rRNA"))

links(.track_id = 1, ..., .ignore = NULL, .adjacent_only = NULL)

seqs(...)

bins(..., .group = vars())

track(.track_id = 1, ..., .track_type = NULL, .ignore = NULL)

pull_feats(.x, .track_id = 1, ..., .ignore = "genes", .geneify = FALSE)

pull_genes(
  .x,
  ...,
  .gene_types = c("CDS", "mRNA", "tRNA", "tmRNA", "ncRNA", "rRNA")
)

pull_links(.x, .track_id = 1, ..., .ignore = NULL, .adjacent_only = NULL)

pull_seqs(.x, ...)

pull_bins(.x, ..., .group = vars())

## S3 method for class 'gggenomes_layout'
pull_bins(.x, ..., .group = vars())

pull_track(.x, .track_id = 1, ..., .track_type = NULL, .ignore = NULL)

Arguments

.track_id

The track to pull out, either as a literal variable name or as a positive/negative integer giving the position from the left/right.

...

Logical predicates passed on to dplyr::filter. "seqs", "feats", "links". Affects position-based selection.

.ignore

track names to ignore when selecting by position. Default is "genes", if using feats0 this defaults to NA.

.geneify

add dummy type, introns and geom_id column to play nicely with geoms supporting multi-level and spliced gene models.

.gene_types

return only feats of this type (type %in% .gene_types)

.adjacent_only

filter for links connecting direct neighbors (⁠abs(y-yend)==1)⁠)

.group

what variables to use in grouping of bins from seqs in addition to y and bin_id. Use this to get additional shared variables from the seqs table into the bins table.

.track_type

restrict to these types of tracks - any combination of "seqs", "feats", "links".

.x

A gggenomes or gggenomes_layout object.

Functions

  • feats(): by default pulls out the first feat track not named "genes".

  • feats0(): by default pulls out the first feat track.

  • genes(): pulls out the first feat track (genes), filtering for records with type=="CDS", and adding a dummy gene_id column if missing to play nice with multi-exon geoms.

  • links(): by default pulls out the first link track.

  • seqs(): pulls out the seqs track (there is only one).

  • bins(): pulls out a binwise summary table of the seqs data powering ⁠geom_bin_*()⁠ calls. The bin table is not a real track, but recomputed on-the-fly.

  • track(): pulls from all tracks in order seqs, feats, links.

Examples


gg <- gggenomes(emale_genes, emale_seqs, emale_tirs, emale_ava)
gg %>% track_info()            # info about track ids, positions and types

# get first feat track that isn't "genes" (all equivalent)
gg %>% pull_feats()            # easiest
gg %>% pull_feats(feats)       # by id
gg %>% pull_feats(1)           # by position
gg %>% pull_feats(2, .ignore=NULL)  # default .ignore="genes"

# get "seqs" track (always track #1)
gg %>% pull_seqs()

# plot integrated transposons and GC content for some viral genomes
gg <- gggenomes(seqs=emale_seqs, feats=list(emale_ngaros, GC=emale_gc))
gg + geom_seq() +
  geom_feat(color="skyblue") + # defaults to data=feats()
  geom_line(aes(x, y+score-.6, group=y), data=feats(GC), color="gray60")

thackl/gggenomes documentation built on March 10, 2024, 7:26 a.m.