require(singleCellTK)
require(DT)
require(knitr)
sce <- params$object
fmTable <- metadata(sce)$findMarker
useAssay <- attr(fmTable, "useAssay")
method <- attr(fmTable, "method")
clusterName <- names(fmTable)[5]
nCluster <- length(unique(as.vector(sce[[clusterName]])))
uniqClusters <- sort(unique(as.vector(sce[[clusterName]])))
fmParams <- attr(fmTable, "params")
log2fcThreshold <- fmParams$log2fcThreshold
fdrThreshold <- fmParams$ fdrThreshold
minClustExprPerc <- fmParams$minClustExprPerc
maxCtrlExprPerc <- fmParams$maxCtrlExprPerc
minMeanExpr <- fmParams$minMeanExpr

Analysis Setting

Find Marker basing on: r clusterName

The marker finding was accomplished by iteratively performing one-against-others differential expression analysis for each cluster. There are r nCluster clusters found in the given SingleCellExperiment object. Here is the summary of the number of cells in each cluster:

sum.table <- t(as.data.frame(table(sce[[names(metadata(sce)$findMarker)[5]]])))
rownames(sum.table) <- c("cluster", "cell number")
datatable(sum.table, 
          options = list(
            headerCallback = JS(
              "function(thead, data, start, end, display){",
              "  $(thead).remove();",
              "}"),
            dom = 't')
)

Method: r method

The method used for performing the differential expression analysis was "r method". For the more information of the method, please refer to the help page.

Parameters

After the computation, we further filtered the result to select the differentially expressed genes with high significance and high fold change. Specifically, the parameters used are:

p <- data.frame(parameter = c("Min. logFC", 
                              "Max. FDR", 
                              "Min. Cluster Expression %", 
                              "Max. Control Expression %", 
                              "Min. Mean Expression"),
                value = c(log2fcThreshold,
                          fdrThreshold,
                          minClustExprPerc,
                          maxCtrlExprPerc,
                          minMeanExpr))
datatable(p, options = list(dom = "t"))

When we identify a gene to be the marker of the cluster of interests:

Result

We report maximum 10 top markers for each cluster, ranked by the FDR value.

Marker Table {.tabset}

out = NULL
for (i in uniqClusters) {
  fmTable.cluster <- fmTable[fmTable[[clusterName]] == i,]
  if (nrow(fmTable.cluster) >= 10) {
    fmTable.cluster.top <- fmTable.cluster[1:10,]
  } else {
    fmTable.cluster.top <- fmTable.cluster
  }
  res <- knit_child('FM_child_cluster.Rmd', quiet=TRUE)
  cat(res, sep = '\n')
}

Heatmap

In the marker heatmap, each column stands for a cell in the given SingleCellExperiment object. The cell level color bar annotates the cluster assignment. Each row is a marker gene, and the gene level color bar assigns the cluster correspondence. The cell cluster is ordered by the cluster population size.

It happens sometimes that a gene is identified as the marker for more than one cluster. In this scenario, we finally assign it to the cluster where it has a higher "logFC" value when plotting.

plotFindMarkerHeatmap(sce, 
                  log2fcThreshold = 0.5, 
                  minClustExprPerc = 0.7, 
                  maxCtrlExprPerc = 0.4, 
                  minMeanExpr = 1)


compbiomed/singleCellTK documentation built on May 8, 2024, 6:58 p.m.