From 01829471e949d476651b34795ee9804efe9093d7 Mon Sep 17 00:00:00 2001 From: Jacob Mitchell Date: Fri, 10 Nov 2023 15:24:31 -0500 Subject: [PATCH] removed redundant mean_ligand_expression Function definition appeared a second time. Likely arose from merging branches earlier. --- R/import_fxns.R | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/R/import_fxns.R b/R/import_fxns.R index 9fbf573..20ea59e 100644 --- a/R/import_fxns.R +++ b/R/import_fxns.R @@ -655,40 +655,19 @@ add_rl_column <- function(map, map_ref, conv, new_name) { #' @return A data frame of ligand expression targeting the specified receptor #' @export #' -mean_ligand_expression <- - function(x, ligands, cell_ident, cell_barcodes, destination){ - # initiate data frame to store results - df <- NULL - - for(feat in ligands){ - # index of ligand row - lig_index <- grep(paste0("^", feat, "$"), rownames(x)) - # column indecies of cells belonging to cell_ident - cell_index <- colnames(x) %in% cell_barcodes - - cell_df <- data.frame( - origin = paste0(cell_ident, "_", feat), - destination = destination, - mean.expression = mean(x[lig_index, cell_index]) - ) - - df <- rbind(df, cell_df) - } - return(df) - } - -#' @export -#' -mean_ligand_expression <- function(x, ligands, cell_ident, cell_barcodes, destination) { +mean_ligand_expression <- function(x, ligands, cell_ident, cell_barcodes, destination){ # initiate data frame to store results df <- NULL - for (feat in ligands) { + for(feat in ligands){ # index of ligand row lig_index <- grep(paste0("^", feat, "$"), rownames(x)) - # column indices of cells belonging to cell_ident + # column indecies of cells belonging to cell_ident cell_index <- colnames(x) %in% cell_barcodes - cell_df <- data.frame(origin = paste0(cell_ident, "_", feat), destination = destination, mean.expression = mean(x[lig_index, - cell_index])) + cell_df <- data.frame( + origin = paste0(cell_ident, "_", feat), + destination = destination, + mean.expression = mean(x[lig_index, cell_index]) + ) df <- rbind(df, cell_df) } return(df)