Make custom Txdb class objects from Txdb
Entering edit mode
Shreyash ▴ 10
Last seen 14 months ago
United States

Hi folks,

I am trying to plot.a zoomed in custom karyoploteR plot. The key issue with the zoomed in plots are that I need the loci a bit bigger which causes the gene labels to merge with each other.

To avoid this issue, I wished to plot only a few custom genes filtered based on the gene name. The key question is how would I do that in such a way that Txdb object makes its own filtered Txdb object which then I can feed it into kpPlotGenes. FYI, kpPlotGenes takes in Txdb object and author Bernat mentions that one can use custom Txdb directly for kpPlotGenes.

## TODO: Initialize the karyoplot
kp <- plotKaryotype(plot.type = 2, zoom = SNAPC3.region, cex = 1, plot.params = pp)
kpDataBackground(kp, data.panel = 1, col = "grey98")

## Plot genes
kpPlotGenes(kp, TxDb.Hsapiens.UCSC.hg19.knownGene, r0 = 0.2, r1 = 0.3, = 0.8, data.panel = 2, gene.margin = 0, col = "darkmagenta", = "black", = "top", avoid.overlapping = TRUE)

The following ways I have tried and failed

  1. Subset the object that I get from karyoploteR <- makeGenesDataFromTxDb(TxDb.Hsapiens.UCSC.hg19.knownGene,
                                    plot.transcripts = FALSE,
                                    plot.transcripts.structure = FALSE) <- addGeneNames( <-$genes[$genes$gene_id %in% ranges.df[ranges.df$coverage == unique(ranges.df$coverage)[1],]$names]
  1. select() won't work here, but can I make it a custom Txdb object using something (this didn't work cause I had different column names)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
customtxdb <- select(txdb, keys = ranges.df[ranges.df$coverage == unique(ranges.df$coverage)[1],]$names, keytype="GENEID", columns = columns(txdb))

Error in check_colnames(transcripts, .REQUIRED_COLS, .OPTIONAL_COLS, "transcripts"): 'transcripts' must have at least the following cols: tx_id, tx_chrom,
  tx_strand, tx_start, tx_end

I think there is a better method in the documentation of genomic features on how to handle this, but I can't seem to find it.

GenomicFeatures karyoploteR TxDb.Hsapiens.UCSC.hg19.knownGene • 527 views

Login before adding your answer.

Traffic: 778 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6