Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Remove R script/notebook package installs from snv-callers (Part 2 of N) #701

Merged
21 changes: 7 additions & 14 deletions analyses/snv-callers/compare_snv_callers_plots-tcga.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ _This assumes you are in the top directory of the repository._
Read in set up script.

```{r}
if (!("ggupset" %in% installed.packages())) {
install.packages("ggupset", repos = "http://cran.us.r-project.org")
}
if (!("UpSetR" %in% installed.packages())) {
install.packages("UpSetR", repos = "http://cran.us.r-project.org")
}
if (!("GGally" %in% installed.packages())) {
install.packages("GGally", repos = "http://cran.us.r-project.org")
}
# Magrittr pipe
`%>%` <- dplyr::`%>%`
```
Expand Down Expand Up @@ -215,9 +206,8 @@ Save this plot to a png

```{r}
# We can save the plot like a normal ggplot
png(file = file.path(plots_dir, "tcga-upset_plot.png"))
upsettr_plot
dev.off()
ggplot2::ggsave(upsettr_plot,
file = file.path(plots_dir, "tcga-upset_plot.png"))
```

Transcripts only upset plot.
Expand All @@ -244,19 +234,22 @@ Graph the median VAF for each combination of callers.

```{r}
# Make this plot
callers_per_mutation %>%
median_vaf_plot <- callers_per_mutation %>%
ggplot2::ggplot(ggplot2::aes(x = caller_combo, y = median_vaf)) +
ggplot2::geom_violin() +
ggplot2::theme_classic() +
ggupset::scale_x_mergelist(sep = "-") +
ggupset::axis_combmatrix(sep = "-") +
ggplot2::xlab("") +
ggplot2::ylab("Median VAF Across Callers")

# Print out plot
median_vaf_plot
```

```{r}
# Save this plot
ggplot2::ggsave(file.path(plots_dir, "tcga-upset_median_vaf_plot.png"))
ggplot2::ggsave(plot = median_vaf_plot, file.path(plots_dir, "tcga-upset_median_vaf_plot.png"))
```

## Base Changes
Expand Down
142 changes: 58 additions & 84 deletions analyses/snv-callers/compare_snv_callers_plots-tcga.nb.html

Large diffs are not rendered by default.

45 changes: 18 additions & 27 deletions analyses/snv-callers/compare_snv_callers_plots.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ _This assumes you are in the top directory of the repository._
Read in set up script.

```{r}
if (!("ggupset" %in% installed.packages())) {
install.packages("ggupset", repos = "http://cran.us.r-project.org")
}
if (!("UpSetR" %in% installed.packages())) {
install.packages("UpSetR", repos = "http://cran.us.r-project.org")
}
if (!("GGally" %in% installed.packages())) {
install.packages("GGally", repos = "http://cran.us.r-project.org")
}
# Magrittr pipe
`%>%` <- dplyr::`%>%`
```
Expand All @@ -67,8 +58,8 @@ Set up directories.

```{r}
scratch_dir <- file.path("..", "..", "scratch")
results_dir <- file.path("results", "comparison")
plots_dir <- file.path("plots", "comparison")
results_dir <- file.path("results", "pbta-comparison")
plots_dir <- file.path("plots", "pbta-comparison")

if (!dir.exists(results_dir)) {
dir.create(results_dir)
Expand All @@ -93,6 +84,7 @@ callers_per_mutation_df %>%
ggplot2::ylab("")
}
```

## Connect to database

Connect to SQLite database.
Expand Down Expand Up @@ -124,10 +116,10 @@ lancet <- dplyr::tbl(con, "lancet") %>%
dplyr::select(join_cols, "VAF")

mutect <- dplyr::tbl(con, "mutect") %>%
dplyr::select(join_cols, "VAF")
dplyr::select(join_cols, "VAF")

vardict <- dplyr::tbl(con, "vardict") %>%
dplyr::select(join_cols, "VAF")
dplyr::select(join_cols, "VAF")
```

Because `DBI` does not support full_join, we had to use a series of `left_join` and
Expand Down Expand Up @@ -220,9 +212,8 @@ Save this plot to a png

```{r}
# We can save the plot like a normal ggplot
png(file = file.path(plots_dir, "upset_plot.png"))
upsettr_plot
dev.off()
ggplot2::ggsave(plot = upsettr_plot,
file.path(plots_dir, "pbta-upset_plot.png"))
```

Transcripts only upset plot.
Expand All @@ -249,19 +240,23 @@ Graph the median VAF for each combination of callers.

```{r}
# Make this plot
callers_per_mutation %>%
median_vaf_plot <- callers_per_mutation %>%
ggplot2::ggplot(ggplot2::aes(x = caller_combo, y = median_vaf)) +
ggplot2::geom_violin() +
ggplot2::theme_classic() +
ggupset::scale_x_mergelist(sep = "-") +
ggupset::axis_combmatrix(sep = "-") +
ggplot2::xlab("") +
ggplot2::ylab("Median VAF Across Callers")

# Print out
median_vaf_plot
```

```{r}
# Save this plot
ggplot2::ggsave(file.path(plots_dir, "upset_median_vaf_plot.png"))
ggplot2::ggsave(plot = median_vaf_plot,
file.path(plots_dir, "upset_median_vaf_plot.png"))
```

## Base Changes
Expand Down Expand Up @@ -347,19 +342,15 @@ ggplot2::ggsave(file.path(plots_dir, "vaf_violin_plot.png"))

## VAF correlations

Make the plot with ggpairs.
Correlate VAF's across callers

```{r}
GGally::ggpairs(vaf_df %>% dplyr::select(-VAF_consensus, -Variant_Classification),
mapping = ggplot2::aes(alpha = 0.05)) +
ggplot2::theme_classic()
vaf_df %>%
dplyr::select(-VAF_consensus, -Variant_Classification) %>%
cor() %>%
knitr::kable()
```

```{r}
# Save this plot
ggplot2::ggsave(file.path(plots_dir, "vaf_correlations_plot.png"))
cansavvy marked this conversation as resolved.
Show resolved Hide resolved
```

## Mutation Region barplot

Summarize `Variant_Classification` information per caller.
Expand Down
Loading