Skip to content

Commit

Permalink
add pvalues to final spillover-reduction figure
Browse files Browse the repository at this point in the history
  • Loading branch information
grst committed Nov 14, 2018
1 parent b307dc0 commit b950c06
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions notebooks/70_pub_figures.Rmd
Expand Up @@ -413,34 +413,39 @@ migration_legend = cowplot::get_legend(p)

```{r, include=FALSE}
# Plot differences with removed marker genes
rmgenes_plot_dc = res_spillover$rm_marker_genes_dc %>%
rmgenes_data_dc = res_spillover$rm_marker_genes_dc %>%
inner_join(method_names) %>%
filter(cell_type == "B cell") %>%
mutate(dataset = if_else(dataset == "before", "no", "yes")) %>%
mutate(dataset = if_else(dataset == "before", "no", "yes"))
rmgenes_plot_dc = rmgenes_data_dc %>%
ggplot(aes(x=dataset, y=predicted_fraction, colour=dataset)) +
geom_quasirandom() +
stat_summary(fun.y=mean, geom="crossbar", fun.ymin=mean, fun.ymax=mean, width=.5, color="black") +
facet_wrap(~method_name, drop = TRUE) +
stat_compare_means(paired = TRUE, method = "t.test", label="p.signif") +
stat_compare_means(paired = TRUE, method = "t.test", label="p") +
theme(legend.position = "none") +
xlab("signature genes removed") +
ylab("predicted B cell score") +
scale_color_brewer(type="qual", palette=6, direction = -1) +
ylim(0, .75) +
theme(plot.margin = margin(t=1, unit = "cm"))
```

```{r, include=FALSE}
rmgenes_plot_cd4 = res_spillover$rm_marker_genes_cd4 %>%
rmgenes_data_cd4 = res_spillover$rm_marker_genes_cd4 %>%
inner_join(method_names) %>%
filter(cell_type == "T cell CD4+") %>%
mutate(dataset = if_else(dataset == "before", "no", "yes")) %>%
mutate(dataset = if_else(dataset == "before", "no", "yes"))
rmgenes_plot_cd4 = rmgenes_data_cd4 %>%
ggplot(aes(x=dataset, y=predicted_fraction, colour=dataset)) +
geom_quasirandom() +
stat_summary(fun.y=mean, geom="crossbar", fun.ymin=mean, fun.ymax=mean, width=.5, color="black") +
facet_wrap(~method_name, drop = TRUE) +
stat_compare_means(paired = TRUE, method = "t.test", label="p.signif") +
stat_compare_means(paired = TRUE, method = "t.test", label="p") +
theme(legend.position = "none") +
xlab("signature genes removed") +
ylab("predicted CD4⁺ T cell score") +
Expand All @@ -451,6 +456,19 @@ rmgenes_plot_cd4 = res_spillover$rm_marker_genes_cd4 %>%
```

```{r spillover_correction_pvalues, include=FALSE}
tmp_datas = list("cd4_background"=rmgenes_data_cd4, "b_dc_spillover"=rmgenes_data_dc)
lapply(names(tmp_datas), function(which_data) {
lapply(c("epic", "quantiseq", "cibersort"), function(method) {
tmp_data = tmp_datas[[which_data]] %>% filter(method == !!method) %>%
spread(dataset, predicted_fraction)
cat(sprintf("## Testing before/after filtering unspecific genes for %s for method %s", which_data, method))
print(t.test(tmp_data$yes, tmp_data$no, paired = TRUE, alternative = "two.sided"))
cat(sprintf("-> Reduction by %f", (mean(tmp_data$no)-mean(tmp_data$yes))/mean(tmp_data$no) ), "\n\n")
})
})
```

```{r fig.width = 8, fig.height=9, echo=FALSE, message=FALSE, fig.cap="Migration chart figure for paper. "}
# combine legend and plot
plot_lower = plot_grid(rmgenes_plot_cd4, rmgenes_plot_dc,
Expand Down

0 comments on commit b950c06

Please sign in to comment.