Call an input file doesn't work

I'm using Gviz library from bioconductor. I input a tab delimited file containing CNV position that I need to plot on my chromosome ideogram.

My input file is defined by dat and has 4 columns

  • [1] chromosome
  • [2] start
  • [3] end
  • [4] width (could '+' or '-' depending on the orientation of the Copy Number)

So I did that :

gen <- "mm9"
chr <- "chr1"

itrack <- IdeogramTrack(genome = gen, chromosome = chr)
gtrack <- GenomeAxisTrack()

dat <- read.delim("C:/R/1ips_chr1.txt", header = FALSE, sep ="\t")
s <- dat[2]
e <- dat[3]
l <- dat[4]

It shows an error message when I call the file dat :

atrack1 <- AnnotationTrack( start = s, width = l , chromosome = chr, genome = gen, name =  "Sample1")
Error : function (classes, fdef, mtable)  : unable to find an inherited method for function ".buildRange", for signature "NULL", "data.frame", "NULL", "data.frame"

Obviously the way I call a the inputed file (in dat) doesn't satisfy R .. Someone help me please :)


From the reference manual for the Gviz package (with which I am not familiar), the arguments start and width in the AnnotationTrack function need to be integer vectors. When you subset dat using the single square bracket [, the resulting object is a data.frame (see ?`[.data.frame` for more on this). Try instead

s <- dat[[2]]
e <- dat[[3]]
l <- dat[[4]]

to obtain integer vectors.

Need Your Help

convert MFC's CString to int for both ASCII and UNICODE

c++ unicode mfc ascii c-strings

Converting CString to an int in ASCII mode is as simple as