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 :
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] # need to select col 2 this way
e <- dat[,3]
l <- dat[,4]
s[s>e] <- e # start < end?
l <- abs(l) # no negative length allowed
It shows an error message when I call the file dat to determine start and width (or end) position of the Copy Number:
# an annotation is made from a ranges object
atrack1 <- AnnotationTrack(IRanges( 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"
I'm a R newbie, please someone tell me how to use columns within an input file !
Thanks :)
Try again if you like :)