Make custom Txdb class objects from Txdb
0
1
Entering edit mode
Shreyash ▴ 10
@57e94391
Last seen 19 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, gene.name.cex = 0.8, data.panel = 2, gene.margin = 0, col = "darkmagenta", gene.name.col = "black", gene.name.position = "top", avoid.overlapping = TRUE)

The following ways I have tried and failed

  1. Subset the gene.data object that I get from karyoploteR
genes.data <- makeGenesDataFromTxDb(TxDb.Hsapiens.UCSC.hg19.knownGene,
                                    karyoplot=kp,
                                    plot.transcripts = FALSE,
                                    plot.transcripts.structure = FALSE)
gene.data <- addGeneNames(genes.data)

selected.gene.data <- gene.data$genes[gene.data$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))
makeTxdb(customtxdb)

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 • 664 views
ADD COMMENT

Login before adding your answer.

Traffic: 505 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6