From 885960c4ed3925a67973de244a98c5a43922dce4 Mon Sep 17 00:00:00 2001 From: RubD Date: Sat, 16 Sep 2023 17:21:50 -0400 Subject: [PATCH] fix error in niche calculation code --- R/combine_metadata.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/combine_metadata.R b/R/combine_metadata.R index 43a765f8..719c5065 100644 --- a/R/combine_metadata.R +++ b/R/combine_metadata.R @@ -563,9 +563,13 @@ calculateSpatCellMetadataProportions = function(gobject, output = 'data.table') # merge spatial network and cell metadata - network_annot = data.table::merge.data.table(network, cell_meta[,c('cell_ID', metadata_column), with = FALSE], by.x = 'source', by.y = 'cell_ID') + network_annot = data.table::merge.data.table(x = sp_network, + y = cell_meta[,c('cell_ID', metadata_column), with = FALSE], + by.x = 'source', by.y = 'cell_ID') setnames(network_annot, old = metadata_column, 'source_clus') - network_annot = data.table::merge.data.table(network_annot, cell_meta[,c('cell_ID', metadata_column), with = FALSE], by.x = 'target', by.y = 'cell_ID') + network_annot = data.table::merge.data.table(x = network_annot, + y = cell_meta[,c('cell_ID', metadata_column), with = FALSE], + by.x = 'target', by.y = 'cell_ID') setnames(network_annot, old = metadata_column, 'target_clus') # create self information: source cell is its own neighbor