@@ -45,17 +45,16 @@ library(Seurat)
45
45
library(AUCell)
46
46
library(ezRun)
47
47
library(HDF5Array)
48
+ library(enrichR)
48
49
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE, knitr.table.format = "html")
49
- ```
50
50
51
- ``` {r}
52
51
clusterInfoFile <- "clusterInfos.xlsx"
53
52
posMarkers <- readxl::read_xlsx("posMarkers.xlsx")
54
53
scData <- readRDS("scData.rds")
55
54
output <- readRDS("output.rds")
56
55
scData$qc.doublet <- scData$doubletClass %in% "doublet"
57
56
allCellsMeta <- readRDS("allCellsMeta.rds")
58
- param = readRDS("param.rds")
57
+ param <- readRDS("param.rds")
59
58
species <- getSpecies(param$refBuild)
60
59
if (file.exists("singler.results.rds")){
61
60
singler.results <- readRDS("singler.results.rds")
@@ -233,7 +232,8 @@ cellIdents_perSample <- data.frame(ident = Idents(scData), Sample=scData$Sample)
233
232
barplot = ggplot(data=cellIdents_perSample, aes(x=ident, fill=Sample)) + geom_bar(stat="Count")
234
233
barplot + labs(x="Cluster", y = "Number of cells", fill = "Sample")
235
234
236
- cells_prop = cellsProportion(scData, groupVar1 = "ident", groupVar2 = "Sample")
235
+
236
+ cells_prop = cellsProportion(scData, groupVar1 = "seurat_clusters", groupVar2 = "Sample")
237
237
kable(cells_prop,row.names=FALSE, format="html",caption="Cell proportions") %>% kable_styling(bootstrap_options = "striped", full_width = F, position = "float_right")
238
238
```
239
239
@@ -293,7 +293,9 @@ FeaturePlot(scData, features="negLog10CellPValue", label = TRUE)
293
293
``` {r, fig.width=12, fig.height=shrinkToRange(length(param$controlSeqs)*3/4, c(6, 18)), eval=ezIsSpecified(param$controlSeqs)}
294
294
genesToPlot <- gsub("_", "-", param$controlSeqs)
295
295
genesToPlot <- intersect(genesToPlot, rownames(scData))
296
- FeaturePlot(scData, genesToPlot) + NoLegend()
296
+ if (length(genesToPlot) > 0){
297
+ FeaturePlot(scData, genesToPlot) + NoLegend()
298
+ }
297
299
```
298
300
299
301
#### Cluster resolution
@@ -369,27 +371,28 @@ enrichrCalls <- paste0("<a href='javascript:void(0)' onClick='", jsCall,
369
371
```
370
372
371
373
372
- ``` {r load enrichR terms, echo=FALSE, results='asis', eval= !is.null(enrichRout)}
373
- enrichRTerm <- as.data.frame(do.call(rbind, lapply(enrichRout, as.vector)))
374
- enrichRTerm <- map_df(enrichRTerm, ~ map_df(.x, ~ replace(.x, is.null(.x), NA)), .id = "database")
375
- enrichRTerm <- enrichRTerm %>%
376
- group_by(., Cluster, database) %>%
377
- summarise(topTerms = paste(Term, collapse = "; ")) %>%
378
- as.data.frame()
379
- enrichRTerm <- dcast(enrichRTerm, ... ~ database)
380
- enrichrTable <- merge(enrichrTable, enrichRTerm, by = "Cluster")
381
- ```
382
374
383
375
``` {r enrichr markers, echo=FALSE, results='asis'}
384
376
enrichrTable <- tibble(Cluster=names(genesPerCluster),
385
377
"# of posMarkers"=lengths(genesPerCluster),
386
378
"Enrichr link"=enrichrCalls)
379
+ if (!is.null(enrichRout)){
380
+ enrichRTerm <- as.data.frame(do.call(rbind, lapply(enrichRout, as.vector)))
381
+ enrichRTerm <- map_df(enrichRTerm, ~ map_df(.x, ~ replace(.x, is.null(.x), NA)), .id = "database")
382
+ enrichRTerm <- enrichRTerm %>%
383
+ group_by(., Cluster, database) %>%
384
+ summarise(topTerms = paste(Term, collapse = "; ")) %>%
385
+ as.data.frame()
386
+ enrichRTerm <- dcast(enrichRTerm, ... ~ database)
387
+ enrichrTable <- merge(enrichrTable, enrichRTerm, by = "Cluster")
388
+ }
387
389
kable(enrichrTable, format="html", escape=FALSE,
388
390
caption=paste0("GeneSet enrichment")) %>%
389
391
kable_styling("striped", full_width = F, position = "left")
390
392
```
391
393
392
394
395
+
393
396
``` {r plot enrichR per cluster, fig.height=5, fig.width=10, eval= !is.null(enrichRout)}
394
397
for (cluster in names(enrichRout)) {
395
398
enrichRDataFrame <- as.data.frame(do.call(rbind, enrichRout[[cluster]]))
0 commit comments