create_profile_matrix {SpatialDecon} | R Documentation |
Create custom cell profile matrix using single cell data. The average gene expression for each cell type is returned.
create_profile_matrix( mtx, cellAnnots, cellTypeCol, cellNameCol, matrixName = "Custom", outDir = "./", geneList = NULL, normalize = FALSE, scalingFactor = 5, minCellNum = 15, minGenes = 100, discardCellTypes = FALSE )
mtx |
cell x gene count matrix |
cellAnnots |
cell annotations with cell type and cell name as columns |
cellTypeCol |
column containing cell type |
cellNameCol |
column containing cell ID/name |
matrixName |
name of final profile matrix |
outDir |
path to desired output directory, set to NULL if matrix should not be written |
geneList |
gene list to filter profile matrix to |
normalize |
Should data be normalized? (TRUE/FALSE) if TRUE data will be normalize using total gene count |
scalingFactor |
what should all values be multiplied by for final matrix, set to 1 if no scaling is wanted |
minCellNum |
minimum number of cells of one type needed to create profile, exclusive |
minGenes |
minimum number of genes expressed in a cell, exclusive |
discardCellTypes |
should cell types be filtered for types like mitotic, doublet, low quality, unknown, etc. |
A custom cell profile matrix genes (rows) by cell types (columns), matrix gets written to disk and outDir
cellNames <- paste0("Cell", seq_len(1500)) geneNames <- paste0("Gene", seq_len(1500)) mtx <- matrix(data=sample(size = length(cellNames)*length(geneNames), replace = TRUE, x = c(0,seq_len(100)), prob = c(0.6784, rep(0.0075, 15), rep(0.005, 25), rep(0.002, 25), rep(0.001, 35))), ncol = length(cellNames), nrow = length(geneNames), dimnames = list(geneNames, cellNames)) cellAnnots <- as.data.frame(cbind(CellID=cellNames, cellType=sample(size = length(cellNames), replace = TRUE, x = c("A", "B", "C", "D"), prob = c(0.1, 0.4, 0.3, 0.2)))) table(cellAnnots$cellType) profile_matrix <- create_profile_matrix(mtx = mtx, cellAnnots = cellAnnots, cellTypeCol = "cellType", cellNameCol = "CellID", minGenes = 10, scalingFactor = 1) head(profile_matrix)