knitr::opts_chunk$set(echo = TRUE)
require(knitr)
require(kableExtra)
require(plotly)
require(seqLogo)

output <- readRDS("output.rds")
param <- readRDS("param.rds")
input <- readRDS("input.rds")
data <- readRDS("data.rds")

dataset = input$meta
samples = input$getNames()

debug <- FALSE

Started on r format(Sys.time(), "%Y-%m-%d %H:%M:%S")

CRISPR ScreenQC Results {.tabset}

1. Per sample sgRNA library barplots

The counts are estimated by MAGeCK

Screened Libraries table
    sgRNAPerLib <- data.frame(data$sgRNAPerLib)
    colnames(sgRNAPerLib) <- c('Library', '#sgRNAs')
    ezInteractiveTableRmd(sgRNAPerLib)
Barplots per Sample
countsPerLib <- data$countsPerLib

  for (nm in names(countsPerLib)){
      #x = countsPerLib[[nm]]/1000

      #par(mar=c(15.1, 6.1, 4.1, 2.1))
      #if (length(x[x > 0]) > 0){
      #    bplot <- barplot(x[x > 0], names.arg = rep('',length(x[x>0])), col = 'royalblue3', 
      #                     main = nm, ylab = 'sgRNA Count per Library per K', las = 2)
      #    text(x = bplot, y = par("usr")[3] - 1, srt = 45, adj = 1, 
      #         labels = names(x)[x > 0], xpd = TRUE)
      #}
      x = 100*(countsPerLib[[nm]]/param$nReads)

      par(mar=c(15.1, 6.1, 4.1, 2.1))
      if (length(x[x > 0]) > 0){
          bplot <- barplot(x[x > 0], names.arg = rep('',length(x[x>0])), col = 'royalblue3', 
                           main = nm, ylab = 'MappingRate per Library in %', las = 2, ylim = c(0,100))
          text(x = bplot, y = par("usr")[3] - 3, srt = 45, adj = 1, 
               labels = names(x)[x > 0], xpd = TRUE)
      }
  }

2. Top sgRNAs

    topFeatureResults <- data$topFeatureResults
    myTable <- c()
for (nm in names(topFeatureResults)){
    topFeatureResult <- data.frame(topFeatureResults[[nm]])
    if(nrow(topFeatureResult)>0){
        topFeatureResult[['Sample']] = nm
        colnames(topFeatureResult) <- c('sgRNA', 'Gene', 'Count', 'Library', 'Sample')
        myTable <- rbind(myTable, topFeatureResult)
    }
}
ezInteractiveTableRmd(myTable)

3. Read Patterns

PWMs <- data$PWMs
consensusSeqs <- c()

for (nm in names(PWMs)){
        cat(nm, "\n \n")
        seqLogo(PWMs[[nm]])
        cons <- limma::strsplit2(consensus(PWMs[[nm]]), split ='')
        cons[ic(PWMs[[nm]]) <1] <- 'N'
        cons <- paste(cons, collapse = '')
        consensusSeqs <- c(consensusSeqs, cons)
        cat("\n \n")
}
names(consensusSeqs) <- names(PWMs)
ezInteractiveTableRmd(values=data.frame(Name=names(consensusSeqs), Sequence = consensusSeqs, row.names = NULL))

Input Dataset

ezInteractiveTableRmd(values=dataset)

SessionInfo

ezSessionInfo()


uzh/ezRun documentation built on May 4, 2024, 3:23 p.m.