Skip to contents

This function calculates absolute cell densities for a SpatialExperiment object by scaling a specified column of relative cell fractions with provided absolute cell densities. The result is added as a new column in the colData of the SPE object.

Usage

scale_cell_counts(spe, value, cell_counts, resName = NULL)

Arguments

spe

An SpatialExperiment object containing spatial transcriptomics data.

value

A string specifying the name of the column in colData(spe) that contains relative cell fractions/deconvolution results to be scaled.

cell_counts

A named vector of absolute cell densities, where names correspond to the rownames in colData(spe).

resName

Optional; a string specifying the name of the new column to be added to colData(spe) that will contain the absolute cell densities. If NULL, defaults to appending "_absolute" to the value parameter.

Value

SPE object with added absolute celltype counts for each spot