Question: Subsetting genomic ranges and plotting cirlces in ggbio used to work --- now: warnings about non-missing arguments
0
gravatar for reviewer3
5.4 years ago by
reviewer320
United States
reviewer320 wrote:

I'm plotting genomic ranges in circle layout using ggbio to connect items from different categories/chromosomes via the metadata column "cross", itself an GRanges column.

cp <- ggplot() + layout_circle(gr.cats, geom = "ideo", fill = "white", radius = 30, trackWidth = 4)

cp.link<- cp + layout_circle(gr.all[seqnames(gr.all) == "1_CH"], geom = "link", linked.to="cross", col=red, radius = 28, trackWidth = 1)

Unfortunately, I get a small number of identical warnings.

In FUN(X[[25L]], ...) : no non-missing arguments to max; returning -Inf

When I execute the plot cp.link, i get a plot identical to cp alone and the following message:

Warning message:
Removed 10527 rows containing missing values (geom_path). 

This has worked previously and now I've spent a day already looking for the bug. Any guesses are welcome, thanks!

UPDATE: my dummy example reproduces this error as soon as I try to process each chr separately - why? Thank you:

gr.cats<-GRanges(seqnames=c("chr1", "chr2", "chr3"), IRanges(start=rep(1,3), width=rep(100,3)), strand=rep("*", 3))

seqlengths(gr.cats)<-rep(100,3)

gr.cats

GRanges with 3 ranges and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1  [1, 100]      *
  [2]     chr2  [1, 100]      *
  [3]     chr3  [1, 100]      *
  ---
  seqlengths:
   chr1 chr2 chr3
    100  100  100

gr.all<-GRanges(seqnames=c(rep("chr1",100), rep("chr2",100), rep("chr3",100)), IRanges(start=rep(seq(1,100),3), width=rep(1,300)), strand=rep("*", 300))

seqlengths(gr.all)<-rep(100,3)

gr.cross<-GRanges(seqnames=c(rep("chr2",100), rep("chr3",100), rep("chr1",100)), IRanges(start=rep(seq(1,100),3), width=rep(1,300)), strand=rep("*", 300))

seqlengths(gr.cross)<-rep(100,3)

values(gr.all)$cross<-gr.cross

gr.all


GRanges with 300 ranges and 1 metadata column:
        seqnames     ranges strand   |             cross
           <Rle>  <IRanges>  <Rle>   |         <GRanges>
    [1]     chr1     [1, 1]      *   |     chr2:*:[1, 1]
    [2]     chr1     [2, 2]      *   |     chr2:*:[2, 2]
    [3]     chr1     [3, 3]      *   |     chr2:*:[3, 3]
    [4]     chr1     [4, 4]      *   |     chr2:*:[4, 4]
    [5]     chr1     [5, 5]      *   |     chr2:*:[5, 5]
    ...      ...        ...    ... ...               ...
  [296]     chr3 [ 96,  96]      *   | chr1:*:[ 96,  96]
  [297]     chr3 [ 97,  97]      *   | chr1:*:[ 97,  97]
  [298]     chr3 [ 98,  98]      *   | chr1:*:[ 98,  98]
  [299]     chr3 [ 99,  99]      *   | chr1:*:[ 99,  99]
  [300]     chr3 [100, 100]      *   | chr1:*:[100, 100]
  ---
  seqlengths:
   chr1 chr2 chr3
    100  100  100

Now, when I run the layout_circle command on all of gr.all it works, but when I subset for a specific chr, it fails:

cp.link <- cp + layout_circle(gr.all, geom = "link",  linked.to = "cross", col=rgb(1,0,0,0.05), radius = 28, trackWidth = 1)


layout_circle() is now a lower level component to transform a
           linear object, and please check circle() for easier API

cp.link.chr1 <- cp + layout_circle(gr.all[seqnames(gr.all) == "chr1"], geom = "link",  linked.to = "cross", col=rgb(1,0,0,0.05), radius = 28, trackWidth = 1)


layout_circle() is now a lower level component to transform a
           linear object, and please check circle() for easier API
Warning messages:
1: In FUN(X[[3L]], ...) : no non-missing arguments to max; returning -Inf
2: In FUN(X[[3L]], ...) : no non-missing arguments to max; returning -Inf

cp.link.chr1


Warning message:
Removed 2900 rows containing missing values (geom_path). 

genomic ranges ggplot2 ggbio • 3.7k views
ADD COMMENTlink modified 4.3 years ago by Biostar ♦♦ 20 • written 5.4 years ago by reviewer320
0
gravatar for mviterson
5.3 years ago by
mviterson0
Netherlands
mviterson0 wrote:

updating the seqlevels of GRanges to.gr should work. Something like this:

gr.chr1 <- gr.all[seqnames(gr.all) == "chr1"]

##update seqlevels to.gr
to.gr <- mcols(gr.chr1)$to.gr
to.gr <- keepSeqlevels(to.gr, as.character(unique(runValue(seqnames(to.gr)))))
mcols(gr.chr1)$to.gr <- to.gr

cp.link.chr1 <- cp + layout_circle(gr.chr1, geom = "link",  linked.to = "cross", col=rgb(1,0,0,0.05), radius = 28, trackWidth = 1)

 

ADD COMMENTlink written 5.3 years ago by mviterson0
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: 1893 users visited in the last hour