rcavalcante / annotatr

Package Homepage: http://bioconductor.org/packages/devel/bioc/html/annotatr.html Bug Reports: https://support.bioconductor.org/p/new/post/?tag_val=annotatr.
26 stars 8 forks source link

hg19_cpgs negative width for inter-CGI #28

Closed mtanic closed 4 years ago

mtanic commented 4 years ago

Hi I was using hg19_cpgs annotations for CGI, shelves, shores and inter-CGI regions but when counting the size of each feature type I get negative values for inter-CGI regions. I am not sure how is this possible?

When I make separate annotations for each feature category and count width and compare it to the either the hg19_cpgs or manually mergeed GRangesList I get the same width for all features except for inter-CGI!

Do you know what could be the cause of this behaviour?

this is my code:

> annotations_CpGs.gr = build_annotations(genome = 'hg19', annotations = "hg19_cpgs")

# Make GRangesList object by splitting by type of annotation
annotations_CpGs.grl <- split(annotations_CpGs.gr, mcols(annotations_CpGs.gr)$type)
    names(annotations_CpGs.grl)

> sum(width(reduce(annotations_CpGs.grl)))
  hg19_cpg_inter hg19_cpg_islands hg19_cpg_shelves 
     -1368521925         21842742         87006497 
 hg19_cpg_shores 
       101866654 

    # Custom annotations:

>     annotations_CGI.gr = build_annotations(genome = 'hg19', annotations = "hg19_cpg_islands")
>     annotations_shores.gr = build_annotations(genome = 'hg19', annotations = "hg19_cpg_shores")
>     annotations_shelves.gr = build_annotations(genome = 'hg19', annotations = "hg19_cpg_shelves")
>     annotations_interCGI.gr = build_annotations(genome = 'hg19', annotations = "hg19_cpg_inter")

> sum(width(reduce(annotations_CGI.gr)))
[1] 21842742

> sum(width(reduce(annotations_shores.gr)))
[1] 101866654
> 
> sum(width(reduce(annotations_shelves.gr)))
[1] 87006497
> 
> sum(width(reduce(annotations_interCGI.gr)))
[1] 2926445371
> 

 # Merged
> annotations_CpGs.grl <- GRangesList("hg19_cpg_islands"=annotations_CGI.gr,"hg19_cpg_shores"=annotations_shores.gr,"hg19_cpg_shelves"=annotations_shelves.gr, "hg19_cpg_inter"=annotations_interCGI.gr )
> 
> # Size of each CGI feature
> sum(width(reduce(annotations_CpGs.grl)))
hg19_cpg_islands  hg19_cpg_shores hg19_cpg_shelves 
        21842742        101866654         87006497 
  hg19_cpg_inter 
     -1368521925 
rcavalcante commented 4 years ago

Good morning,

Thanks for your interest in annotatr. I have sort of a busy day, but I wanted to let you know that I saw this, and I'll take a look by Friday.

Raymond

mtanic commented 4 years ago

Thank you Raymond. I look forward gearing your comments.

mtanic commented 4 years ago

Hi Raymond,

I got the correct number when using lapply to get the total width on the same object that gives negative values for inter-CGI, but have no idea why it behaves differently?!

lapply(annotations_CpGs.grl, function(x) sum(width(reduce(x))))
$hg19_cpg_islands
[1] 21842742

$hg19_cpg_shores
[1] 101866654

$hg19_cpg_shelves
[1] 87006497

$hg19_cpg_inter
[1] 2926445371

> sum(width(reduce(annotations_CpGs.grl)))
hg19_cpg_islands  hg19_cpg_shores hg19_cpg_shelves 
        21842742        101866654         87006497 
  hg19_cpg_inter 
     -1368521925 
rcavalcante commented 4 years ago

Very interesting. I don't really know why this would happen, but suspect that it's something to do with the GRangesList object and how the functions operate on it, rather than having something to do with the annotatr package per se.

If you don't mind, I'll go ahead and close the issue.