Last updated: 2024-06-24

Checks: 7 0

Knit directory: GibbsDTE-code/analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

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(20231211) 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 5b41ed5. 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:    .Rhistory
    Ignored:    .Rprofile
    Ignored:    .Rproj.user/
    Ignored:    .gitattributes
    Ignored:    .gitignore
    Ignored:    GibbsDTE-code.Rproj
    Ignored:    analysis/figure/
    Ignored:    code/lung/data/slurm-10678225.out
    Ignored:    code/lung/index-subread/.RData
    Ignored:    code/lung/index-subread/buildindex.Rout
    Ignored:    code/lung/index-subread/slurm-15397947.out
    Ignored:    code/lung/index-subread/slurm-15397948.out
    Ignored:    code/lung/index-subread/slurm-15397949.out
    Ignored:    code/lung/index/slurm-10679764.out
    Ignored:    code/lung/index/slurm-10679768.out
    Ignored:    code/lung/index/slurm-10684814.out
    Ignored:    code/lung/kallisto/slurm-16121443.out
    Ignored:    code/lung/salmon/.RData
    Ignored:    code/lung/salmon/runWasabi.Rout
    Ignored:    code/lung/salmon/slurm-15257704.out
    Ignored:    code/lung/salmon/slurm-15397973.out
    Ignored:    code/lung/salmon/slurm-15887027.out
    Ignored:    code/lung/subread/.nextflow.log
    Ignored:    code/lung/subread/.nextflow/
    Ignored:    code/lung/subread/log/
    Ignored:    code/lung/subread/report.html
    Ignored:    code/lung/subread/slurm-15398003.out
    Ignored:    code/lung/subread/timeline.html
    Ignored:    code/lung/subread/trace-20240201-45121600.txt
    Ignored:    code/pkg/.Rbuildignore
    Ignored:    code/pkg/.Rhistory
    Ignored:    code/pkg/.Rproj.user/
    Ignored:    code/pkg/pkg.Rproj
    Ignored:    code/pkg/src/.gitignore
    Ignored:    code/pkg/src/RcppExports.o
    Ignored:    code/pkg/src/pkg.so
    Ignored:    code/pkg/src/rcpparma_hello_world.o
    Ignored:    code/simulation/.RData
    Ignored:    code/simulation/slurm-15466798.out
    Ignored:    code/simulation/slurm-15466799_1.out
    Ignored:    code/simulation/slurm-15466799_10.out
    Ignored:    code/simulation/slurm-15466799_100.out
    Ignored:    code/simulation/slurm-15466799_101.out
    Ignored:    code/simulation/slurm-15466799_102.out
    Ignored:    code/simulation/slurm-15466799_103.out
    Ignored:    code/simulation/slurm-15466799_104.out
    Ignored:    code/simulation/slurm-15466799_105.out
    Ignored:    code/simulation/slurm-15466799_106.out
    Ignored:    code/simulation/slurm-15466799_107.out
    Ignored:    code/simulation/slurm-15466799_108.out
    Ignored:    code/simulation/slurm-15466799_109.out
    Ignored:    code/simulation/slurm-15466799_11.out
    Ignored:    code/simulation/slurm-15466799_110.out
    Ignored:    code/simulation/slurm-15466799_111.out
    Ignored:    code/simulation/slurm-15466799_112.out
    Ignored:    code/simulation/slurm-15466799_113.out
    Ignored:    code/simulation/slurm-15466799_114.out
    Ignored:    code/simulation/slurm-15466799_115.out
    Ignored:    code/simulation/slurm-15466799_116.out
    Ignored:    code/simulation/slurm-15466799_117.out
    Ignored:    code/simulation/slurm-15466799_118.out
    Ignored:    code/simulation/slurm-15466799_119.out
    Ignored:    code/simulation/slurm-15466799_12.out
    Ignored:    code/simulation/slurm-15466799_120.out
    Ignored:    code/simulation/slurm-15466799_121.out
    Ignored:    code/simulation/slurm-15466799_122.out
    Ignored:    code/simulation/slurm-15466799_123.out
    Ignored:    code/simulation/slurm-15466799_124.out
    Ignored:    code/simulation/slurm-15466799_125.out
    Ignored:    code/simulation/slurm-15466799_126.out
    Ignored:    code/simulation/slurm-15466799_127.out
    Ignored:    code/simulation/slurm-15466799_128.out
    Ignored:    code/simulation/slurm-15466799_129.out
    Ignored:    code/simulation/slurm-15466799_13.out
    Ignored:    code/simulation/slurm-15466799_130.out
    Ignored:    code/simulation/slurm-15466799_131.out
    Ignored:    code/simulation/slurm-15466799_132.out
    Ignored:    code/simulation/slurm-15466799_133.out
    Ignored:    code/simulation/slurm-15466799_134.out
    Ignored:    code/simulation/slurm-15466799_135.out
    Ignored:    code/simulation/slurm-15466799_136.out
    Ignored:    code/simulation/slurm-15466799_137.out
    Ignored:    code/simulation/slurm-15466799_138.out
    Ignored:    code/simulation/slurm-15466799_139.out
    Ignored:    code/simulation/slurm-15466799_14.out
    Ignored:    code/simulation/slurm-15466799_140.out
    Ignored:    code/simulation/slurm-15466799_141.out
    Ignored:    code/simulation/slurm-15466799_142.out
    Ignored:    code/simulation/slurm-15466799_143.out
    Ignored:    code/simulation/slurm-15466799_144.out
    Ignored:    code/simulation/slurm-15466799_145.out
    Ignored:    code/simulation/slurm-15466799_146.out
    Ignored:    code/simulation/slurm-15466799_147.out
    Ignored:    code/simulation/slurm-15466799_148.out
    Ignored:    code/simulation/slurm-15466799_149.out
    Ignored:    code/simulation/slurm-15466799_15.out
    Ignored:    code/simulation/slurm-15466799_150.out
    Ignored:    code/simulation/slurm-15466799_151.out
    Ignored:    code/simulation/slurm-15466799_152.out
    Ignored:    code/simulation/slurm-15466799_153.out
    Ignored:    code/simulation/slurm-15466799_154.out
    Ignored:    code/simulation/slurm-15466799_155.out
    Ignored:    code/simulation/slurm-15466799_156.out
    Ignored:    code/simulation/slurm-15466799_157.out
    Ignored:    code/simulation/slurm-15466799_158.out
    Ignored:    code/simulation/slurm-15466799_159.out
    Ignored:    code/simulation/slurm-15466799_16.out
    Ignored:    code/simulation/slurm-15466799_160.out
    Ignored:    code/simulation/slurm-15466799_161.out
    Ignored:    code/simulation/slurm-15466799_162.out
    Ignored:    code/simulation/slurm-15466799_163.out
    Ignored:    code/simulation/slurm-15466799_164.out
    Ignored:    code/simulation/slurm-15466799_165.out
    Ignored:    code/simulation/slurm-15466799_166.out
    Ignored:    code/simulation/slurm-15466799_167.out
    Ignored:    code/simulation/slurm-15466799_168.out
    Ignored:    code/simulation/slurm-15466799_169.out
    Ignored:    code/simulation/slurm-15466799_17.out
    Ignored:    code/simulation/slurm-15466799_170.out
    Ignored:    code/simulation/slurm-15466799_171.out
    Ignored:    code/simulation/slurm-15466799_172.out
    Ignored:    code/simulation/slurm-15466799_173.out
    Ignored:    code/simulation/slurm-15466799_174.out
    Ignored:    code/simulation/slurm-15466799_175.out
    Ignored:    code/simulation/slurm-15466799_176.out
    Ignored:    code/simulation/slurm-15466799_177.out
    Ignored:    code/simulation/slurm-15466799_178.out
    Ignored:    code/simulation/slurm-15466799_179.out
    Ignored:    code/simulation/slurm-15466799_18.out
    Ignored:    code/simulation/slurm-15466799_180.out
    Ignored:    code/simulation/slurm-15466799_181.out
    Ignored:    code/simulation/slurm-15466799_182.out
    Ignored:    code/simulation/slurm-15466799_183.out
    Ignored:    code/simulation/slurm-15466799_184.out
    Ignored:    code/simulation/slurm-15466799_185.out
    Ignored:    code/simulation/slurm-15466799_186.out
    Ignored:    code/simulation/slurm-15466799_187.out
    Ignored:    code/simulation/slurm-15466799_188.out
    Ignored:    code/simulation/slurm-15466799_189.out
    Ignored:    code/simulation/slurm-15466799_19.out
    Ignored:    code/simulation/slurm-15466799_190.out
    Ignored:    code/simulation/slurm-15466799_191.out
    Ignored:    code/simulation/slurm-15466799_192.out
    Ignored:    code/simulation/slurm-15466799_193.out
    Ignored:    code/simulation/slurm-15466799_194.out
    Ignored:    code/simulation/slurm-15466799_195.out
    Ignored:    code/simulation/slurm-15466799_196.out
    Ignored:    code/simulation/slurm-15466799_197.out
    Ignored:    code/simulation/slurm-15466799_198.out
    Ignored:    code/simulation/slurm-15466799_199.out
    Ignored:    code/simulation/slurm-15466799_2.out
    Ignored:    code/simulation/slurm-15466799_20.out
    Ignored:    code/simulation/slurm-15466799_200.out
    Ignored:    code/simulation/slurm-15466799_21.out
    Ignored:    code/simulation/slurm-15466799_22.out
    Ignored:    code/simulation/slurm-15466799_23.out
    Ignored:    code/simulation/slurm-15466799_24.out
    Ignored:    code/simulation/slurm-15466799_25.out
    Ignored:    code/simulation/slurm-15466799_26.out
    Ignored:    code/simulation/slurm-15466799_27.out
    Ignored:    code/simulation/slurm-15466799_28.out
    Ignored:    code/simulation/slurm-15466799_29.out
    Ignored:    code/simulation/slurm-15466799_3.out
    Ignored:    code/simulation/slurm-15466799_30.out
    Ignored:    code/simulation/slurm-15466799_31.out
    Ignored:    code/simulation/slurm-15466799_32.out
    Ignored:    code/simulation/slurm-15466799_33.out
    Ignored:    code/simulation/slurm-15466799_34.out
    Ignored:    code/simulation/slurm-15466799_35.out
    Ignored:    code/simulation/slurm-15466799_36.out
    Ignored:    code/simulation/slurm-15466799_37.out
    Ignored:    code/simulation/slurm-15466799_38.out
    Ignored:    code/simulation/slurm-15466799_39.out
    Ignored:    code/simulation/slurm-15466799_4.out
    Ignored:    code/simulation/slurm-15466799_40.out
    Ignored:    code/simulation/slurm-15466799_41.out
    Ignored:    code/simulation/slurm-15466799_42.out
    Ignored:    code/simulation/slurm-15466799_43.out
    Ignored:    code/simulation/slurm-15466799_44.out
    Ignored:    code/simulation/slurm-15466799_45.out
    Ignored:    code/simulation/slurm-15466799_46.out
    Ignored:    code/simulation/slurm-15466799_47.out
    Ignored:    code/simulation/slurm-15466799_48.out
    Ignored:    code/simulation/slurm-15466799_49.out
    Ignored:    code/simulation/slurm-15466799_5.out
    Ignored:    code/simulation/slurm-15466799_50.out
    Ignored:    code/simulation/slurm-15466799_51.out
    Ignored:    code/simulation/slurm-15466799_52.out
    Ignored:    code/simulation/slurm-15466799_53.out
    Ignored:    code/simulation/slurm-15466799_54.out
    Ignored:    code/simulation/slurm-15466799_55.out
    Ignored:    code/simulation/slurm-15466799_56.out
    Ignored:    code/simulation/slurm-15466799_57.out
    Ignored:    code/simulation/slurm-15466799_58.out
    Ignored:    code/simulation/slurm-15466799_59.out
    Ignored:    code/simulation/slurm-15466799_6.out
    Ignored:    code/simulation/slurm-15466799_60.out
    Ignored:    code/simulation/slurm-15466799_61.out
    Ignored:    code/simulation/slurm-15466799_62.out
    Ignored:    code/simulation/slurm-15466799_63.out
    Ignored:    code/simulation/slurm-15466799_64.out
    Ignored:    code/simulation/slurm-15466799_65.out
    Ignored:    code/simulation/slurm-15466799_66.out
    Ignored:    code/simulation/slurm-15466799_67.out
    Ignored:    code/simulation/slurm-15466799_68.out
    Ignored:    code/simulation/slurm-15466799_69.out
    Ignored:    code/simulation/slurm-15466799_7.out
    Ignored:    code/simulation/slurm-15466799_70.out
    Ignored:    code/simulation/slurm-15466799_71.out
    Ignored:    code/simulation/slurm-15466799_72.out
    Ignored:    code/simulation/slurm-15466799_73.out
    Ignored:    code/simulation/slurm-15466799_74.out
    Ignored:    code/simulation/slurm-15466799_75.out
    Ignored:    code/simulation/slurm-15466799_76.out
    Ignored:    code/simulation/slurm-15466799_77.out
    Ignored:    code/simulation/slurm-15466799_78.out
    Ignored:    code/simulation/slurm-15466799_79.out
    Ignored:    code/simulation/slurm-15466799_8.out
    Ignored:    code/simulation/slurm-15466799_80.out
    Ignored:    code/simulation/slurm-15466799_81.out
    Ignored:    code/simulation/slurm-15466799_82.out
    Ignored:    code/simulation/slurm-15466799_83.out
    Ignored:    code/simulation/slurm-15466799_84.out
    Ignored:    code/simulation/slurm-15466799_85.out
    Ignored:    code/simulation/slurm-15466799_86.out
    Ignored:    code/simulation/slurm-15466799_87.out
    Ignored:    code/simulation/slurm-15466799_88.out
    Ignored:    code/simulation/slurm-15466799_89.out
    Ignored:    code/simulation/slurm-15466799_9.out
    Ignored:    code/simulation/slurm-15466799_90.out
    Ignored:    code/simulation/slurm-15466799_91.out
    Ignored:    code/simulation/slurm-15466799_92.out
    Ignored:    code/simulation/slurm-15466799_93.out
    Ignored:    code/simulation/slurm-15466799_94.out
    Ignored:    code/simulation/slurm-15466799_95.out
    Ignored:    code/simulation/slurm-15466799_96.out
    Ignored:    code/simulation/slurm-15466799_97.out
    Ignored:    code/simulation/slurm-15466799_98.out
    Ignored:    code/simulation/slurm-15466799_99.out
    Ignored:    code/simulation/slurm-15478249_201.out
    Ignored:    code/simulation/slurm-15478249_202.out
    Ignored:    code/simulation/slurm-15478249_203.out
    Ignored:    code/simulation/slurm-15478249_204.out
    Ignored:    code/simulation/slurm-15478249_205.out
    Ignored:    code/simulation/slurm-15478249_206.out
    Ignored:    code/simulation/slurm-15478249_207.out
    Ignored:    code/simulation/slurm-15478249_208.out
    Ignored:    code/simulation/slurm-15478249_209.out
    Ignored:    code/simulation/slurm-15478249_210.out
    Ignored:    code/simulation/slurm-15478249_211.out
    Ignored:    code/simulation/slurm-15478249_212.out
    Ignored:    code/simulation/slurm-15478249_213.out
    Ignored:    code/simulation/slurm-15478249_214.out
    Ignored:    code/simulation/slurm-15478249_215.out
    Ignored:    code/simulation/slurm-15478249_216.out
    Ignored:    code/simulation/slurm-15478249_217.out
    Ignored:    code/simulation/slurm-15478249_218.out
    Ignored:    code/simulation/slurm-15478249_219.out
    Ignored:    code/simulation/slurm-15478249_220.out
    Ignored:    code/simulation/slurm-15478249_221.out
    Ignored:    code/simulation/slurm-15478249_222.out
    Ignored:    code/simulation/slurm-15478249_223.out
    Ignored:    code/simulation/slurm-15478249_224.out
    Ignored:    code/simulation/slurm-15478249_225.out
    Ignored:    code/simulation/slurm-15478249_226.out
    Ignored:    code/simulation/slurm-15478249_227.out
    Ignored:    code/simulation/slurm-15478249_228.out
    Ignored:    code/simulation/slurm-15478249_229.out
    Ignored:    code/simulation/slurm-15478249_230.out
    Ignored:    code/simulation/slurm-15478249_231.out
    Ignored:    code/simulation/slurm-15478249_232.out
    Ignored:    code/simulation/slurm-15478249_233.out
    Ignored:    code/simulation/slurm-15478249_234.out
    Ignored:    code/simulation/slurm-15478249_235.out
    Ignored:    code/simulation/slurm-15478249_236.out
    Ignored:    code/simulation/slurm-15478249_237.out
    Ignored:    code/simulation/slurm-15478249_238.out
    Ignored:    code/simulation/slurm-15478249_239.out
    Ignored:    code/simulation/slurm-15478249_240.out
    Ignored:    code/simulation/slurm-15530400.out
    Ignored:    code/simulation/summarize.Rout
    Ignored:    data/annotation/hg38/gencode.v33.annotation.gtf.gz
    Ignored:    data/annotation/mm39/
    Ignored:    data/lung-ont/220928_dge.rds
    Ignored:    data/lung/fastq/
    Ignored:    data/lung/index-kallisto/
    Ignored:    data/lung/index-subread/
    Ignored:    data/lung/index/
    Ignored:    ignore/
    Ignored:    misc/
    Ignored:    output/lung/
    Ignored:    output/simulation/

Unstaged changes:
    Modified:   analysis/lung.Rmd

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-paper.Rmd) and HTML (docs/simulation-paper.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
Rmd 5b41ed5 Pedro Baldoni 2024-06-24 Printing out tables
html 70ab63f Pedro Baldoni 2024-04-05 Publishing workflowr
Rmd bebf946 Pedro Baldoni 2024-04-05 Adding simulation Rmds

Introduction

Setup

knitr::opts_chunk$set(dev = "png",
                      dpi = 300,
                      dev.args = list(type = "cairo-png"),
                      root.dir = '.',
                      autodep = TRUE)

options(knitr.kable.NA = "-")
library(data.table)
library(magrittr)
library(ggplot2)
library(patchwork)
library(plyr)
library(kableExtra)
devtools::load_all('../code/pkg')
path.misc <- file.path('../misc/simulation.Rmd')
dir.create(path.misc,recursive = TRUE,showWarnings = FALSE)

path.example <- "../output/simulation/data/mm39/readlen-100/fc2/paired-end/9999TxPerGene/unbalanced/5libsPerGroup"

path.fdr <-
  list.files('../output/simulation/summary','fdr.tsv.gz',recursive = TRUE,full.names = TRUE)
path.metrics <-
  list.files('../output/simulation/summary','metrics.tsv.gz',recursive = TRUE,full.names = TRUE)
path.time <-
  list.files('../output/simulation/summary','^time.tsv.gz',recursive = TRUE,full.names = TRUE)
path.quanttime <-
  list.files('../output/simulation/summary','quanttime.tsv.gz',recursive = TRUE,full.names = TRUE)
path.quantile <-
  list.files('../output/simulation/summary','quantile.tsv.gz',recursive = TRUE,full.names = TRUE)
path.pvalue <-
  list.files('../output/simulation/summary','pvalue.tsv.gz',recursive = TRUE,full.names = TRUE)
path.overdispersion <-
  list.files('../output/simulation/summary','overdispersion.tsv.gz',recursive = TRUE,full.names = TRUE)
path.roc <-
  list.files('../output/simulation/summary','roc.tsv.gz',recursive = TRUE,full.names = TRUE)
bs <- 8

Data loading

relabel <- function(x){
  y <- copy(x)
  y$TxPerGene %<>% factor(levels = paste0(c(2, 3, 4, 5, 9999), 'TxPerGene'),labels = c(paste0("#Tx/Gene = ", c(2, 3, 4, 5)), 'All Transcripts')) %<>% droplevels()
  y$LibsPerGroup %<>% factor(levels = paste0(c(3, 5, 10), 'libsPerGroup'),labels = paste0('#Lib/Group = ', c(3, 5, 10))) %<>% droplevels()
  y$Quantifier %<>% factor(levels = c('salmon','salmon-gibbs','kallisto'),labels = c('Salmon-Boot','Salmon-Gibbs','kallisto')) %<>% droplevels()
  y$Length %<>% factor(levels = paste0('readlen-', seq(50, 150, 25)),labels = paste0(seq(50, 150, 25), 'bp')) %<>% droplevels()
  if (!is.null(x$Sample)) {
    y$Sample %<>% factor(levels = c(paste0("groupA_rep",1:10,"_R1"),paste0("groupB_rep",1:10,"_R1")),labels = c(paste0("A",1:10),paste0("B",1:10))) %<>% droplevels()
  }
  return(y)
}

# Loading datasets
dt.fdr <- do.call(rbind,lapply(path.fdr,fread)) %>% relabel()
dt.metrics <- do.call(rbind,lapply(path.metrics,fread)) %>% relabel()
dt.time <- do.call(rbind,lapply(path.time,fread)) %>% relabel()
dt.quanttime <- do.call(rbind,lapply(path.quanttime,fread)) %>% relabel()
dt.quantile <- do.call(rbind,lapply(path.quantile,fread)) %>% relabel()
dt.pvalue <- do.call(rbind,lapply(path.pvalue,fread)) %>% relabel()
dt.overdispersion <- do.call(rbind,lapply(path.overdispersion,fread)) %>% relabel()
dt.roc <- do.call(rbind,lapply(path.roc,fread)) %>% relabel()

Power

dt.power <- dt.metrics[FC == 'fc2' &
                         Quantifier != 'kallisto' &
                         !grepl("\\.n|RC",Method) &
                         Scenario == 'unbalanced',]

dt.power$LibsPerGroup %<>% factor(levels = paste0('#Lib/Group = ', c(3, 5,10)),labels = paste0(c(3,5,10),' samples per group'))
dt.power$Scenario %<>% factor(levels = c('balanced','unbalanced'),labels = c('Equal library sizes','Unequal library sizes'))
dt.power$Quantifier %<>% factor(levels = c('Salmon-Boot','Salmon-Gibbs'),labels = c('Bootstrap','Gibbs'))
dt.power$Method %<>% mapvalues(from = c('edgeR-SC','edgeR.legacy-SC'),to = c('edgeR-v4','edgeR-v3'))

dt.power[, FDR := roundPretty(ifelse((FP+TP) == 0,NA,100*FP/(FP+TP)),1)]

x.melt <- melt(dt.power,id.vars = colnames(dt.power)[-which(colnames(dt.power) %in% c('P.SIG','TP','FP'))],
               measure.vars = c('TP','FP'),
               variable.name = 'Type',
               value.name = 'Value')
x.melt$Type <-
  factor(x.melt$Type,
         levels = c('FP','TP'),
         labels = c('False','True'))

plot.power <- function(df.bar,df.txt,scenario,library,legend = FALSE, base_size = bs){
  tb.bar <- df.bar[Scenario == scenario & LibsPerGroup == library,]
  tb.txt <- df.txt[Scenario == scenario & LibsPerGroup == library,][FDR != 'NA',]
  gap <- 0.05*max(dt.power$TP + dt.power$FP)
  ggplot(tb.bar,aes(x = Quantifier,y = Value,fill = Type)) +
    facet_wrap(facets = "Method",nrow = 1) +
    geom_col() +
    geom_text(aes(x = Quantifier,y = (TP + FP) +  gap,label = FDR),
              vjust = 0,data = tb.txt,size = base_size/.pt,inherit.aes = FALSE) +
    scale_fill_manual(values = c('#ff0000','#bebebe')) +
    labs(x = NULL,y = paste('DE Transcripts')) +
    scale_y_continuous(limits = c(0,3250)) +
    theme_bw(base_size = base_size,base_family = 'sans') +
    theme(panel.grid = element_blank(),
          # axis.text.x = element_text(angle = 90),
          axis.text = element_text(colour = 'black',size = base_size),
          strip.text = element_text(size = base_size)) +
    if (legend == TRUE) theme(legend.background = element_rect(fill = alpha('white', 0)),
                              legend.text = element_text(size = base_size),
                              legend.position = c(0.95,0.825),
                              legend.direction = 'vertical',
                              legend.title = element_blank(),
                              legend.key.size = unit(0.75,"line")) else theme(legend.position = 'none')
}

fig.power <- plot.power(df.bar = x.melt,
                        df.txt = dt.power,
                        scenario = 'Unequal library sizes',
                        library = '5 samples per group',
                        legend = TRUE)
Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2
3.5.0.
ℹ Please use the `legend.position.inside` argument of `theme()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
generated.
fig.power

Version Author Date
70ab63f Pedro Baldoni 2024-04-05

FDR

dt.fdr.plot <- dt.fdr[FC == 'fc2' &
                        Quantifier != 'kallisto' &
                        !grepl("\\.n|RC",Method) &
                        Scenario == 'unbalanced',]

colmeth <- methodsNames()$color
names(colmeth) <- gsub('^edgeR-SC$','edgeR-v4',names(colmeth))
names(colmeth) <- gsub('^edgeR.legacy-SC$','edgeR-v3',names(colmeth))

dt.fdr.plot$LibsPerGroup %<>% factor(levels = paste0('#Lib/Group = ', c(3, 5,10)),labels = paste0(c(3,5,10),' samples per group'))
dt.fdr.plot$Scenario %<>% factor(levels = c('balanced','unbalanced'),labels = c('Equal library sizes','Unequal library sizes'))
dt.fdr.plot$Quantifier %<>% factor(levels = c('Salmon-Boot','Salmon-Gibbs'),labels = c('Bootstrap','Gibbs')) %<>% factor(levels = c('Gibbs','Bootstrap'))
dt.fdr.plot$Method %<>% mapvalues(from = c('edgeR-SC','edgeR.legacy-SC'),to = c('edgeR-v4','edgeR-v3'))

dt.fdr.plot$Method %<>% factor(levels = c('Swish',
                                          'sleuth-Wald',
                                          'sleuth-LRT',
                                          'edgeR-v3',
                                          'edgeR-v4'))

plot.fdr <- function(df.line,scenario,library,legend = FALSE,base_size = bs,color = colmeth,
                     ylim = c(0,800),xlim = c(0,300),...){
  tb.bar <- df.line[Scenario == scenario & LibsPerGroup == library,]
  
  ggplot(tb.bar,aes(x = N,y = FDR,color = Method,linetype = Quantifier)) +
    geom_line(linewidth = 0.7) +
    scale_color_manual(values = color,
                       breaks = c('edgeR-v3',
                                  'edgeR-v4',
                                  'sleuth-LRT',
                                  'sleuth-Wald',
                                  'Swish')) +
    coord_cartesian(xlim = xlim,ylim = ylim) +
    labs(y = 'False discoveries',x = 'Transcripts chosen') +
    theme_bw(base_size = base_size,base_family = 'sans') +
    theme(panel.grid = element_blank(),
          axis.text = element_text(colour = 'black',size = base_size)) +
    if (legend == TRUE) theme(legend.background = element_rect(fill = alpha('white', 0)),
                              legend.direction = 'vertical',
                              legend.box = 'horizontal',
                              legend.position = c(0.4,0.8),
                              legend.text = element_text(size = base_size),
                              legend.title = element_blank(),
                              legend.key.size = unit(0.75,"line")) else theme(legend.position = 'none')
}

fig.fdr <- plot.fdr(df.line = dt.fdr.plot[N <= 2500,],
                    scenario = 'Unequal library sizes',
                    library = '5 samples per group',
                    ylim = c(0,310),
                    xlim = c(0,2500),
                    legend = TRUE)

fig.fdr

Version Author Date
70ab63f Pedro Baldoni 2024-04-05

ROC curves

dt.rcurve <- dt.roc[FC == 'fc2' &
                      grepl("edgeR-SC|edgeR-SC\\.n",Method) &
                      Scenario == 'unbalanced' &
                      Quantifier != 'kallisto',]

dt.rcurve$LibsPerGroup %<>% factor(levels = paste0('#Lib/Group = ', c(3, 5, 10)),labels = paste0(c('Three','Five', 'Ten'),' samples per group'))
dt.rcurve$Scenario %<>% factor(levels = c('balanced','unbalanced'),labels = c('Equal library sizes','Unequal library sizes'))
dt.rcurve$Quantifier %<>% factor(levels = c('Salmon-Boot','Salmon-Gibbs'),labels = c('Bootstrap','Gibbs'))
dt.rcurve$Method %<>%
  factor(levels = c(paste0('edgeR-SC.n',seq(10,90,10)),'edgeR-SC')) %<>%
  mapvalues(from = c(paste0('edgeR-SC.n',seq(10,90,10)),'edgeR-SC'),to = paste0(seq(10,100,10)))

fig.roc <- ggplot(data = dt.rcurve,aes(x = oFDR,y = oTPR,group = Method,color = Method)) +
  facet_grid(rows = vars(LibsPerGroup),cols = vars(Quantifier)) +
  geom_vline(xintercept = c(0.01,0.05,0.1,0.15,0.2),linetype = 'dashed',linewidth = 0.25,color = 'gray') +
  geom_hline(yintercept = c(0,0.25,0.5,0.75,1),linetype = 'dashed',linewidth = 0.25,color = 'gray') +
  geom_line(linewidth = 0.5) +
  geom_point(aes(shape = as.factor(nFDR)),size = 3) +
  scale_y_continuous(limits = c(0,1)) +
  scale_x_continuous(limits = c(0,0.2)) +
  scale_color_viridis_d(direction = -1) +
  theme_bw(base_size = bs,base_family = 'sans') +
  theme(panel.grid = element_blank(),
        legend.text = element_text(colour = 'black',size = bs),
        axis.text = element_text(colour = 'black',size = bs),
        strip.text = element_text(colour = 'black',size = bs)) +
  labs(x = 'Observed FDR',y = 'Observed power',shape = 'Nominal FDR',color = 'Resamples')

fig.roc

Version Author Date
70ab63f Pedro Baldoni 2024-04-05

Error rate

dt.type1error <- dt.metrics[FC == 'fc1' &
                              Quantifier == 'Salmon-Gibbs' &
                              !grepl("\\.n|RC",Method) &
                              Scenario == 'unbalanced',]

dt.type1error$LibsPerGroup %<>% factor(levels = paste0('#Lib/Group = ', c(3, 5,10)),labels = paste0(c(3,5,10),' samples per group'))
dt.type1error$Scenario %<>% factor(levels = c('balanced','unbalanced'),labels = c('Equal library sizes','Unequal library sizes'))
dt.type1error$Quantifier %<>% factor(levels = c('Salmon-Gibbs'),labels = c('Gibbs'))
dt.type1error$Method %<>% mapvalues(from = c('edgeR-SC','edgeR.legacy-SC','sleuth-LRT','sleuth-Wald','Swish'),to = c('edgeR\nv4','edgeR\nv3','sleuth\nLRT','sleuth\nWald','Swish'))

x.melt <-
  melt(dt.type1error,
       id.vars = colnames(dt.type1error)[-which(colnames(dt.type1error) %in% c('P.SIG','TP','FP'))],
       measure.vars = c('P.SIG'),variable.name = 'Type',value.name = 'Value')

plot.type1error <- function(df.bar,scenario,library,legend = FALSE,base_size = bs){
  tb.bar <- df.bar[Scenario == scenario & LibsPerGroup == library,]
  ggplot(tb.bar,aes(x = Method,y = Value)) +
    geom_col(fill = "#bebebe") +
    geom_hline(yintercept = 0.05,color = '#ff0000',linetype = 'dashed',linewidth = 0.5) +
    labs(x = NULL,y = paste('Type 1 error rate')) +
    scale_y_continuous(limits = c(0,0.06),breaks = seq(0,0.06,0.01)) +
    theme_bw(base_size = base_size,base_family = 'sans') +
    theme(panel.grid = element_blank(),
          axis.text.x = element_text(angle = 0),
          axis.text = element_text(colour = 'black',size = base_size))
}

fig.type1error <- plot.type1error(df.bar = x.melt,
                                  scenario = 'Unequal library sizes',
                                  library = '5 samples per group')

fig.type1error

Version Author Date
70ab63f Pedro Baldoni 2024-04-05

Quantification time

dt.salmontime <- dt.quanttime[Quantifier != 'kallisto',
                              .(TotalTime = mean(Time)/60,
                                ResamplingTime = mean(ResamplingTime)/60),
                              by = c('LibSize','Quantifier')]

dt.salmontime$QuantTime <- dt.salmontime$TotalTime - dt.salmontime$ResamplingTime
setcolorder(dt.salmontime,c('Quantifier','LibSize','QuantTime','ResamplingTime','TotalTime'))

dt.salmontime$LibSize %<>% factor(levels = c('2.5e+07','5e+07','1e+08'),
                                  labels = c('25','50','100'))

dt.salmontime$Quantifier %<>% factor(levels = c('Salmon-Boot','Salmon-Gibbs'),
                                     labels = c('Bootstrap','Gibbs'))

dt.salmontime <- dt.salmontime[order(Quantifier,LibSize),]

cnames <- c('Resampling\nMethod',
            'Library Size\n(million read pairs)',
            'Optimization',
            'Resampling',
            'Total')

tb.salmontime <- kbl(x = dt.salmontime,
                     format = 'latex',
                     digits = 2,
                     col.names = linebreak(cnames,align = 'c'),
                     align = 'ccccc',
                     escape = FALSE,
                     booktabs = TRUE) %>%
  add_header_above(c(" " = 2, "Quantification Time (minutes)" = 3)) %>%
  collapse_rows(1, latex_hline = 'major')

kbl(x = dt.salmontime,
    format = 'pipe',
    digits = 2,
    col.names = linebreak(cnames,align = 'c'),
    align = 'ccccc',
    escape = FALSE,
    booktabs = TRUE) %>%
  add_header_above(c(" " = 2, "Quantification Time (minutes)" = 3)) %>%
  collapse_rows(1, latex_hline = 'major')
Quantification Time (minutes)
Optimization Resampling Total
Bootstrap 25 1.79 9.45 11.24
50 3.22 13.41 16.64
100 6.09 19.15 25.24
Gibbs 25 1.78 0.91 2.69
50 3.22 1.62 4.85
100 6.05 3.01 9.06

edgeR comparison

dt.dte <- merge(x = dt.time[grepl("edgeR-SC$|edgeR.legacy-SC$",Method) &
                              grepl("Salmon",Quantifier) &
                              Scenario == 'unbalanced' &
                              FC == 'fc2',c('LibsPerGroup','Method','Quantifier','Time')],
                y = dt.roc[grepl("edgeR-SC$|edgeR.legacy-SC$",Method) &
                             grepl("Salmon",Quantifier) &
                             Scenario == 'unbalanced' &
                             FC == 'fc2' &
                             nFDR == 0.05,c('LibsPerGroup','Method','Quantifier','oTPR','oFDR')],
                by = c('LibsPerGroup','Method','Quantifier'),
                all.x = TRUE)

dt.dte[,Time := 60*Time]

dt.dte$LibsPerGroup %<>% factor(levels = paste0('#Lib/Group = ',c(3,5,10)),
                                labels = c('Three','Five','Ten'))

dt.dte$Method %<>% factor(levels = c('edgeR-SC','edgeR.legacy-SC'),
                          labels = c('edgeR-v4','edgeR-v3'))

dt.dte$Quantifier %<>% factor(levels = c('Salmon-Boot','Salmon-Gibbs'),
                              labels = c('Bootstrap','Gibbs'))

dt.dte.edger <- dt.dte[Method == 'edgeR-v4',]
setnames(dt.dte.edger,
         old = c('Time','oTPR','oFDR'),
         new = c('Time.edgeR','oTPR.edgeR','oFDR.edgeR'))
dt.dte.edger.legacy <- dt.dte[Method != 'edgeR-v4',]
setnames(dt.dte.edger.legacy,
         old = c('Time','oTPR','oFDR'),
         new = c('Time.edgeRLegacgy','oTPR.edgeRLegacgy','oFDR.edgeRLegacgy'))

dt.dte <- merge(dt.dte.edger.legacy[,-2],dt.dte.edger[,-2],
                by = c('LibsPerGroup','Quantifier'),
                all.x = TRUE,
                sort = FALSE)

cnames <- c('Samples per\nGroup',
            'Sampling\nMethod',
            'Time',
            'Power',
            'FDR',
            'Time',
            'Power',
            'FDR')

tb.dte <- kbl(x = dt.dte,
              digits = 2,
              format = 'latex',
              escape = FALSE,
              booktabs = TRUE,
              col.names = linebreak(cnames,align = 'c'),
              align = 'llcccccc') %>%
  add_header_above(c(" " = 2, "edgeR-v3" = 3,"edgeR-v4" = 3)) %>%
  collapse_rows(1, latex_hline = 'major')

kbl(x = dt.dte,
    digits = 2,
    format = 'pipe',
    escape = FALSE,
    booktabs = TRUE,
    col.names = linebreak(cnames,align = 'c'),
    align = 'llcccccc') %>%
  add_header_above(c(" " = 2, "edgeR-v3" = 3,"edgeR-v4" = 3)) %>%
  collapse_rows(1, latex_hline = 'major')
edgeR-v3
edgeR-v4
Time Power FDR Time Power FDR
Three Bootstrap 6.79 0.39 0.04 3.54 0.42 0.04
Gibbs 7.81 0.38 0.03 4.46 0.42 0.04
Five Bootstrap 9.96 0.71 0.04 5.79 0.73 0.04
Gibbs 11.38 0.72 0.04 7.21 0.74 0.04
Ten Bootstrap 17.78 0.91 0.04 10.95 0.92 0.05
Gibbs 20.60 0.92 0.04 13.61 0.94 0.05

Output files

fig.metrics <- wrap_plots(A = fig.power,
                          B = fig.fdr,
                          C = fig.type1error,
                          design = c(area(1,1,1,2),area(2,1),area(2,2)),
                          heights = c(0.3,0.7),widths = c(3.5/6,1-3.5/6)) + 
  plot_annotation(tag_levels = 'a',
                  theme = theme(plot.tag = element_text(size = bs)))

ggsave(plot = fig.metrics,filename = file.path(path.misc,'Figure-Metrics.pdf'),
       device = 'pdf',width = 6,height = 5,units = 'in',dpi = 300)

ggsave(plot = fig.roc,filename = file.path(path.misc,'Figure-ROC.pdf'),
       device = 'pdf',width = 6,height = 5,units = 'in',dpi = 300)

save_kable(tb.salmontime,file = file.path(path.misc,'Table-QuantTime.tex'))
save_kable(tb.dte,file = file.path(path.misc,'Table-DTETime.tex'))

sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /stornext/System/data/apps/R/R-4.4.0/lib64/R/lib/libRblas.so 
LAPACK: /stornext/System/data/apps/R/R-4.4.0/lib64/R/lib/libRlapack.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] pkg_1.0           kableExtra_1.4.0  plyr_1.8.9        patchwork_1.2.0  
[5] ggplot2_3.5.1     magrittr_2.0.3    data.table_1.15.4 workflowr_1.7.1  

loaded via a namespace (and not attached):
  [1] splines_4.4.0               later_1.3.2                
  [3] BiocIO_1.14.0               bitops_1.0-7               
  [5] filelock_1.0.3              R.oo_1.26.0                
  [7] tibble_3.2.1                XML_3.99-0.16.1            
  [9] lifecycle_1.0.4             httr2_1.0.1                
 [11] edgeR_4.2.0                 rprojroot_2.0.4            
 [13] processx_3.8.4              lattice_0.22-6             
 [15] ensembldb_2.28.0            limma_3.60.3               
 [17] sass_0.4.9                  rmarkdown_2.27             
 [19] jquerylib_0.1.4             yaml_2.3.8                 
 [21] remotes_2.5.0               httpuv_1.6.15              
 [23] sessioninfo_1.2.2           pkgbuild_1.4.4             
 [25] DBI_1.2.3                   abind_1.4-5                
 [27] pkgload_1.3.4               zlibbioc_1.50.0            
 [29] GenomicRanges_1.56.1        R.utils_2.12.3             
 [31] purrr_1.0.2                 AnnotationFilter_1.28.0    
 [33] BiocGenerics_0.50.0         RCurl_1.98-1.14            
 [35] rappdirs_0.3.3              git2r_0.33.0               
 [37] GenomeInfoDbData_1.2.12     wasabi_1.0.1               
 [39] IRanges_2.38.0              S4Vectors_0.42.0           
 [41] fishpond_2.10.0             svglite_2.1.3              
 [43] codetools_0.2-20            DelayedArray_0.30.1        
 [45] xml2_1.3.6                  tidyselect_1.2.1           
 [47] farver_2.1.2                UCSC.utils_1.0.0           
 [49] matrixStats_1.3.0           stats4_4.4.0               
 [51] BiocFileCache_2.12.0        showtext_0.9-7             
 [53] GenomicAlignments_1.40.0    jsonlite_1.8.8             
 [55] ellipsis_0.3.2              systemfonts_1.1.0          
 [57] tools_4.4.0                 progress_1.2.3             
 [59] ragg_1.3.2                  Rcpp_1.0.12                
 [61] glue_1.7.0                  svMisc_1.2.3               
 [63] SparseArray_1.4.8           xfun_0.45                  
 [65] MatrixGenerics_1.16.0       usethis_2.2.3              
 [67] GenomeInfoDb_1.40.1         dplyr_1.1.4                
 [69] withr_3.0.0                 BiocManager_1.30.23        
 [71] fastmap_1.2.0               rhdf5filters_1.16.0        
 [73] fansi_1.0.6                 callr_3.7.6                
 [75] digest_0.6.35               R6_2.5.1                   
 [77] mime_0.12                   textshaping_0.4.0          
 [79] colorspace_2.1-0            gtools_3.9.5               
 [81] biomaRt_2.60.0              RSQLite_2.3.7              
 [83] R.methodsS3_1.8.2           utf8_1.2.4                 
 [85] generics_0.1.3              tximeta_1.22.1             
 [87] rtracklayer_1.62.0          prettyunits_1.2.0          
 [89] httr_1.4.7                  htmlwidgets_1.6.4          
 [91] S4Arrays_1.4.1              whisker_0.4.1              
 [93] pkgconfig_2.0.3             gtable_0.3.5               
 [95] blob_1.2.4                  SingleCellExperiment_1.26.0
 [97] XVector_0.44.0              htmltools_0.5.8.1          
 [99] sysfonts_0.8.9              profvis_0.3.8              
[101] ProtGenerics_1.36.0         sleuth_0.30.0              
[103] scales_1.3.0                Biobase_2.64.0             
[105] Rsubread_2.18.0             png_0.1-8                  
[107] knitr_1.47                  rstudioapi_0.16.0          
[109] tzdb_0.4.0                  rjson_0.2.21               
[111] curl_5.2.1                  showtextdb_3.0             
[113] cachem_1.1.0                rhdf5_2.48.0               
[115] stringr_1.5.1               BiocVersion_3.19.1         
[117] parallel_4.4.0              miniUI_0.1.1.1             
[119] AnnotationDbi_1.66.0        restfulr_0.0.15            
[121] desc_1.4.3                  pillar_1.9.0               
[123] grid_4.4.0                  vctrs_0.6.5                
[125] urlchecker_1.0.1            promises_1.3.0             
[127] dbplyr_2.5.0                xtable_1.8-4               
[129] tximport_1.32.0             evaluate_0.24.0            
[131] readr_2.1.5                 GenomicFeatures_1.56.0     
[133] locfit_1.5-9.9              cli_3.6.2                  
[135] compiler_4.4.0              Rsamtools_2.20.0           
[137] rlang_1.1.4                 crayon_1.5.2               
[139] labeling_0.4.3              ps_1.7.6                   
[141] getPass_0.2-4               fs_1.6.4                   
[143] stringi_1.8.4               viridisLite_0.4.2          
[145] BiocParallel_1.38.0         txdbmaker_1.0.0            
[147] munsell_0.5.1               Biostrings_2.72.1          
[149] lazyeval_0.2.2              devtools_2.4.5             
[151] Matrix_1.7-0                hms_1.1.3                  
[153] bit64_4.0.5                 Rhdf5lib_1.26.0            
[155] KEGGREST_1.44.0             statmod_1.5.0              
[157] shiny_1.8.1.1               highr_0.11                 
[159] SummarizedExperiment_1.34.0 AnnotationHub_3.12.0       
[161] memoise_2.0.1               thematic_0.1.5             
[163] bslib_0.7.0                 bit_4.0.5