Skip to content

Commit

Permalink
add mean.adj as an option for blend
Browse files Browse the repository at this point in the history
  • Loading branch information
jcyang34 committed Sep 5, 2023
1 parent 1e38113 commit bc8a012
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion R/RunCellToSystem.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param sys.small A filtered Seurat object. The active identity will be used to define populations for connectomic sampling and crossings.
#' @param ground.truth Ground truth signaling mechanisms present in sys.small.
#' @param assay The assay to run the CellToSystem transformation on. Defaults to "RNA."
#' @param blend Choice of linear operator to combine edges. Defaults to "mean", also accepts "sum"
#' @param blend Choice of linear operator to combine edges. Defaults to "mean", also accepts "sum","mean.adj"
#' @param meta.data.to.map A character vector of metadata names present in the original object which will be carried to the NICHES objects
#' @param output_format string. Choice of the output format. "seurat" will output a list of seurat objects, "raw" will output a list of lists with raw interaction matrix and compiled metadata
#'
Expand Down Expand Up @@ -50,6 +50,12 @@ RunCellToSystem <- function(sys.small,
if (blend == 'mean'){
rec.map2 <- Matrix::rowMeans(rec.map,dims = 1)
}
if (blend == 'mean.adj'){
binary <- rec.map > 0
percent.expression <- Matrix::rowSums(binary)/ncol(binary)
rec.map2 <- Matrix::rowMeans(rec.map,dims=1)
rec.map2 <- rec.map2/percent.expression
}
rec.map2 <- do.call(cbind, replicate(ncol(rec.map), rec.map2, simplify=FALSE))

# Ligand data
Expand Down
8 changes: 7 additions & 1 deletion R/RunSystemToCell.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param sys.small A filtered Seurat object. The active identity will be used to define populations for connectomic sampling and crossings.
#' @param ground.truth Ground truth signaling mechanisms present in sys.small.
#' @param assay The assay to run the SystemToCell transformation on. Defaults to "RNA."
#' @param blend Choice of linear operator to combine edges. Defaults to "mean", also accepts "sum"
#' @param blend Choice of linear operator to combine edges. Defaults to "mean", also accepts "sum", "mean.adj"
#' @param meta.data.to.map A character vector of metadata names present in the original object which will be carried to the NICHES objects
#' @param output_format string. Choice of the output format. "seurat" will output a list of seurat objects, "raw" will output a list of lists with raw interaction matrix and compiled metadata
#'
Expand Down Expand Up @@ -49,6 +49,12 @@ RunSystemToCell <- function(sys.small,
if (blend == 'mean'){
lig.map2 <- Matrix::rowMeans(lig.map,dims = 1)
}
if (blend == 'mean.adj'){
binary <- lig.map > 0
percent.expression <- Matrix::rowSums(binary)/ncol(binary)
lig.map2 <- Matrix::rowMeans(lig.map,dims=1)
lig.map2 <- lig.map2/percent.expression
}
lig.map2 <- do.call(cbind, replicate(ncol(lig.map), lig.map2, simplify=FALSE))

# Receptor data
Expand Down

0 comments on commit bc8a012

Please sign in to comment.