Skip to contents

Convert the coordinates of set of genes into vectors.

Usage

create_genesets(
  data_lst,
  name_lst,
  bin_type = "square",
  bin_param,
  w_x = w_x,
  w_y = w_y,
  cluster_info
)

Arguments

data_lst

A list of named matrices containing the coordinates of transcripts.

name_lst

A named list of strings giving the name of features that are treated as background.

bin_type

A string indicating which bin shape is to be used for vectorization. One of "square" (default), "rectangle", or "hexagon".

bin_param

A numeric vector indicating the size of the bin. If the bin_type is "square" or "rectangle", this will be a vector of length two giving the numbers of rectangular quadrats in the x and y directions. If the bin_type is "hexagonal", this will be a number giving the side length of hexagons. Positive numbers only.

w_x

A numeric vector of length two specifying the x coordinate limits of enclosing box.

w_y

A numeric vector of length two specifying the y coordinate limits of enclosing box.

cluster_info

A dataframe/matrix containing the centroid coordinates, cluster and sample label for each cell.The column names must include "x" (x coordinate), "y" (y coordinate), "cluster" (cluster label) and "sample" (sample).

Value

A matrix contains the sum count in each grid. Each row refers to a grid, each column refers to a set in name_lst. The column name will match the names in name_lst.

Examples

set.seed(15)
trans = as.data.frame(rbind(cbind(x = runif(10, min=1, max=10),
                                y = runif(10, min=1, max=10),
                                feature_name="A"),
                         cbind(x = runif(5, min=10, max=24),
                               y = runif(5, min=1, max=10),
                               feature_name="B"),
                         cbind(x = runif(10, min=10, max=24),
                               y = runif(10, min=10, max=24),
                               feature_name="C")))
trans$x = as.numeric(trans$x)
trans$y = as.numeric(trans$y)
geneset_res = create_genesets(data_lst=list("rep1"= trans),
                           name_lst=list(dummy_A=c("A","C"),
                                         dummy_B=c("A","B","C")),
                           bin_type="square",
                           bin_param=c(2,2),
                           w_x=c(0,25), w_y=c(0,25), cluster_info=NULL)