Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kpPlotGenes: Overlapping gene names margin increase #138

Open
Hanuphant opened this issue Apr 3, 2023 · 3 comments
Open

kpPlotGenes: Overlapping gene names margin increase #138

Hanuphant opened this issue Apr 3, 2023 · 3 comments

Comments

@Hanuphant
Copy link

Hanuphant commented Apr 3, 2023

Hi Bernat,

Thanks for this versatile tool. I had a query where we can adjust the gene margin a bit more to accommodate the gene names as well along with the names. I was hoping if someone could help me out in this regard.

The current plots that I have now look this.

image

image

I do understand the genes are too small to be plot and have labels, but I was hoping how I could increase the gap between overlapping gene names a bit more.

Attached is my code for plotting.

kp <- plotKaryotype(plot.type = 2, zoom = SNAPC3.region, cex = 1, plot.params = pp)
kpDataBackground(kp, data.panel = 1, col = "grey98")
kpPlotGenes(kp, gene.data, r0 = 0.2, r1 = 0.4, gene.name.cex = 0.8, data.panel = 2, gene.margin = 1, col = "darkmagenta", gene.name.col = "black", gene.name.position = "top")
kpDataBackground(kp, data.panel = 2, col = "grey98", r0 = 0.6, r1 = 0.7)
@Hanuphant Hanuphant changed the title kpPlotGenes: Overlapping gene names kpPlotGenes: Overlapping gene names margin increase Apr 3, 2023
@Hanuphant
Copy link
Author

Is there a way to subset gene.data based on the gene_ids so I can plot the gene ids I'd want. Something which works like this (obviously this doesn't work)?

gene.data <- gene.data$genes[gene.data$genes$gene_id %in% ranges.df[ranges.df$coverage == unique(ranges.df$coverage)[1],]$names]

@Hanuphant
Copy link
Author

I do see we can use Txdb objects to customize the gene names and was wondering how can I filter Txdb object so that I can get what I want?

@h20gg702
Copy link

Hi, I faced the same problem and found the solution. I used the following script to filter the gene which I want to.
Rplot01
Rplot03

`kp <- plotKaryotype(zoom = grW, cex=1, plot.type=2,
main=position)
kpAddBaseNumbers(kp, tick.dist = 10000, minor.tick.dist = 2000,
add.units = TRUE, cex=1, digits = 6)

genes.data <- makeGenesDataFromTxDb(TxDb.Hsapiens.UCSC.hg38.knownGene,
karyoplot=kp,
plot.transcripts = TRUE,
plot.transcripts.structure = TRUE)
###--- merge all trascripts of each gene into one and addGeneNames ---###
genes.data <- addGeneNames(genes.data)
genes.data <- mergeTranscripts(genes.data)

Keep only the gene data for gene "54507"

genes.data$genes <- genes.data$genes[genes.data$genes$gene_id == "54507", ]

Keep only the transcripts data for gene "54507"

genes.data$transcripts <- genes.data$transcripts["54507"]

kpPlotGenes(kp, data=genes.data, r0=0, r1=0.35, gene.name.cex = 1, data.panel = 1)`

I do see we can use Txdb objects to customize the gene names and was wondering how can I filter Txdb object so that I can get what I want?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants