Skip to content

Commit

Permalink
Update utils.R
Browse files Browse the repository at this point in the history
update get_num_cell_per_spot to accommodate spatial
  • Loading branch information
ycao6928 authored Oct 3, 2023
1 parent be04fe8 commit 20b2d09
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,23 @@ bulk_sample <- function(data, ncores = 1) {
#'
#' @export
get_num_cell_per_spot <- function(data) {
readcount <- log2(colSums2(data))

linMap <- function(x, from, to) {
(x - min(x)) / max(x - min(x)) * (to - from) + from
}

numberofcells <- linMap(readcount, 1, 100)

data$number_cells <- numberofcells

return(data)

data_cal <- logcounts(data)

readcount <- log2(colSums2(data_cal))

linMap <- function(x, from, to) {
(x - min(x)) / max(x - min(x)) * (to - from) + from
}

numberofcells <- linMap(readcount, 1, 100)

data$number_cells <- numberofcells

return(data)
}


#' Rearrange string
#'
#' @description
Expand Down

0 comments on commit 20b2d09

Please sign in to comment.