From 428be3978b738135d9a547e60af7d2a33ae58d10 Mon Sep 17 00:00:00 2001 From: Petar Glazar Date: Tue, 25 Apr 2017 15:02:39 +0200 Subject: [PATCH] fixed the indexing bug that was assigning wrong gene_id for intergenic features. fixes #16 --- R/annotate.R | 6 +++--- inst/scripts/test_load_data.R | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/R/annotate.R b/R/annotate.R index 9146164..aca1287 100644 --- a/R/annotate.R +++ b/R/annotate.R @@ -200,10 +200,10 @@ annotateHostGenes <- function(se, genes.gr) { start(circ.ends.gr) <- end(circ.ends.gr) olap.start <- findOverlaps(circ.starts.gr, genes.gr, type = "within") - olap.end <- findOverlaps(circ.ends.gr, genes.gr, type = "within") + olap.end <- findOverlaps(circ.ends.gr, genes.gr, type = "within") - circs <- data.table(start.hit = names(circs.gr) %in% queryHits(olap.start), - end.hit = names(circs.gr) %in% queryHits(olap.end), + circs <- data.table(start.hit = 1:length(circs.gr) %in% queryHits(olap.start), + end.hit = 1:length(circs.gr) %in% queryHits(olap.end), id = circs.gr$id, ord = 1:length(circs.gr)) diff --git a/inst/scripts/test_load_data.R b/inst/scripts/test_load_data.R index fcf5bb6..935395d 100644 --- a/inst/scripts/test_load_data.R +++ b/inst/scripts/test_load_data.R @@ -18,8 +18,19 @@ circs.se <- summarizeCircs(colData = cdata, keep.linear = FALSE, wobble = 1, circs.se <- annotateCircs(se = circs.se, annot.list = annot.list, assembly = "hg19") +# issue16 +tmp <- resTable(circs.se) +tmp[feature == "intergenic:intergenic" & gene_id != "intergenic"] +tmp.gr <- GRanges(seqnames = tmp[feature == "intergenic:intergenic" & gene_id != "intergenic"][3:7,]$chr, + ranges = IRanges(start=tmp[feature == "intergenic:intergenic" & gene_id != "intergenic"][3:7]$start, + end=tmp[feature == "intergenic:intergenic" & gene_id != "intergenic"][3:7]$end), + strand = "-") + +tmp.gr <- range(tmp.gr) + + # find_circ2 -annot.list <- loadAnnotation("data/test.sqlite") +annot.list <- loadAnnotation("inst/extdata/db/test.sqlite") cdata <- data.frame(sample = c("D0", "D2", "D4"), filename = c("inst/extdata/Sy5y_D0_sites.bed", @@ -32,12 +43,26 @@ circs.se <- summarizeCircs(colData = cdata, wobble = 1, keepCols = 1:19) circs.se <- annotateCircs(se = circs.se, annot.list = annot.list, assembly = "hg19", fixCoordIndexing = T) - +# issue #16 histogram(circs.se, 0.5) annotPie(circs.se, 0.02) uniqReadsQC(circs.se, "all") +## issue #16 # +tmp <- resTable(circs.se) +tmp[feature=="intergenic:intergenic" & gene_id == "no_single_host"] +rowRanges(circs.se)[start(rowRanges(circs.se))==119107780] +rowRanges(circs.se)[start(rowRanges(circs.se))==180669210] + +rowRanges(circs.se)[start(rowRanges(circs.se)) %in% c(119107780, 180669210)] + +sub.se <- circs.se[c(which(start(rowRanges(circs.se)) %in% c(119107779, 180669209)), 200:300),] + + + + + # development #library(data.table) #library(GenomicRanges)