Skip to content

Commit

Permalink
Fix minor plot rendering issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Vera N. Karlbauer committed Jun 5, 2025
1 parent 0d094a7 commit c5ecf99
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scripts/10_correction_batch_effects_unfiltered.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ if (correction_variable_1 == "PLEASE FILL IN"){
var_explained = 100*round(summary(PCA_object)$importance[2,], 2),
cumm_var_explained = 100*round(summary(PCA_object)$importance[3,], 2))
variance_explained %>%
screeplot <- variance_explained %>%
dplyr::slice(1:10) %>%
ggplot(aes(x = factor(PC, level = PC), y = var_explained, group = 1)) +
geom_point() +
geom_line() +
geom_text(aes(label = cumm_var_explained), vjust = 1.5) +
labs(x = "Principal Component", y = "Variance Explained (%)", title = "Scree Plot",
subtitle = "Note: cumulative variance explained (%) is displayed as text")
print(screeplot)
R <- pc_cutoff(variance_explained) # automatically calculate number of PCs
print(paste0(R, " PCs were included"))
Expand Down Expand Up @@ -231,7 +232,8 @@ if (correction_variable_1 == "PLEASE FILL IN"){
```

```{r, print p-value table for batch effects after correction of first batch effect variable}
anova_lm_pvalue_df %>% paged_table()
if (correction_variable_1 != "PLEASE FILL IN"){
anova_lm_pvalue_df %>% paged_table()}
```

```{r, correction of second batch effect and PCA, results='asis'}
Expand All @@ -250,14 +252,15 @@ if (correction_variable_2 == "PLEASE FILL IN"){
var_explained = 100*round(summary(PCA_object)$importance[2,], 2),
cumm_var_explained = 100*round(summary(PCA_object)$importance[3,], 2))
variance_explained %>%
screeplot <- variance_explained %>%
dplyr::slice(1:10) %>%
ggplot(aes(x = factor(PC, level = PC), y = var_explained, group = 1)) +
geom_point() +
geom_line() +
geom_text(aes(label = cumm_var_explained), vjust = 1.5) +
labs(x = "Principal Component", y = "Variance Explained (%)", title = "Scree Plot",
subtitle = "Note: cumulative variance explained (%) is displayed as text")
print(screenplot)
R <- pc_cutoff(variance_explained) # automatically calculate number of PCs
print(paste0(R, " PCs were included"))
Expand Down Expand Up @@ -394,7 +397,8 @@ if (correction_variable_2 == "PLEASE FILL IN"){
```

```{r, print p-value table for batch effects after correction of second batch effect variable}
anova_lm_pvalue_df %>% paged_table()
if (correction_variable_2 != "PLEASE FILL IN"){
anova_lm_pvalue_df %>% paged_table()}
```

```{r, correction of third batch effect and PCA, results='asis'}
Expand All @@ -413,14 +417,15 @@ if (correction_variable_3 == "PLEASE FILL IN"){
var_explained = 100*round(summary(PCA_object)$importance[2,], 2),
cumm_var_explained = 100*round(summary(PCA_object)$importance[3,], 2))
variance_explained %>%
screeplot <- variance_explained %>%
dplyr::slice(1:10) %>%
ggplot(aes(x = factor(PC, level = PC), y = var_explained, group = 1)) +
geom_point() +
geom_line() +
geom_text(aes(label = cumm_var_explained), vjust = 1.5) +
labs(x = "Principal Component", y = "Variance Explained (%)", title = "Scree Plot",
subtitle = "Note: cumulative variance explained (%) is displayed as text")
print(screeplot)
R <- pc_cutoff(variance_explained) # automatically calculate number of PCs
print(paste0(R, " PCs were included"))
Expand Down Expand Up @@ -557,7 +562,8 @@ if (correction_variable_3 == "PLEASE FILL IN"){
```

```{r, print p-value table for batch effects after correction of third batch effect variable}
anova_lm_pvalue_df %>% paged_table()
if (correction_variable_3 != "PLEASE FILL IN"){
anova_lm_pvalue_df %>% paged_table()}
```

```{r, conversion M to Beta and save, include=FALSE}
Expand Down

0 comments on commit c5ecf99

Please sign in to comment.