knitr::opts_chunk$set(echo = TRUE)
## All genes
zValues = cor(xNormed, use="complete.obs")
figure.height <- min(max(7, nrow(zValues) * 0.3), 30)
## Top genes
zValuesNormaled = cor(xNormed[topGenes,], use="complete.obs")
## All genes
ezCorrelationPlot(zValues, cond=conds, condLabels=conds,
                  main=paste0("all present genes (", sum(isValid), ") gene-wise normalized"))
## Top genes
ezCorrelationPlot(zValuesNormaled, cond=conds, condLabels=conds,
                  main=paste0("top genes (", length(topGenes), ") gene-wise normalized"))
if (ncol(rawData) > 3){
  cat("#### Sample clustering", "\n")
  ## All genes
  d <- as.dist(1-cor(xNormed, use="complete.obs"));
  hc <- hclust(d, method="ward.D2")
  #hcd = as.dendrogram(, hang=-0.1)
  #hcd = colorClusterLabels(hcd, sampleColors)
  plotDendroAndColors(hc, sampleColors, autoColorHeight=TRUE, hang = -0.1,
                      main="all present genes; gene-wise normalized")

  ## Top genes
  d = as.dist(1-cor(xNormed[topGenes, ], use="complete.obs"));
  hc <- hclust(d, method="ward.D2")
  plotDendroAndColors(hc, sampleColors, autoColorHeight=TRUE, hang = -0.1,
                      main=paste("top", length(topGenes), 
                                 "genes; gene-wise normalized"))
}
## Don't run the expression density plot
if(ncol(rawData) > 3){
  cat("### Expression densities", "\n")
  cat("Zero or negative counts are not represented by the area!", "\n")
  cat("\n")
  plotCmd = expression({
      #countDensPlot(signal, sampleColors, main="all transcripts", bw=0.7)
      p = countDensGGPlot(cts=data.frame(signal,stringsAsFactors = F),
                          colors=colData(rawData)$sampleColors, alpha=0.4)
      print(p)
    })
  eval(plotCmd)
}


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