Skip to content

Commit

Permalink
Fix minor plot printing issues
Browse files Browse the repository at this point in the history
Vera N. Karlbauer committed Jun 5, 2025
1 parent 44f4b8a commit 0d094a7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scripts/9_correction_batch_effects_filtered.Rmd
Original file line number Diff line number Diff line change
@@ -97,14 +97,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"))
@@ -241,7 +242,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'}
@@ -260,14 +262,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(screeplot)
R <- pc_cutoff(variance_explained) # automatically calculate number of PCs
print(paste0(R, " PCs were included"))
@@ -404,7 +407,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}
@@ -423,14 +427,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"))
@@ -566,7 +571,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, convertion M to Beta and save, include=FALSE}

0 comments on commit 0d094a7

Please sign in to comment.