Closed ksm113 closed 2 years ago
Pertains to model_density.R.
# Also perform total aggregation on combined tumor and stroma totals <- region %>% group_by(t_number, panel, cell_type, batch) %>% summarise(area = sum(area), n = sum(n), .groups = "drop") %>% mutate(classifier_label = "Total", .before = everything()) %>% group_by(classifier_label) %>% mutate( area = ensure_one_value(area), # Fill in area when n==0 classifier_label = factor(classifier_label, levels = c("Stroma", "Tumor", "Total")) ) %>% mutate(density = if_else(n==0, 0, n / area)) bind_rows(region, totals) }
Unnecessarily copied code. How about
density_total <- density_per_region %>% group_by(t_number, panel, cell_type, batch, .drop=F) %>% summarize(n = sum(n), area = ensure_one_value(area)) %>% mutate(classifier_label = 'Total')
the density calculation from area and n can also be shared:
bind_rows(region, totals) %>% mutate(density = if_else(n==0, 0, n / area))
_Originally posted by @tychobismeijer in https://github.com/ksm113/ppbc/pull/2#discussion_r855556957_
I think I tried something like this already and it didn't quite work the way that I intended. Need to double check before implementation.
Deprecated
Pertains to model_density.R.
Unnecessarily copied code. How about
the density calculation from area and n can also be shared:
_Originally posted by @tychobismeijer in https://github.com/ksm113/ppbc/pull/2#discussion_r855556957_