From bc18369cf73d9358c06f3cc7bb5c882934d1d59a Mon Sep 17 00:00:00 2001 From: Stephanie Date: Thu, 19 Oct 2023 13:31:25 -0400 Subject: [PATCH] code to combine matrices and track how big each split is --- .../qc_report/celltypes_supplemental_report.rmd | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index c0b8ef16..1a6d5c1c 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -140,17 +140,30 @@ calculate_jaccard_matrix <- function(celltype_df, colname1, colname2) { ```{r} # Calculate all jaccard matrices of interest for input to heatmap +# baseline matrix +jaccard_mat <- matrix( + nrow = 0, + ncol = length(unique(celltype_df$cluster)) +) + +# vector to track splitting the heatmap +split_lengths <- c() + if (has_submitter) { cluster_submitter_jaccard_matrix <- calculate_jaccard_matrix(celltype_df, "cluster", "submitter_celltype_annotation") + jaccard_mat <- rbind(jaccard_mat, cluster_submitter_jaccard_matrix) + split_lengths <- c(split_lengths, "Submitter annotations" = nrow(cluster_submitter_jaccard_matrix)) } if (has_singler) { cluster_singler_jaccard_matrix <- calculate_jaccard_matrix(celltype_df, "cluster", "singler_celltype_annotation") + jaccard_mat <- rbind(jaccard_mat, cluster_singler_jaccard_matrix) + split_lengths <- c(split_lengths, "SingleR annotations" = nrow(cluster_singler_jaccard_matrix)) } if (has_cellassign) { cluster_cellassign_jaccard_matrix <- calculate_jaccard_matrix(celltype_df, "cluster", "cellassign_celltype_annotation") + jaccard_mat <- rbind(jaccard_mat, cluster_cellassign_jaccard_matrix) + split_lengths <- c(split_lengths, "CellAssign annotations" = nrow(cluster_cellassign_jaccard_matrix)) } - -# TODO: Need a clean appraoch with correct logic for combining these matrices. ```