makeGenesDataFromTxDb {karyoploteR} | R Documentation

## makeGenesDataFromTxDb

### Description

This is a utility function that transforms a TxDb object into a custom object valid as input for `kpPlotGenes`.

### Usage

    makeGenesDataFromTxDb(txdb, karyoplot=NULL, plot.transcripts=TRUE, plot.transcripts.structure=TRUE)

### Arguments

`txdb` | (a TxDb object) The transcript database object from which the data will be extracted.
`karyoplot` | (karyoplot object) A valid karyoplot object created by a call to `plotKaryotype`. If present, genes data will be restricted to the visible region in the plot. If NULL, all genes will be included. (defaults to NULL)
`plot.transcripts` | (boolean) TRUE if transcripts are needed in addition to the genes. (defaults to TRUE)
`plot.transcripts.structure` | (boolean) TRUE if the coding and non-coding exons are needed in addition to the genes and transcripts. (defaults to TRUE)

### Details

This function creates a valid data object for `kpPlotGenes` starting from a TxDb object. The resulting object will contain only the genes and transcripts ovelapping the plot region of the given Karyoplot object.

### Value

Returns a list with at least one element called `genes`, a `GRanges` with all genes overlapping karyoplot. If `plot.transcripts` is TRUE, the returned list will have a `transcript` element, a list of `GRanges` objects, one per gene (named with the gene ids), with the transcripts of that gene. If `plot.transcripts.structure` is TRUE, two more elements are present: `coding.exons` and `non.coding.exons`, each a list with one element per trascript (named with the transcript id), and each element the coding or non-coding exons of that transcript.

### Note

`kpPlotGenes` accepts TxDb objects directly. This function is only expected to be used when the user want to manipulate the results somehow (i.e. removing some of the genes).

### See Also

`kpPlotGenes`

### Examples

    library(TxDb.Hsapiens.UCSC.hg19.knownGene)

    zoom <- toGRanges("chr17", 32.6e6, 33.2e6)
    kp <- plotKaryotype(genome="hg19", zoom=zoom)

    genes.data <- makeGenesDataFromTxDb(TxDb.Hsapiens.UCSC.hg19.knownGene,
                     karyoplot=kp, plot.transcripts=TRUE,
                     plot.transcripts.structure=TRUE)

[Package karyoploteR version 1.20.3 Index]