bernatgel / karyoploteR

karyoploteR - An R/Bioconductor package to plot arbitrary data along the genome
https://bernatgel.github.io/karyoploter_tutorial/
298 stars 42 forks source link

Bands with custom colors #50

Closed caonetto closed 4 years ago

caonetto commented 5 years ago

Hi, Thanks for developing the package looks great. I wonder if it’s possible to plot any sort of bands using custom colors? Something like the cytobands but input a bed file with regions and a column with colors associated to the type of region?

Thanks

bernatgel commented 5 years ago

Hi @caonetto

Sure, it's possible to plot any bands as the chromosomes bands. You can do it in two different ways:

caonetto commented 5 years ago

Thank you for your response, Is there any option to also plot data directly from lets say a gff file?? How do you upload all the associated data included in a GFF file from the loaded genome and plot densities of different things included in the gff file? Any idea of a tutorial that could be close enough to achieve this?

Thanks you.

bernatgel commented 5 years ago

So far GFF files are not directly supported. You'll need to use another package to convert them into an accepted format.

One possibility is to use rtracklayer::import to import a GFF and then filter the GRanges to obtain the different elements and plot the densities with kpPlotDensity. Something silinar to this (unfinished and untested code):

library(rtracklayer)
gff.data <- import("data.file.gff")
only.exons <- gff.data[gff.data$type=="exon"]
kp <- plotKaryotype()
kpPlotDensity(kp, data=only.exons)

On the other hand, if you have a GFF representing genes, you can call GenomicFeatures::makeTxDbFromGFF and then use the (unsufficiently documented at the moment) functions makeGenesDataFromTxDb and kpPlotGenes (and maybe addGeneNamesand mergeTranscripts) to plot the gene structures.