runCPie: Run SpatialCPie

Description Usage Arguments Value Examples

Description

Runs the SpatialCPie gadget.

Usage

1
2
3
4
runCPie(counts, image = NULL, spotCoordinates = NULL,
  margin = "spot", resolutions = 2:4,
  assignmentFunction = function(k, x) kmeans(x, centers = k)$cluster,
  view = NULL)

Arguments

counts

gene count matrix or a SummarizedExperiment-class object containing count values.

image

image to be used as background to the plot.

spotCoordinates

data.frame with pixel coordinates. The rows should correspond to the columns (spatial areas) in the count file.

margin

which margin to cluster.

resolutions

numeric vector specifying the clustering resolutions.

assignmentFunction

function to compute cluster assignments.

view

viewer object.

Value

a list with the following items:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if (interactive()) {
    options(device.ask.default = FALSE)

    ## Set up coordinate system
    coordinates <- as.matrix(expand.grid(1:10, 1:10))

    ## Generate data set with three distinct genes generated by three
    ## distinct cell types
    profiles <- diag(rep(1, 3)) + runif(9)
    centers <- cbind(c(5, 2), c(2, 8), c(8, 2))
    mixes <- apply(coordinates, 1, function(x) {
        x <- exp(-colSums((centers - x) ^ 2) / 50)
        x / sum(x)
    })
    means <- 100 * profiles %*% mixes
    counts <- matrix(rpois(prod(dim(means)), means), nrow = nrow(profiles))
    colnames(counts) <- apply(
        coordinates,
        1,
        function(x) do.call(paste, c(as.list(x), list(sep = "x")))
    )
    rownames(counts) <- paste("gene", 1:nrow(counts))

    ## Run SpatialCPie
    runCPie(counts)
}

SpatialCPie documentation built on Nov. 8, 2020, 7:43 p.m.