## nolint start suppressPackageStartupMessages({ library(goalie) library(basejump) library(dplyr) library(pointillism) }) prepareTemplate() source("_setup.R") ## nolint end
file <- params[["seurat_file"]] object <- import(file) name <- basenameSansExt(file) rm(file) assert( is(object, "Seurat"), is.character(name) ) invisible(validObject(object)) print(object)
idents <- levels(Idents(object)) interestingGroups <- interestingGroups(object) if (is.null(interestingGroups)) { interestingGroups <- "sampleName" }
groups <- unique(c("ident", "sampleName", interestingGroups)) invisible(lapply( X = groups, FUN = function(group) { markdownHeader(group, level = 2L, asis = TRUE) show(plotUmap(object, interestingGroups = group)) } )) rm(groups)
groups <- unique(c("sampleName", interestingGroups)) invisible(lapply( X = idents, FUN = function(ident) { subset <- subset(object, idents = ident) markdownHeader(ident, level = 2L, asis = TRUE, tabset = TRUE) invisible(lapply(groups, function(group) { markdownHeader(group, level = 3L, asis = TRUE) show(plotUmap(subset, interestingGroups = group)) })) } )) rm(groups)
invisible(lapply(idents, function(ident) { markdownHeader(ident, level = 2L, asis = TRUE, tabset = TRUE) subset <- subset(object, idents = ident) master <- subset[[]] assert(is.data.frame(master)) master <- as(master, "DataFrame") master[["ident"]] <- Idents(subset) if (!isSubset("sampleName", colnames(master))) { master[["sampleName"]] <- as.factor("unknown") } master <- uniteInterestingGroups( object = master, interestingGroups = interestingGroups ) sampleStats <- master |> as_tibble() |> arrange(sampleName) |> group_by(sampleName) |> summarize(count = n()) |> mutate(pct = signif(x = count / sum(count), digits = 2L)) show(sampleStats) intgroupStats <- master |> as_tibble() |> arrange(interestingGroups) |> group_by(interestingGroups) |> summarize(count = n()) |> mutate(pct = signif(x = count / sum(count), digits = 2L)) show(intgroupStats) }))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.