From 4678a1a59269ed3f67efea58f04b82131b7d9152 Mon Sep 17 00:00:00 2001 From: alvaannett <46521652+alvaannett@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:09:50 -0400 Subject: [PATCH 1/3] Update annotate_report.Rmd --- Notebooks/annotate_report.Rmd | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Notebooks/annotate_report.Rmd b/Notebooks/annotate_report.Rmd index d44e134..e938182 100644 --- a/Notebooks/annotate_report.Rmd +++ b/Notebooks/annotate_report.Rmd @@ -42,6 +42,14 @@ marker_genes = strsplit(params$marker_genes, split = ' ')[[1]] ``` ```{r} +harmonize_unresolved = function(pred, ref_labels){ + pred %>% + column_to_rownames('cellname') %>% + mutate(across(where(is.character), ~ifelse(. %in% c(ref_labels$label), ., 'Unresolved'))) %>% + rownames_to_column('cellname') %>% + return() +} + plot_tool_correlation_heatmap = function(seurat, tools){ mat = query@meta.data %>% @@ -251,7 +259,7 @@ for(r in refs){ list[[r]]$lab = data.table::fread(paste0(params$output_dir, '/model/', r, '/labels.csv'), header = T) list[[r]]$pred = data.table::fread(paste0(params$output_dir, '/', params$sample, '/', r, '/Prediction_Summary.tsv')) %>% - harmonize_unsure(., list[[r]]$lab) + harmonize_unresolved(., list[[r]]$lab) # create reference pal list[[r]]$pal = create_color_pal(list[[r]]$lab$label) From a802aa4b07678a5bdc8401117245497d14dacb81 Mon Sep 17 00:00:00 2001 From: alvaannett <46521652+alvaannett@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:18:49 -0400 Subject: [PATCH 2/3] Update annotate_report.Rmd --- Notebooks/annotate_report.Rmd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Notebooks/annotate_report.Rmd b/Notebooks/annotate_report.Rmd index e938182..84e956c 100644 --- a/Notebooks/annotate_report.Rmd +++ b/Notebooks/annotate_report.Rmd @@ -163,7 +163,7 @@ x = seurat@meta.data %>% color_class_seurat = function(seurat, meta_column, pal){ list = list() - pal['Unsure'] = 'red' + pal['Unresolved'] = 'red' pal['No Consensus'] = 'red' Idents(seurat) = meta_column class = (table(query@meta.data[[meta_column]]) %>% as.data.frame() %>% filter(Freq > 20))$Var @@ -202,7 +202,7 @@ umap_plotly = function(seurat, meta_column, pal){ return(p2) } -calculate_percentage_unsure = function(pred, order){ +calculate_percentage_unresolved = function(pred, order){ warn = pred %>% select(order) %>% pivot_longer(order) %>% @@ -211,7 +211,7 @@ calculate_percentage_unsure = function(pred, order){ count(value, .drop = F) %>% mutate(frac = n/sum(n)*100) %>% filter(!(!name == 'Consensus' & value == 'No Consensus')) %>% - filter(value %in% c('No Consensus', 'Unsure')) %>% + filter(value %in% c('No Consensus', 'Unresolved')) %>% mutate(warn = case_when(frac >= 70 ~ 'HIGH', frac < 70 & frac > 30 ~ 'MEDIUM', frac <= 30 ~ 'LOW')) @@ -327,9 +327,9 @@ for(r in refs){ cat(" \n## Prediction QC \n") - cat("