Question: IdeogramTrack from Gviz with chromosome name "4" rather "chr4"
0
4.3 years ago by
tangming2005150
United States
tangming2005150 wrote:

I have to make the chromosome name to "4" rather "chr4" because my dataTrack 's chromosome names are numbers without "chr". I read the tutorial, and did the following, but it did not work.  Thank you for your help.

Ming

options(ucscChromosomeNames=FALSE)

itrack<- IdeogramTrack(genome = "hg19", chromosome = 4)
Error in .local(.Object, ...) :
Chromosome '4' does not exist on UCSC genome 'hg19'
gviz • 1.6k views
modified 4.3 years ago by Robert Ivanek650 • written 4.3 years ago by tangming2005150
Answer: IdeogramTrack from Gviz with chromosome name "4" rather "chr4"
1
4.3 years ago by
Robert Ivanek650
Switzerland
Robert Ivanek650 wrote:

I guess it is a bit counter-intuitive however the IdeogramTrack function is building the ideogram based on UCSC and they use "chr" as a part of the chromosome names. However if you set the option ucscChromosomeNames to FALSE before calling the IdeogramTrack function, then the plot will show "Chromosome 4" as name for the IdeogramTrack.

options(ucscChromosomeNames=FALSE)
itrack <- IdeogramTrack(genome = "hg19", chromosome = "chr4")
plotTracks(itrack, from=45e6, to=46e6)

Thanks for your answer. I know that it is build on UCSC. The problem is that my data track's chromosome name is only numbers,

when I plot my dataTrack and the IdeogramTrack together, it complains that the chromosomes are different....

1

I see, in that case the fastest fix can be something like this:

levels(itrack@bandTable$chrom) <- sub("^chr", "", levels(itrack@bandTable$chrom), ignore.case=T)


This would remove the "chr" from the original chromosome names in the IdeogramTrack.

However I noticed that you are using current version of the biomart which is for human genome using the GRCh38.p3 but you built IdeogramTrack from older genome version from UCSC (hg19). Maybe it is safer to use the same one?

Here is example code which shows also dummy data track on chromosome 4.

library(Gviz)
options(ucscChromosomeNames=FALSE)
itrack <- IdeogramTrack(genome = "hg38", chromosome = "chr4")
levels(itrack@bandTable$chrom) <- sub("^chr", "", levels(itrack@bandTable$chrom), ignore.case=T)
dtrack <- DataTrack(range=GRanges("4", IRanges(45.5e6, width=1), e=100))
plotTracks(list(itrack,dtrack), from=45e6, to=46e6, chromosome="4")

Thank you for the answer! I am aware that biomart is using the newest genome build, and I will have to use an older version of biomart database when I put the IdeogramTrack from hg19 together.

it worked for your example. But when i feed into a bam file. it still complains. any ideas why?

options(ucscChromosomeNames=FALSE)
bam_track <- DataTrack(range = RNAseq_bam,
genome = "hg19",
type = "polygon",
name = "Coverage",
window = -1,
chromosome = "4")
itrack <- IdeogramTrack(genome = "hg19", chromosome = "chr4")
levels(itrack@bandTable$chrom) <- sub("^chr", "", levels(itrack@bandTable$chrom), ignore.case=T)
plotTracks(list(itrack, bam_track), from =48833082, to = 48863265)
Updating chromosome band information
Warning message:
In plotTracks(list(itrack, bam_track), from = 48833082, to = 48863265) :
The track chromosomes in 'trackList' differ. Setting all tracks to chromosome 'chr4'

I figured it out that I have to do this also to make it work:

itrack@chromosome<-"4"