We need to clean up our cell metadata if samples are dropped. Else they appear in legends of plots later on... This chunk should placed just before ## Normalisation.
# Remove filtered cells from meta data
sc_cell_metadata = sc_cell_metadata %>% dplyr::filter(IS_FILTERED==FALSE)
# Update levels
idx.factors = sapply(sc_cell_metadata, is.factor) %>% which()
for (n in colnames(sc_cell_metadata[idx.factors])) {
levels_new = sc_cell_metadata %>% dplyr::pull(n) %>% as.character() %>% unique()
sc_cell_metadata[[n]] = factor(sc_cell_metadata[[n]], levels=levels_new)
}
# Update actual colors as well, as they will appear in the plots otherwise
param$col_samples_orig = param$col_samples
param$col_samples = param$col_samples_orig[ -match(param$samples_to_drop, names(param$col_samples_orig)) ]
We need to clean up our cell metadata if samples are dropped. Else they appear in legends of plots later on... This chunk should placed just before
## Normalisation
.