Hi everyone,

I am trying to plot genomic regions using KaryoplotR. I have been following the tutorial page, I converted my data frame into Granges object, however the tool does not work with my data.
My data frame is simply a list of genomic location ['chr', 'start', 'end']

The following script doesn't give any warning or error message and only plots the chromosomes but not the genomic regions:

    library(karyoploteR)
    library(GenomicRanges)
    library(data.table)
    
    setwd("/path/to/dataframe") 
    
    
    df <- fread("for_ideogram.csv", header = T)
    
    gr <- makeGRangesFromDataFrame(df, start.field="start",  end.field= "end")
    
    kp <- plotKaryotype(genome = "hg19", chromosomes="autosomal", plot.type = 1)
    
    kpPlotRegions(kp, data=gr)

Does anyone know how to get this to work?

Thanks
Hi @gabi,

When karyoploteR creates the ideogram but nothing gets added to it with the other plotting functions, in many cases it is due to different chromosome names. 

Are your gr chromosome names in  UCSC style ("chr1", "chr2", ...) or in Ensembl/NCBI style ("1", "2", ...)? The default bioconductor chromosome names are UCSC style and these are the ones used by karyoploteR. 

Please check if adding `seqlevelsStyle(gr) <- "UCSC"` before plotting solves the problem. 

    library(karyoploteR)
    library(GenomicRanges)
    library(data.table)

    setwd("/path/to/dataframe") 


    df <- fread("for_ideogram.csv", header = T)

    gr <- makeGRangesFromDataFrame(df, start.field="start",  end.field= "end")
    seqlevelsStyle(gr) <- "UCSC"

    kp <- plotKaryotype(genome = "hg19", chromosomes="autosomal", plot.type = 1)
    kpPlotRegions(kp, data=gr)

and I don't know the structure of your csv file, but if the first 3 columns contain the chr, the start and the end positions (like a bed file and with any names) you can use [`toGRanges`](https://rdrr.io/bioc/regioneR/man/toGRanges.html) simplify you code to this (toGRanges will  change the chromosome names to the ones used by "hg19" in this case):

    library(karyoploteR)

    gr <- toGRanges("path/to/dataframe/for_ideogram.csv", genome="hg19") 

    kp <- plotKaryotype(genome = "hg19", chromosomes="autosomal", plot.type = 1)
    kpPlotRegions(kp, data=gr)


If this does not work, I'd need to see the first couple of lines for you csv file to understand what's going on.

