Skip to content

Commit

Permalink
Correct name of source script and print batch effect tables in separa…
Browse files Browse the repository at this point in the history
…te chunks
  • Loading branch information
Vera N. Karlbauer committed Mar 7, 2025
1 parent 5402c78 commit 7090e55
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions scripts/9_correction_batch_effects_filtered.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ start_time <- Sys.time()
```

```{r setup, include=FALSE}
source("../data/calculate_pc_cutoff.R") # source function for determining PC cutoff
source("../data/Calculate_PC_Cutoff.R") # source function for determining PC cutoff
needed_packages <- c("BiocManager", "dplyr", "knitr", "rmarkdown", "tibble", "ggplot2",
"ggrepel", "broom", "gplots", "tidyr", "sva", "methods")
user_choices <- readRDS("../data/user_choices.rds")
Expand Down Expand Up @@ -79,7 +79,7 @@ phenotype_data <- readRDS(paste0(user_choices$project_name, "/processed_data/phe

## Correction of technical batch effects with ComBat

```{r, correction of first batch effect and PCA}
```{r, correction of first batch effect and PCA, results='asis'}
m_values <- apply(Betas_clean_filtered_quantile_bmiq, 2, function(x) log2((x)/(1-x))) # get M-values
if (correction_variable_1 == "PLEASE FILL IN"){
Expand Down Expand Up @@ -240,7 +240,11 @@ if (correction_variable_1 == "PLEASE FILL IN"){
}
```

```{r, correction of second batch effect and PCA}
```{r, print p-value table for batch effects after correction of first batch effect variable}
anova_lm_pvalue_df %>% paged_table()
```

```{r, correction of second batch effect and PCA, results='asis'}
if (correction_variable_2 == "PLEASE FILL IN"){
print("No second batch correction variable was specified by user, data remains unchanged")
} else {
Expand Down Expand Up @@ -399,6 +403,10 @@ 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()
```

```{r, correction of third batch effect and PCA}
if (correction_variable_3 == "PLEASE FILL IN"){
print("No third batch correction variable was specified by user, data remains unchanged")
Expand Down Expand Up @@ -557,6 +565,10 @@ 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()
```

```{r, convertion M to Beta and save, include=FALSE}
if(exists("m_values_combat_3")){
corrected_data <- m_values_combat_3
Expand Down

0 comments on commit 7090e55

Please sign in to comment.