if (!exists("DEBUG")) {
  DEBUG <- TRUE
  # DEBUG=FALSE
}
if (!exists("DEBUGSAVE")) {
  # DEBUGSAVE=TRUE
  DEBUGSAVE <- FALSE
}
# LIBRARIES -----------------------------------------------------------------
library(shiny)
library(shinyTree)
library(tibble)
library(plotly)
library(shinythemes)
library(ggplot2)
library(DT)
library(pheatmap)
library(threejs)
library(RColorBrewer)
library(mclust)
library(reshape2)
library(ggplot2)
library(knitr)
library(kableExtra)
library(shinyWidgets)
library(scater)
library(kohonen)
library(Rsomoclu)
library(gtools)
library(SingleCellExperiment)
library(Matrix)
library(colourpicker)
library(scran)

# we overwirte this function because it doesn't make sense in the report and causes problems otherwise
exportTestValues <- function(...){return(NULL)}


# params only exsits if called from somewhere with parameters
if (exists("params") & is.list(params)) {
  cat(file = stderr(), paste("params:", params$calledFromShiny, "\n"))
  cat(file = stderr(), paste("params exists:", "calledFromShiny" %in% names(params), "\n"))
  LOCALEXECUTION <- FALSE
  if (DEBUGSAVE) {
    base::save(file = "~/SCHNAPPsDebug/tempReport-rmd.RData", list = c(ls()))
  }
} else {
  # rm(list = ls())
   base::load(file = "geneLists.RData")
  source("serverFunctions.R")
  source("defaultValues.R")
  source("reactives.R", local = TRUE)
  uiFiles <- dir(path = "contributions", pattern = "reactives.R", full.names = TRUE, recursive = TRUE)
  for (fp in uiFiles) {
    if (DEBUG) cat(file = stderr(), paste("loading: ", fp, "\n"))
    source(fp, local = TRUE)
  }
  cp = load("~/SCHNAPPsDebug/tempReport.RData")
  params <- myparams
  LOCALEXECUTION <- TRUE # to know that we are debugging.
}

LOAD_REACTIVES

parameters

save(file = "~/report.RData", list = c(ls(), "params"))
# load("~/report.RData")
# cat(file = stderr(), paste(ls(), collapse = "\n"))
# save(file = "~/SCHNAPPsDebug/report.vars.RData", list = ls())
# load(file = "~/SCHNAPPsDebug/report.vars.RData")
fileConn <- (paste0(reportTempDir, "/variables.used.txt"))
printVars <- function(x, fileConn) {
  for (varN in names(x)) {
    # if (is.data.frame(x[[varN]])) {
    cat(file = fileConn, x = paste(varN, "=", paste(x[[varN]], collapse = "\n"), collapse = "\n"), append = TRUE)
    cat(file = fileConn, x = "\n\t", append = TRUE)
  }
}
cat(file = fileConn, "Parametes used in last session\n", append = FALSE)
printVars(input, fileConn)
# close(fileConn)
# TODO this needs to go to individual packages

if (is.null(input$cluster)) {
  input$cluster <- "0"
  print("Warning: setting cluster to 0")
}
if (is.null(input$cluster5)) {
  input$cluster5 <- "0"
  print("Warning: setting cluster5 to 0")
}
if (is.null(input$clusters)) {
  input$clusters <- "0"
  print("Warning: setting clusters to 0")
}
if (is.null(input$sCA_dgeClustersSelection)) {
  input$sCA_dgeClustersSelection <- "0"
  print("Warning: setting sCA_dgeClustersSelection to All")
}
if (is.null(input$clusters2)) {
  input$clusters2 <- "0"
  print("Warning: setting clusters2 to 0")
}
if (is.null(input$clusters3)) {
  input$clusters3 <- "0"
  print("Warning: setting clusters4 to 0")
}
if (is.null(input$DE_clusterSelectionPanelPlot)) {
  input$DE_clusterSelectionPanelPlot <- "All"
  print("Warning: setting clusters4 to All")
}
if (is.null(input$geneSelectionClustering)) {
  input$geneSelectionClustering <- ""
  print("Warning: setting geneSelectionClustering to All")
}
# if ( !exists("dataTables")) {# needed when working with ~/SCHNAPPsDebug/reports.Data
cat(file = stderr(), paste("loading dataTables\n"))
# in case the file is not in the root directory is has to be manually loaded during debugging
# input$file1 = data.frame("datapath" = dir(path = "~/Rstudio/shHubgit/", pattern="scEx.RData", full.names = T), stringsAsFactors = F)
# inFile = input$file1
dataTables <- inputData
# }
featureDataReact <- dataTables$featuredata[useGenes, ]
featureData <- dataTables$featuredata[useGenes, ]

medianENSG <- medianENSGfunc(as.matrix(assays(scEx)[[1]]))

medianUMI <- medianUMIfunc(as.matrix(assays(scEx)[[1]]))

scEx_matrix <- as.matrix(assays(scEx)[[1]])

log2cpm <- as.data.frame(as.matrix(assays(scEx_log)[[1]]))

Creating r input$gQC_tsneDim tSNE clusters.

line1 <- paste("No. of cells:", dim(log2cpm)[2], sep = "\t")
line2 <- paste("Median UMIs:", medianUMI, sep = "\t")
line3 <- paste("Median Genes:", medianENSG, sep = "\t")
line5 <- paste("No. of reads:", dim(log2cpm)[1], sep = "\t")
HTML(
  paste0(
    "Summary statistics of this dataset:", "<br/>", "<br/>",
    line1, "<br/>",
    line2, "<br/>",
    line3, "<br/>",
    line5
  )
)

Input/General

input file: r paste(inputFile$inFile, " _ ", inputFile$annFile)

Description:

r input$descriptionOfWork

Normalization used

Normalization method used: r input$normalizationRadioButton.

Variables used

Variables that are used can be found here: **variables.used.txt

CHILDREPORTS

Session information

if (!LOCALEXECUTION) {
  # save(file = "~/SCHNAPPsDebug/report.RData", list=ls())
}
sessionInfo()


C3BI-pasteur-fr/UTechSCB-SCHNAPPs documentation built on Jan. 11, 2020, 12:28 p.m.