Bioconductor R And Input File Issue
1
0
Entering edit mode
12.5 years ago
madkitty ▴ 690

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 :)

r • 6.4k views
ADD COMMENT
0
Entering edit mode

Try again if you like :)

ADD REPLY
4
Entering edit mode
12.5 years ago
Michael 55k

I have edited your code, you were missing some , in a matrix, columns are selected like this.

Edit to deal with negative width and start>stop issues try to insert this code before making the annotation track:

s[s>e] <- e
e <- abs(e)
ADD COMMENT
0
Entering edit mode

Oh thanks! BTW .. We have a lot of negative width .. if I invert the start and end position this is gonna be a pain. Is there a way to pass negative value to IRange ?

ADD REPLY
0
Entering edit mode

You must make sure your width is not negative, and that start < end, otherwise:

IRanges(start=10,width=-3) Error in .Call2("solve_user_SEW0", start, end, width, PACKAGE = "IRanges") : solving row 1: negative widths are not allowed

ADD REPLY
0
Entering edit mode

I inverted start and end whenever we have a negative width, that worked like a charm! Thanks :)

ADD REPLY

Login before adding your answer.

Traffic: 2105 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6