madkitty
madkitty

Reputation: 1675

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

So I did that :

library(IRanges)
libraray(Gviz)
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 :)

Upvotes: 1

Views: 1383

Answers (1)

BenBarnes
BenBarnes

Reputation: 19454

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.

Upvotes: 1

Related Questions