Skip to content

Commit

Permalink
fix: experiment countplots (#149)
Browse files Browse the repository at this point in the history
Co-authored-by: Max Schubach <max.schubach@bih-charite.de>
  • Loading branch information
visze and visze authored Dec 17, 2024
1 parent 061d78a commit d2be468
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
10 changes: 6 additions & 4 deletions workflow/rules/qc_report.smk
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ rule qc_report_count:
statistics_all_single="results/experiments/{project}/statistic/statistic_assigned_counts_single_{assignment}_{config}.tsv",
statistics_all_oligo_cor_all="results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_correlation.tsv",
statistics_all_oligo_cor_thresh="results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_correlation_minThreshold.tsv",
counts_per_oligo_dna="results/experiments/{project}/statistic/barcode/assigned_counts/{assignment}/{condition}_{config}_DNA_perBarcode.png",
counts_per_oligo_rna="results/experiments/{project}/statistic/barcode/assigned_counts/{assignment}/{condition}_{config}_RNA_perBarcode.png",
counts_per_oligo="results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_barcodesPerInsert.png",
counts_per_bc_dna="results/experiments/{project}/statistic/barcode/assigned_counts/{assignment}/{condition}_{config}_DNA_perBarcode.png",
counts_per_bc_rna="results/experiments/{project}/statistic/barcode/assigned_counts/{assignment}/{condition}_{config}_RNA_perBarcode.png",
activity_thresh="results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_group_barcodesPerInsert_box.png",
activity_all="results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_group_barcodesPerInsert_box_minThreshold.png",
dna_over_rna="results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_dna_vs_rna.png",
Expand Down Expand Up @@ -121,8 +122,9 @@ rule qc_report_count:
-P "ratio_oligo_coor_plot:{input.ratio_oligo_coor_plot}" \
-P "ratio_oligo_min_thre_plot:{input.ratio_oligo_min_thre_plot}" \
-P "statistics_all_merged:{input.statistics_all_merged}" \
-P "counts_per_oligo_dna:{input.counts_per_oligo_dna}" \
-P "counts_per_oligo_rna:{input.counts_per_oligo_rna}" \
-P "counts_per_oligo:{input.counts_per_oligo}" \
-P "counts_per_bc_dna:{input.counts_per_bc_dna}" \
-P "counts_per_bc_rna:{input.counts_per_bc_rna}" \
-P "statistics_all_single:{input.statistics_all_single}" \
-P "activity_all:{input.activity_all}" \
-P "activity_thresh:{input.activity_thresh}" \
Expand Down
1 change: 1 addition & 0 deletions workflow/rules/statistic/correlation.smk
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ rule statistic_correlation_hist_box_plots:
),
script=getScript("count/plot_perInsertCounts_stats.R"),
output:
"results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_barcodesPerInsert.png",
"results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_group_barcodesPerInsert_box.png",
"results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_group_barcodesPerInsert_box_minThreshold.png",
"results/experiments/{project}/statistic/assigned_counts/{assignment}/{config}/{condition}_dna_vs_rna.png",
Expand Down
19 changes: 12 additions & 7 deletions workflow/scripts/count/plot_perInsertCounts_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,17 @@ for (n in 1:(data %>% nrow())) {
assigned_counts <- all %>% filter(replicate == rep)

# Histograms
intercept <- median(assigned_counts$n_bc)
x_lim_n_bc <- min(max(assigned_counts$n_bc), 300)
intercept_median <- median(assigned_counts$n_bc)
intercept_mean <- mean(assigned_counts$n_bc)
hist_plot_list[[n]] <-
ggplot(assigned_counts, aes(x = n_bc)) +
geom_histogram(bins = 300) +
geom_vline(xintercept = intercept, colour = "red") +
xlim(0, 300) +
geom_histogram(bins = x_lim_n_bc) +
geom_vline(xintercept = intercept_median, colour = "red") +
geom_vline(xintercept = intercept_mean, colour = "blue") +
xlim(0, x_lim_n_bc) +
ylab("Frequency") +
xlab("Barcodes per oligo") +
ggtitle(paste("replicate", rep, sep = " "))

# Boxplots
Expand All @@ -214,22 +219,22 @@ for (n in 1:(data %>% nrow())) {
}

hist_plot <- do.call("plot_grid", c(hist_plot_list))
ggsave(sprintf("%s_barcodesPerInsert.png", outdir), hist_plot, width = 30, height = 30)
ggsave(sprintf("%s_barcodesPerInsert.png", outdir), hist_plot, dpi = 300, type = "cairo")



box_plot_insert <- do.call("plot_grid", c(box_plot_insert_list))
ggsave(sprintf("%s_group_barcodesPerInsert_box.png", outdir),
box_plot_insert,
width = 30, height = 30
dpi = 300, type = "cairo"
)

box_plot_insert_thresh <-
do.call("plot_grid", c(box_plot_insert_thresh_list))
ggsave(
sprintf("%s_group_barcodesPerInsert_box_minThreshold.png", outdir),
box_plot_insert_thresh,
width = 30, height = 30
dpi = 300, type = "cairo"
)

print("Script done")
23 changes: 18 additions & 5 deletions workflow/scripts/report/qc_report_count.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,33 @@ df_single.style.hide(axis="index").format( precision=2)

# Number of barcodes per oligo

Histogramm of number of barcodes per oligo. Median is blue, mean is red.
Median is red, mean is blue.


# Histograms barcodes per oligo, counts per barcode

Histogramm of number of barcodes per oligo and the number of counts per barcode devidied by DNA and RNA. Median is red, mean is blue.


::: {.panel-tabset}

# DNA
# Number of barcodes per oligo
```{python}
#| echo: false
display(Image(f"{workdir}/{counts_per_oligo}"))
```


# Number of counts per DNA barcode
```{python}
#| echo: false
display(Image(f"{workdir}/{counts_per_oligo_dna}"))
display(Image(f"{workdir}/{counts_per_bc_dna}"))
```

# RNA
# Number of counts per DNA barcode
```{python}
#| echo: false
display(Image(f"{workdir}/{counts_per_oligo_rna}"))
display(Image(f"{workdir}/{counts_per_bc_rna}"))
```

:::
Expand Down

0 comments on commit d2be468

Please sign in to comment.