Question: Bioconductor R And Input File Issue
0
gravatar for madkitty
5.5 years ago by
madkitty530
Canada
madkitty530 wrote:

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 • 3.4k views
ADD COMMENTlink modified 5.5 years ago by Michael Dondrup43k • written 5.5 years ago by madkitty530

Try again if you like :)

ADD REPLYlink written 5.5 years ago by Michael Dondrup43k
4
gravatar for Michael Dondrup
5.5 years ago by
Bergen, Norway
Michael Dondrup43k wrote:

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 COMMENTlink modified 5.5 years ago • written 5.5 years ago by Michael Dondrup43k

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 REPLYlink written 5.5 years ago by madkitty530

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 REPLYlink written 5.5 years ago by Michael Dondrup43k

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

ADD REPLYlink written 5.5 years ago by madkitty530
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1424 users visited in the last hour