tests/testthat/test-roxytest-testexamples-show_sig_bootstrap.R

# Generated by roxytest: do not edit by hand!

# File R/show_sig_bootstrap.R: @testexamples

test_that("[unknown alias] @ L102", {
  
  
  if (require("BSgenome.Hsapiens.UCSC.hg19")) {
    laml.maf <- system.file("extdata", "tcga_laml.maf.gz", package = "maftools")
    laml <- read_maf(maf = laml.maf)
    mt_tally <- sig_tally(
      laml,
      ref_genome = "BSgenome.Hsapiens.UCSC.hg19",
      use_syn = TRUE
    )
  
    library(NMF)
    mt_sig <- sig_extract(mt_tally$nmf_matrix,
      n_sig = 3,
      nrun = 2,
      cores = 1
    )
  
    mat <- t(mt_tally$nmf_matrix)
    mat <- mat[, colSums(mat) > 0]
    bt_result <- sig_fit_bootstrap_batch(mat, sig = mt_sig, n = 10)
    ## Parallel computation
    ## bt_result = sig_fit_bootstrap_batch(mat, sig = mt_sig, n = 10, use_parallel = TRUE)
  
    ## At default, mean bootstrap exposure for each sample has been calculated
    p <- show_sig_bootstrap_exposure(bt_result, methods = c("QP"))
    ## Show bootstrap exposure (optimal exposure is shown as triangle)
    p1 <- show_sig_bootstrap_exposure(bt_result, methods = c("QP"), sample = "TCGA-AB-2802")
    p1
    p2 <- show_sig_bootstrap_exposure(bt_result,
      methods = c("QP"),
      sample = "TCGA-AB-3012",
      signatures = c("Sig1", "Sig2")
    )
    p2
  
    ## Show bootstrap error
    ## Similar to exposure above
    p <- show_sig_bootstrap_error(bt_result, methods = c("QP"))
    p
    p3 <- show_sig_bootstrap_error(bt_result, methods = c("QP"), sample = "TCGA-AB-2802")
    p3
  
    ## Show exposure (in)stability
    p4 <- show_sig_bootstrap_stability(bt_result, methods = c("QP"))
    p4
    p5 <- show_sig_bootstrap_stability(bt_result, methods = c("QP"), measure = "MAE")
    p5
    p6 <- show_sig_bootstrap_stability(bt_result, methods = c("QP"), measure = "AbsDiff")
    p6
    p7 <- show_sig_bootstrap_stability(bt_result, methods = c("QP"), measure = "CV")
    p7
  } else {
    message("Please install package 'BSgenome.Hsapiens.UCSC.hg19' firstly!")
  }
  
  expect_s3_class(p1, "ggplot")
  expect_s3_class(p2, "ggplot")
  expect_s3_class(p3, "ggplot")
  expect_s3_class(p4, "ggplot")
  expect_s3_class(p5, "ggplot")
  expect_s3_class(p6, "ggplot")
  expect_s3_class(p7, "ggplot")
})
ShixiangWang/sigminer documentation built on March 16, 2024, 12:30 p.m.