-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.4 Upset.R
50 lines (40 loc) · 1.64 KB
/
3.4 Upset.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
library(Biostrings)
library(dplyr)
library(IRanges)
library(Repitools)
library(rtracklayer)
library(UpSetR)
gen <- readDNAStringSet("~/Desktop/Nanopore/References/GCA_000001405.15_GRCh38_no_alt_analysis_set.fa")
gen_len <- width(x = gen)
names(x = gen_len) <- sub(pattern = " .*", replacement = "", x = names(x = gen))
gen_bin <- genomeBlocks(genome = gen_len, width = 2000)
annotation <- function(file) {
annot <- import(con = file) %>% .[.$type == "transcript", ]
annot <- subsetByOverlaps(x = annot, ranges = gen_bin)
annot <- annot[annot$type == "transcript", ]
return(annot)
}
Bambu <- annotation(file = "~/Desktop/Nanopore/References/annotations_bambu.gtf")
FLAIR <- annotation(file = "~/Desktop/Nanopore/References/annotations_flair.gtf")
IsoQuant <- annotation(file = "~/Desktop/Nanopore/References/annotations_isoquant.gtf")
StringTie <- annotation(file = "~/Desktop/Nanopore/References/annotations_StringTie.gtf")
overlaps <- function(annotation) {
overlap <- queryHits(x = findOverlaps(query = gen_bin, subject = annotation))
return(overlap)
}
Bambu <- overlaps(annotation = Bambu)
FLAIR <- overlaps(annotation = FLAIR)
IsoQuant <- overlaps(annotation = IsoQuant)
StringTie <- overlaps(annotation = StringTie)
overlap <- list(Bambu = Bambu, FLAIR = FLAIR, IsoQuant = IsoQuant, StringTie = StringTie)
bin_mat <- fromList(input = overlap)
pdf(file = "~/Desktop/Nanopore/Benchmarking/3.4 Upset.pdf", width = 11, height = 8.5, family = "Helvetica")
options(scipen = 999)
upset(
data = bin_mat,
mainbar.y.label = "Overlapping isoform coordinates",
point.size = 4,
order.by = "freq",
text.scale = c(3, 2.5, 2.5, 1.5, 2.5, 1.5)
)
dev.off()