Last updated: 2020-04-27
Checks: 6 1
Knit directory: MINTIE-paper-analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.6.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish
to commit the R Markdown file and build the HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200415)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 1096df5. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: R/
Ignored: analysis/.DS_Store
Ignored: analysis/cache/
Ignored: code/.DS_Store
Ignored: data/.DS_Store
Ignored: data/simu/.DS_Store
Ignored: data/simu/results/.DS_Store
Ignored: data/simu/results/MINTIE/.DS_Store
Ignored: data/simu/results/TAP/.sv.bedpe.swp
Ignored: data/simu/truth/.DS_Store
Ignored: data/simu/truth/.allvars_fusions_simulated.tsv.swp
Ignored: data/simu/truth/.allvars_tsvs_splice_simulated.tsv.swp
Ignored: data/simu/truth/.swp
Unstaged changes:
Modified: .gitignore
Modified: analysis/Simulation_Benchmarking.Rmd
Modified: analysis/_site.yml
Modified: code/simu_helper.R
Modified: data/simu/truth/allvars_fusions_simulated.tsv
Modified: data/simu/truth/allvars_tsvs_splice_simulated.tsv
Modified: data/simu/truth/hg19_bg_gene_ref.tsv
Staged changes:
Renamed1: data/simu/truth/hg19_liftover/background_genes.bed
Renamed2: data/simu/truth/hg19_bg_gene_ref.tsv
Deleted: data/simu/truth/hg19_liftover/fus_loc1.bed
Deleted: data/simu/truth/hg19_liftover/fus_loc2.bed
Deleted: data/simu/truth/hg19_liftover/tsv_nsv.bed
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/Simulation_Benchmarking.Rmd
) and HTML (docs/Simulation_Benchmarking.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | 663689c | Marek Cmero | 2020-04-23 | Build site. |
Rmd | e57763b | Marek Cmero | 2020-04-23 | Initial commit |
html | e57763b | Marek Cmero | 2020-04-23 | Initial commit |
# util
library(data.table)
library(dplyr)
library(here)
# plotting
library(ggplot2)
# bioinformatics helpers
library(GenomicRanges)
library(Rsamtools)
source(here("code/simu_helper.R"))
source(here("code/plot.R"))
options(stringsAsFactors = FALSE)
Here we analyse the results on a simulated data set of 1,500 variants containing fusions, transcribed structural variants and novel splice variants, across 8 methods: MINTIE, TAP, Barnacle, SQUID, JAFFA, Arriba, StringTie and KisSplice.
The plots show the number of variants detected from each category and the number of false positives. The number of background genes detected in the false positives in displayed as printed output.
fus_truth <- read.delim(here("data/simu/truth/allvars_fusions_simulated.tsv"))
tsv_nsv_truth <- read.delim(here("data/simu/truth/allvars_tsvs_splice_simulated.tsv"))
all_gene_locs <- read.delim(gzfile(here("data/simu/all_gene_locs.tsv.gz")))
bg_gene_ref <- read.delim(here("data/simu/truth/bg_gene_ref.tsv"))
# extract truth and background gene names
var_genes_truth <- unique(c(fus_truth$gene1, fus_truth$gene2, tsv_nsv_truth$gene))
var_genes_truth <- var_genes_truth[var_genes_truth != ""]
bg_genes <- bg_gene_ref$gene
# make Genomic Ranges objects from data
fus_grx <- get_granges(fus_truth)
tsv_nsv_grx <- get_granges(tsv_nsv_truth)
bgenes_grx <- get_granges(bg_gene_ref, convert_chrom = TRUE, add_chr = FALSE)
all_gene_grx <- get_granges(all_gene_locs, convert_chrom = TRUE, add_chr = FALSE)
# create results object
nsv_names <- c("Extended exon",
"Novel exon",
"Retained intron",
"Truncated exon",
"Unknown splice")
tsv_names <- c("Deletion",
"Insertion",
"Internal tandem duplication",
"Partial tandem duplication",
"Inversion")
fus_names <- c("Fusion (canonical)",
"Fusion (EE)",
"Fusion (NE)",
"Fusion (insertion)",
"Fusion (unpartnered)")
vartypes <- c("False positive", nsv_names, tsv_names, fus_names)
classes <- c("False positive",
"Novel splice variant",
"Transcribed structural variant",
"Fusion")
results <- data.frame(vartype = factor(vartypes, levels = vartypes),
class = factor(c(classes[1], rep(classes[2:4], each=5)),
levels = classes[4:1]),
row.names = c("FP", "EE", "NE", "RI", "NEJ", "US",
"DEL", "INS", "ITD", "PTD", "INV",
"canonical_fusion", "EE_fusion",
"NE_fusion", "INS_fusion", "unpartnered_fusion"))
cols <- c("#87649aff", "#bdd888ff", "#e7d992ff", "#636363")
names(cols) <- c("Fusion", "Transcribed structural variant", "Novel splice variant", "False positive")
# load data
mintie_results <- read.delim(here("data/simu/results/MINTIE/allvars-case_results.tsv"))
mintie_results <- mintie_results[mintie_results$logFC > 5,]
# extract genes
mintie_vargenes <- sapply(mintie_results$overlapping_genes, function(x){strsplit(x, "\\||:")[[1]]})
mvg <- unlist(mintie_vargenes)
# count found fusions, TSVs and NSVs
found_fus <- table(fus_truth$fusion_type[fus_truth$gene1 %in% mvg | fus_truth$gene2 %in% mvg])
found_tsv <- table(tsv_nsv_truth$vartype[tsv_nsv_truth$gene %in% mvg])
# count false positives genes
fp <- sapply(mintie_vargenes, function(x){!any(x %in% var_genes_truth)})
fp_genes <- unlist(sapply(mintie_results$overlapping_genes[fp], function(x){strsplit(x, "\\||:")}))
fp_genes <- fp_genes[fp_genes != ""]
n_fp <- length(unique(fp_genes))
results <- append_results(results, "MINTIE", found_fus, found_tsv, n_fp)
print(paste("Background genes in FPs:", sum(unique(fp_genes) %in% bg_genes)))
[1] "Background genes in FPs: 1"
plot_simu_benchmarking(results, "MINTIE")
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
# load result data
tap_svs <- read.delim(here("data/simu/results/TAP/sv.bedpe"), sep = "\t", skip = 2)
tap_nsv <- read.delim(here("data/simu/results/TAP/novel_splicing.bedpe"), sep = "\t", skip = 2)
# extract variant genes
tap_vargenes <- Reduce(union, list(tap_svs$gene1, tap_svs$gene2, tap_nsv$gene))
# count found fusions, TSVs and NSVs
found_fus <- table(fus_truth$fusion_type[fus_truth$gene1 %in% tap_vargenes | fus_truth$gene2 %in% tap_vargenes])
found_tsv <- table(tsv_nsv_truth$vartype[tsv_nsv_truth$gene %in% tap_vargenes])
# count false positives genes
fp_svs <- tap_svs[!tap_svs$gene1 %in% var_genes_truth & !tap_svs$gene2 %in% var_genes_truth,]
fp_nsv <- tap_nsv[!tap_nsv$gene1 %in% var_genes_truth & !tap_nsv$gene2 %in% var_genes_truth,]
fp_genes <- unique(c(fp_svs$gene1, fp_svs$gene2, fp_nsv$gene1, fp_nsv$gene2))
n_fp <- length(fp_genes)
results <- append_results(results, "TAP", found_fus, found_tsv, n_fp)
print(paste("Background genes in FPs:", sum(fp_genes %in% bg_genes)))
[1] "Background genes in FPs: 2"
plot_simu_benchmarking(results, "TAP")
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
# build hg19 version of truth data
# fusions
hg19_fus_truth <- fus_truth
hg19_fus_truth$loc1 <- hg19_fus_truth$hg19_loc1
hg19_fus_truth$loc2 <- hg19_fus_truth$hg19_loc2
hg19_fus_truth$loc1[hg19_fus_truth$loc1 == ""] <- "chrZ:1-2" #dummy record for blanks
hg19_fus_truth$loc2[hg19_fus_truth$loc2 == ""] <- "chrZ:1-2"
# TSVs/NSVs
hg19_tsv_nsv_truth <- tsv_nsv_truth
hg19_tsv_nsv_truth$loc <- hg19_tsv_nsv_truth$hg19_loc
hg19_tsv_nsv_truth$loc[hg19_tsv_nsv_truth$loc == ""] <- "chrZ:1-2"
# make Genomic Ranges objects
hg19_fus_grx <- get_granges(hg19_fus_truth, convert_chrom = FALSE)
hg19_tsv_nsv_grx <- get_granges(hg19_tsv_nsv_truth, convert_chrom = FALSE)
hg19_bg_gene_ref <- read.delim(here("data/simu/truth/hg19_bg_gene_ref.tsv"))
hg19_bgenes_grx <- get_granges(bg_gene_ref, convert_chrom = FALSE)
# load barnacle results and make Genomic Ranges objects
barnacle_results <- read.delim(here("data/simu/results/barnacle/allvars-case.barnacle.data"), header=FALSE)$V1
barnacle_results <- barnacle_results[grep("OVERLAPPING", barnacle_results)]
barnacle_grx_a <- get_barnacle_grx(barnacle_results)
barnacle_grx_b <- get_barnacle_grx(barnacle_results, side_A = FALSE)
# extract hits
hits <- get_hits(barnacle_grx_a, barnacle_grx_b,
hg19_fus_grx[[1]], hg19_fus_grx[[2]],
hg19_tsv_nsv_grx, hg19_bgenes_grx)
found_fus <- table(hg19_fus_truth[hits$fus_truth_hits,]$fusion_type)
found_tsv <- table(hg19_tsv_nsv_truth[hits$tsv_nsv_truth_hits,]$vartype)
fps <- !1:length(barnacle_grx_a) %in% unique(hits$caller_hits)
n_fp <- sum(fps)
results <- append_results(results, "Barnacle", found_fus, found_tsv, n_fp)
print(paste("Background genes in FPs:", sum(hits$bg_hits %in% which(fps))))
[1] "Background genes in FPs: 3"
plot_simu_benchmarking(results, "Barnacle")
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
# load data
squid_results <- read.delim(here("data/simu/results/squid/results_sv.txt"))
# make GRanges objects
chr1 <- sapply(squid_results$X..chrom1, convert_chrom, add_chr=FALSE)
loc1_grx <- GRanges(seqnames = chr1,
ranges = IRanges(start = squid_results$start1, end = squid_results$end1))
chr2 <- sapply(squid_results$chrom2, convert_chrom, add_chr=FALSE)
loc2_grx <- GRanges(seqnames = chr2,
ranges = IRanges(start = squid_results$start2, end = squid_results$end2))
# get hits
hits <- get_hits(loc1_grx, loc2_grx, fus_grx[[1]], fus_grx[[2]], tsv_nsv_grx, bgenes_grx)
found_fus <- table(fus_truth[hits$fus_truth_hits,]$fusion_type)
found_tsv <- table(tsv_nsv_truth[hits$tsv_nsv_truth_hits,]$vartype)
# get false positives
fps <- squid_results[!1:nrow(squid_results) %in% hits$caller_hits,]
fps <- fps[!(fps$X..chrom1 %like% "alt" | fps$chrom2 %like% "alt"),]
n_fp <- nrow(fps)
results <- append_results(results, "SQUID", found_fus, found_tsv, n_fp)
print(paste("Background genes in FPs:", sum(hits$bg_hits %in% as.numeric(rownames(fps)))))
[1] "Background genes in FPs: 0"
plot_simu_benchmarking(results, "SQUID")
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
# load data
jaffa_results <- read.delim(here("data/simu/results/JAFFA/jaffa_results.csv"), sep = ",")
# make GRanges objects
chr1 <- sapply(jaffa_results$chrom1, convert_chrom, add_chr=FALSE)
loc1_grx <- GRanges(seqnames = chr1,
ranges = IRanges(start = jaffa_results$base1, end = jaffa_results$base1))
chr2 <- sapply(jaffa_results$chrom1, convert_chrom, add_chr=FALSE)
loc2_grx <- GRanges(seqnames = chr2,
ranges = IRanges(start = jaffa_results$base2, end = jaffa_results$base2))
# get hits
hits <- get_hits(loc1_grx, loc2_grx, fus_grx[[1]], fus_grx[[2]], tsv_nsv_grx, bgenes_grx)
found_fus <- table(fus_truth[hits$fus_truth_hits,]$fusion_type)
found_tsv <- table(tsv_nsv_truth[hits$tsv_nsv_truth_hits,]$vartype)
# get false positives
fps <- jaffa_results[!rownames(jaffa_results) %in% hits$caller_hits,]
fps <- fps[!(fps$chrom1 %like% "alt" | fps$chrom2 %like% "alt"),]
fp_genes <- unlist(sapply(fps$fusion.genes, strsplit, split=":"))
n_fp <- length(unique(fp_genes))
results <- append_results(results, "JAFFA", found_fus, found_tsv, n_fp)
print(paste("Background genes in FPs:", sum(hits$bg_hits %in% as.numeric(rownames(fps)))))
[1] "Background genes in FPs: 0"
plot_simu_benchmarking(results, "JAFFA")
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
# load data
arriba_results <- read.delim(here("data/simu/results/arriba/fusions.tsv"))
# extract variasnt genes
arriba_vargenes1 <- sapply(arriba_results$X.gene1, get_arriba_genes)
arriba_vargenes2 <- sapply(arriba_results$gene2, get_arriba_genes)
avg <- unlist(list(arriba_vargenes1, arriba_vargenes2))
# tally results
found_tsv <- table(tsv_nsv_truth[tsv_nsv_truth$gene %in% avg,]$vartype)
found_fus <- table(fus_truth[fus_truth$gene1 %in% avg | fus_truth$gene2 %in% avg,]$fusion_type)
# get false positives
fp1 <- sapply(arriba_vargenes1, function(x){!any(x %in% var_genes_truth)})
fp2 <- sapply(arriba_vargenes2, function(x){!any(x %in% var_genes_truth)})
fp_genes1 <- arriba_vargenes1[fp1 & fp2]
fp_genes2 <- arriba_vargenes2[fp1 & fp2]
fp_genes <- unique(union(fp_genes1, fp_genes2))
n_fp <- length(fp_genes)
results <- append_results(results, "Arriba", found_fus, found_tsv, n_fp)
print(paste("Background genes in FPs:", sum(fp_genes%in% bgenes_grx$genes)))
[1] "Background genes in FPs: 0"
plot_simu_benchmarking(results, "Arriba")
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
# load data and extract transcripts marked as novel
stringtie_results <- read.delim(here("data/simu/results/StringTie/fullsimu.gtf"), comment="#", header=F)
stringtie_results <- stringtie_results[!stringtie_results$V9 %like% "ref_gene_id",]
stringtie_results <- stringtie_results[stringtie_results$V3 == "transcript",]
chrom <- sapply(stringtie_results$V1, convert_chrom, add_chr = FALSE)
stringtie_grx <- GRanges(seqnames = chrom,
ranges = IRanges(start = stringtie_results$V4,
end = stringtie_results$V5))
hits <- get_hits_oneloc(stringtie_grx, fus_grx[[1]], fus_grx[[2]], tsv_nsv_grx, bgenes_grx)
found_fus <- table(fus_truth[hits$fus_truth_hits,]$fusion_type)
found_tsv <- table(tsv_nsv_truth[hits$tsv_nsv_truth_hits,]$vartype)
# get false positives
fp_grx <- stringtie_grx[!1:length(hits$caller_hits) %in% hits$caller_hits]
fp_gene_hits <- all_gene_grx[subjectHits(findOverlaps(fp_grx, all_gene_grx))]
n_fp <- length(unique(fp_gene_hits$genes))
results <- append_results(results, "StringTie", found_fus, found_tsv, n_fp)
print(paste("Background genes in FPs:", sum(unique(fp_gene_hits$genes) %in% bgenes_grx$genes)))
[1] "Background genes in FPs: 1"
plot_simu_benchmarking(results, "StringTie")
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
# regenerate gene ranges objects "chr" prefix
# (this is required as KisSplice"s bam was aligned
# to a genome with chr prefixes)
fus_grx <- get_granges(fus_truth, convert_chrom = TRUE)
tsv_nsv_grx <- get_granges(tsv_nsv_truth, convert_chrom = TRUE)
bgenes_grx <- get_granges(bg_gene_ref, convert_chrom = FALSE)
# extract hits im fusion and TSV/NSV gene regions
bam <- here("data/simu/results/KisSplice/results.bam")
fus1_hits <- get_kissplice_hits(bam, fus_grx[[1]])
fus2_hits <- get_kissplice_hits(bam, fus_grx[[2]])
tsv_nsv_hits <- get_kissplice_hits(bam, tsv_nsv_grx)
# remame row names to match locations from results
rownames(fus_truth) <- sapply(fus_truth$loc1, convert_chrom)
rownames(tsv_nsv_truth) <- sapply(tsv_nsv_truth$loc, convert_chrom)
# tally results
found_fus <- table(fus_truth[names(fus1_hits)[fus1_hits | fus2_hits],]$fusion_type)
found_tsv <- table(tsv_nsv_truth[names(tsv_nsv_hits[tsv_nsv_hits]),]$vartype)
# count number of FP hits in background genes
# first, get all reads that we counted as "hits"
param <- ScanBamParam(which = c(fus_grx[[1]], fus_grx[[2]], tsv_nsv_grx),
what = c("pos"))
all_hits <- scanBam(bam, param = param)
all_hits <- unique(unlist(all_hits))
# now get all reads in the results and count all
# reads that were not counted as hits
param <- ScanBamParam(what = "pos")
all_results <- unique(scanBam(bam, param = param)[[1]]$pos)
fps <- all_results[!all_results %in% all_hits]
n_fp <- length(fps)
# count the numner of FPs in background genes
param <- ScanBamParam(which = bgenes_grx, what = c("pos"))
bg_hits <- scanBam(bam, param = param)
bg_hits <- bg_hits[as.numeric(bg_hits) %in% fps]
results <- append_results(results, "KisSplice", found_fus, found_tsv, n_fp)
print(paste("Background genes in FPs:", length(bg_hits)))
[1] "Background genes in FPs: 0"
plot_simu_benchmarking(results, "KisSplice")
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
MINTIE paper Figure 3 containing results from all benchmarked methods.
mr <- melt(results, id.vars = c("vartype", "class"), variable.name = "method")
mr$method <- factor(mr$method,
levels=c("MINTIE", "TAP", "Barnacle", "SQUID", "JAFFA", "Arriba", "KisSplice", "StringTie"))
plot_all_simu_benchmarks(mr)
Version | Author | Date |
---|---|---|
1096df5 | Marek Cmero | 2020-04-24 |
sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] Rsamtools_1.34.1 Biostrings_2.50.2 XVector_0.22.0
[4] GenomicRanges_1.34.0 GenomeInfoDb_1.18.2 IRanges_2.16.0
[7] S4Vectors_0.20.1 BiocGenerics_0.28.0 ggplot2_3.1.0
[10] here_0.1 dplyr_0.8.1 data.table_1.12.0
loaded via a namespace (and not attached):
[1] tidyselect_0.2.5 xfun_0.5 reshape2_1.4.3
[4] purrr_0.3.2 colorspace_1.4-1 htmltools_0.3.6
[7] yaml_2.2.0 rlang_0.4.2 later_1.0.0
[10] pillar_1.3.1 glue_1.3.1 withr_2.1.2
[13] BiocParallel_1.14.2 GenomeInfoDbData_1.2.0 plyr_1.8.4
[16] stringr_1.4.0 zlibbioc_1.28.0 munsell_0.5.0
[19] gtable_0.3.0 workflowr_1.6.1 codetools_0.2-16
[22] evaluate_0.13 labeling_0.3 knitr_1.22
[25] httpuv_1.5.2 Rcpp_1.0.1 promises_1.1.0
[28] scales_1.0.0 backports_1.1.3 fs_1.2.7
[31] digest_0.6.18 stringi_1.4.3 grid_3.5.1
[34] rprojroot_1.3-2 tools_3.5.1 bitops_1.0-6
[37] magrittr_1.5 lazyeval_0.2.2 RCurl_1.95-4.12
[40] tibble_2.1.1 crayon_1.3.4 whisker_0.3-2
[43] pkgconfig_2.0.2 assertthat_0.2.1 rmarkdown_1.12
[46] R6_2.4.0 git2r_0.26.1 compiler_3.5.1