exportToTrack {CAGEr} | R Documentation

## Converts TSSs and clusters of TSSs to a genome browser track format

### Description

Converts CTSS, tag clusters or consensus clusters to the `UCSCData` format of the `rtracklayer` package, that can be exported to BED file(s) with track information for genome browsers. CTSSes and consensus clusters are optionally colored by their expression class. Tag clusters and consensus clusters can be displayed in a whiskerplot-like representation with a line showing full span on the cluster, filled block showing interquantile range and a thick box denoting position of the dominant (most frequently) used TSS.

### Usage

    exportToTrack(
      object,
      what = c("CTSS", "tagClusters", "consensusClusters"),
      qLow = NULL,
      qUp = NULL,
      colorByExpressionProfile = FALSE,
      oneTrack = TRUE
    )

    ## S4 method for signature 'CAGEexp'
    exportToTrack(
      object,
      what = c("CTSS", "tagClusters", "consensusClusters"),
      qLow = NULL,
      qUp = NULL,
      colorByExpressionProfile = FALSE,
      oneTrack = TRUE
    )

    ## S4 method for signature 'GRangesList'
    exportToTrack(
      object,
      what = c("CTSS", "tagClusters", "consensusClusters"),
      qLow = NULL,
      qUp = NULL,
      colorByExpressionProfile = FALSE,
      oneTrack = TRUE
    )

    ## S4 method for signature 'GRanges'
    exportToTrack(
      object,
      what = c("CTSS", "tagClusters", "consensusClusters"),
      qLow = NULL,
      qUp = NULL,
      colorByExpressionProfile = FALSE,
      oneTrack = TRUE
    )

    ## S4 method for signature 'CTSS'
    exportToTrack(
      object,
      what = c("CTSS", "tagClusters", "consensusClusters"),
      qLow = NULL,
      qUp = NULL,
      colorByExpressionProfile = FALSE,
      oneTrack = TRUE
    )

    ## S4 method for signature 'TagClusters'
    exportToTrack(
      object,
      what = c("CTSS", "tagClusters", "consensusClusters"),
      qLow = NULL,
      qUp = NULL,
      colorByExpressionProfile = FALSE,
      oneTrack = TRUE
    )

    ## S4 method for signature 'ConsensusClusters'
    exportToTrack(
      object,
      what = c("CTSS", "tagClusters", "consensusClusters"),
      qLow = NULL,
      qUp = NULL,
      colorByExpressionProfile = FALSE,
      oneTrack = TRUE
    )

### Arguments

`object` | A `CAGEexp` object.
`what` | Which elements should be exported: `CTSS` for individual CTSSs, `tagClusters` for tag clusters or `consensusClusters` for consensus clusters.
`qLow, qUp` | Position of which "lower" (resp. "upper") quantile should be used as 5' (resp. 3') boundary of the filled block in whiskerplot-like representation of the cluster. Default: `NULL` (plain line representation). Ignored when `what = "CTSS"`.
`colorByExpressionProfile` | Logical, should blocks be colored in the color of their corresponding expression class. Ignored when `what` equals`"tagClusters"`.
`oneTrack` | Logical, should the data be converted in an individual object or a list of objects?

### Details

The BED representations of CTSSs, tag cluster and consensus clusters can be directly visualised in the ZENBU or UCSC Genome Browsers.

When `what = "CTSS"`, one `UCSCData` object with single track of 1 bp blocks representing all detected CTSSs (in all CAGE samples) is created. CTSSs can be colored according to their expression class (see `getExpressionProfiles` and `plotExpressionProfiles`). For `colorByExpressionProfile = FALSE`, CTSSs included in the clusters are shown in black and CTSSs that were filtered out in gray.

When `what = "tagClusters"`, one track per CAGE dataset is created, which can be exported to a single `UCSCData` object (by setting `oneFile = TRUE`) or separate ones (`FALSE`). If no quantile boundaries were provided (`qLow` and `qUp` are `NULL`, TCs are represented as simple blocks showing the full span of TC fromthe start to the end. Setting `qLow` and/or `qUp` parameters to a value of the desired quantile creates a gene-like representation with a line showing full span of the TC, filled block showing specified interquantile range and a thick 1 bp block denoting position of the dominant (most frequently used) TSS. All TCs in one track (one CAGE dataset) are shown in the same color.

When `what = "consensusClusters"` consensus clusters are exported. Since there is only one set of consensus clusters common to all CAGE datasets, only one track is created in case of a simple representation. This means that when `qLow = NULL` and `qUp = NULL` one track with blocks showing the full span of consensus cluster from the start to the end is created. However, the distribution of the CAGE signal within consensus cluster can be different in different CAGE samples, resulting in different positions of quantiles and dominant TSS. Thus, when `qLow` and/or `qUp` parameters are set to a value of the desired quantile, a separate track with a gene-like representation is created for every CAGE dataset. These tracks can be exported to a single `UCSCData` object (by setting `oneFile = TRUE`) or separate ones (by setting `oneFile = FALSE`). The gene-like representation is analogous to the one described above for the TCs. In all cases consensus clusters can be colored according to their expression class (provided the expression profiling of consensus clusters was done by calling `getExpressionProfiles` function). Colors of expression classes match the colors in which they are shown in the plot returned by the `plotExpressionProfiles` function. For `colorByExpressionProfile = FALSE` all consensus clusters are shown in black.

### Value

Returns either a `rtracklayer` `UCSCData` object, or a `GRangesList` of them.

### Author(s)

Vanja Haberle

Charles Plessy

### Examples

    # You can export from a CAGEexp object or from a cluster object directly:
    exportToTrack(exampleCAGEexp, what = "CTSS")  # Is same as:
    exportToTrack(CTSScoordinatesGR(exampleCAGEexp))  # Or:
    exampleCAGEexp |> CTSScoordinatesGR() |> exportToTrack()

    # Export a single sample,
    exampleCAGEexp |> CTSStagCountGR(2)      |> exportToTrack()
    exampleCAGEexp |> CTSSnormalizedTpmGR(2) |> exportToTrack()

    # Exporting multiple samples results in a GRangesList of UCSCData objects.
    exportToTrack(exampleCAGEexp, what = "CTSS", oneTrack = FALSE)
    exampleCAGEexp |> CTSStagCountGR("all")  |> exportToTrack()
    exampleCAGEexp |> CTSSnormalizedTpmGR("all")  |> exportToTrack()

    ### exporting CTSSs colored by expression class
    # Temporarly disabled
    # exportToTrack(exampleCAGEexp, what = "CTSS", colorByExpressionProfile = TRUE)

    ### exporting tag clusters in gene-like representation
    exportToTrack(exampleCAGEexp, what = "tagClusters", qLow = 0.1, qUp = 0.9)
    tagClustersGR(exampleCAGEexp, 1) |> exportToTrack(qLow = 0.1, qUp = 0.9)

    ### exporting consensus clusters
    exportToTrack( exampleCAGEexp, what = "consensusClusters")
    exampleCAGEexp |>
      consensusClustersGR("Zf.high", qLow = .1, qUp = .9) |>
      exportToTrack(qLow = .1, qUp = .9)

[Package CAGEr version 2.0.2 Index]