Skip to content

Commit

Permalink
Merge pull request #138 from omnideconv/updateScaling
Browse files Browse the repository at this point in the history
Update scaling function
  • Loading branch information
czackl committed Mar 15, 2024
2 parents eb36e11 + 9259e20 commit 67a3d35
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/scale_cell_counts.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ scale_cell_counts <- function(spe, value, cell_counts, resName = NULL) {
resName <- paste0(value, "_absolute")
}

if (any(is.na(match(rownames(colData(spe)), names(cell_densities))))) {
stop("Not all rownames in colData have a matching entry in cell_densities.")
if (cell_counts %in% colnames(colData(spe))) {
cell_densities <- colData(spe)[, cell_counts]
} else {
stop("Cell count data not available in the object")
}

# Calculate absolute cell densities
absoluteValues <- colData(spe)[, value] * cell_densities[rownames(colData(spe))]
absoluteValues <- colData(spe)[, value] * cell_densities

# Add the absolute cell densities as a new column
colData(spe)[[resName]] <- absoluteValues
Expand Down

0 comments on commit 67a3d35

Please sign in to comment.