Skip to content

Commit

Permalink
modify package description
Browse files Browse the repository at this point in the history
  • Loading branch information
Zheng206 committed Jan 15, 2025
1 parent 4ce73c3 commit 80f522a
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 71 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: ComBatFamQC
Title: Harmonization QC visualization
Version: 0.0.1
Title: Comprehensive Batch Effect Diagnostics and Harmonization
Version: 1.0.0
Authors@R:
person("Zheng", "Ren", , "zren1422@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0009-0006-2430-4625"))
Description: Streamline interactive batch effect diagnostics, harmonization, and post-harmonization downstream analysis to greatly simplify the data harmonization process and improve transparency and reproducibility.
Description: Provides a comprehensive framework for batch effect diagnostics, harmonization, and post-harmonization downstream analysis. Features include interactive visualization tools, robust statistical tests, and a range of harmonization techniques. Additionally, ComBatFamQC enables the creation of life-span age trend plots with estimated age-adjusted centiles and facilitates the generation of covariate-corrected residuals for analytical purposes.
License: MIT + file LICENSE
URL: https://github.com/Zheng206/ComBatFamQC
URL: https://github.com/Zheng206/ComBatFamQC, https://zheng206.github.io/ComBatQC-Web/
BugReports: https://github.com/Zheng206/ComBatFamQC/issues
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
12 changes: 6 additions & 6 deletions R/Harmonization.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#' @param batch The name of the batch variable. Can be skipped if `result` is provided.
#' @param covariates The names of covariates supplied to `model`. This can be be skipped if `result` is provided.
#' @param df Dataset to be harmonized. This can be be skipped if `result` is provided.
#' @param type The name of a regression model to be used in the ComBatFamily package: "lmer", "lm", "gam".
#' @param type The name of a regression model to be used in the ComBatFamily package: `"lmer"`, `"lm"`, `"gam"`.
#' @param random The variable name of a random effect in linear mixed effect model.
#' @param smooth The name of the covariates that require a smooth function.
#' @param interaction Expression of interaction terms supplied to `model` (eg: "age,diagnosis").
#' @param smooth_int_type A vector that indicates the types of interaction in `gam` models. By default, smooth_int_type is set to be NULL, "linear" represents linear interaction terms.
#' "categorical-continuous", "factor-smooth" both represent categorical-continuous interactions ("factor-smooth" includes categorical variable as part of the smooth),
#' "tensor" represents interactions with different scales, and "smooth-smooth" represents interaction between smoothed variables.
#' @param family The type of combat family to use, comfam or covfam.
#' @param interaction Expression of interaction terms supplied to `model` (eg: `"age,diagnosis"`).
#' @param smooth_int_type A vector that indicates the types of interaction in `gam` models. By default, `smooth_int_type` is set to be NULL, `"linear"` represents linear interaction terms.
#' `"categorical-continuous"`, `"factor-smooth"` both represent categorical-continuous interactions (`"factor-smooth"` includes categorical variable as part of the smooth),
#' `"tensor"` represents interactions with different scales, and "smooth-smooth" represents interaction between smoothed variables.
#' @param family The type of combat family to use, `comfam` or `covfam`.
#' @param eb If \code{TRUE}, uses ComBat model with empirical Bayes for mean and variance harmonization
#' @param ref.batch The name of the reference batch.
#' @param predict A boolean variable indicating whether to run ComBat from scratch or apply existing model to new dataset (currently only work for original ComBat and ComBat-GAM).
Expand Down
23 changes: 9 additions & 14 deletions R/age_shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @param age_list A list containing all ROIs' true volumes, age trend estimates, and the fitted GAMLSS model.
#' @param features A vector of roi names.
#' @param quantile_type A vector of quantile types.
#' @param quantile_type A vector of quantile types (e.g., `c("quantile_25", "median", "quantile_75")`)
#' @param use_plotly A boolean variable that indicates whether to display the age plot using the `plotly` package.
#'
#' @importFrom gamlss gamlss gamlss.control predictAll getQuantile ps pb
Expand Down Expand Up @@ -344,7 +344,7 @@ age_list_gen <- function(sub_df, lq = 0.25, hq = 0.75, mu = "smooth", sigma = "s
#' }


customize_percentile <- function(age_list, feature, q, s){
customize_percentile <- function(age_list, feature, q = 0.75, s = "F"){
mdl_sex <- age_list[[feature]]$model
sub_df <- age_list[[feature]]$true_df
min_age <- min(sub_df[["age"]])
Expand Down Expand Up @@ -381,7 +381,7 @@ customize_percentile <- function(age_list, feature, q, s){
#' cus_result_gen(age_list, customized_q = 0.75, f = "Volume_1")
#' }

cus_result_gen <- function(age_list, customized_q, f){
cus_result_gen <- function(age_list, customized_q = 0.75, f){
result <- age_list[[f]]
cus_result <- lapply(c("F", "M"), function(x) customize_percentile(age_list, f, customized_q, x)) |> bind_rows()
cus_result <- rbind(cus_result, result$predicted_df_sex %>% filter(.data[["type"]] == "median"))
Expand Down Expand Up @@ -427,7 +427,7 @@ cus_result_gen <- function(age_list, customized_q, f){
#' )
#' }

age_trend_plot <- function(age_list, f, s, q, cus_list = NULL, use_plotly = TRUE){
age_trend_plot <- function(age_list, f, s = "none", q = "median", cus_list = NULL, use_plotly = TRUE){
result <- age_list[[f]]
pal <- c("coral", "olivedrab")
pal <- setNames(pal, c("F", "M"))
Expand All @@ -442,7 +442,6 @@ age_trend_plot <- function(age_list, f, s, q, cus_list = NULL, use_plotly = TRUE
marker = list(
color = "rgba(70, 130, 150, 0.5)",
size = 6
#line = list(color = "lightblue", width = 0.5)
),
hoverinfo = "text",
text = ~paste("Age: ", round(.data[["age"]], 2), "<br>Volume: ", round(.data[[f]],2)),
Expand All @@ -455,7 +454,6 @@ age_trend_plot <- function(age_list, f, s, q, cus_list = NULL, use_plotly = TRUE
font = list(family = "Arial", size = 12)
)
if(q != "customization"){

if(s == "none"){
base_plot
}else if(s == "F"){
Expand All @@ -481,7 +479,7 @@ age_trend_plot <- function(age_list, f, s, q, cus_list = NULL, use_plotly = TRUE
mode = "lines",
line = list(color = "olivedrab"),
linetype = ~.data[["type"]],
hoverinfo = "text", # Show custom hover text
hoverinfo = "text",
text = ~paste("Age: ", round(.data[["age"]], 2), "<br>Volume: ", round(.data[["prediction"]], 2))
)
}else if(s == "F vs M"){
Expand Down Expand Up @@ -552,7 +550,6 @@ age_trend_plot <- function(age_list, f, s, q, cus_list = NULL, use_plotly = TRUE
axis.text.x = element_text(size = 12, face = "bold"),
axis.text.y = element_text(size = 12, face = "bold"),
)

if(q != "customization"){
if(s == "none"){
base_plot
Expand All @@ -564,7 +561,7 @@ age_trend_plot <- function(age_list, f, s, q, cus_list = NULL, use_plotly = TRUE
base_plot + geom_line(data = result$predicted_df_sex %>% filter(.data[["type"]] == q), mapping = aes(x = .data[["age"]], y = .data[["prediction"]], color = .data[["sex"]])) +
scale_color_manual(
values = c("F" = "coral", "M" = "olivedrab"),
name = "Sex" # Optional: specify the legend title
name = "Sex"
)
}
}else{
Expand Down Expand Up @@ -620,7 +617,7 @@ age_trend_plot <- function(age_list, f, s, q, cus_list = NULL, use_plotly = TRUE
#' @examples
#' \dontrun{
#' # Generate table for females at the 50th percentile
#' age_table_gen(result, q = "quantile_50", s = "F")
#' age_table_gen(result, q = "median", s = "F")
#'
#' # Generate comparison table for females vs. males at the 75th percentile
#' age_table_gen(result, q = "quantile_75", s = "F vs M")
Expand All @@ -629,7 +626,7 @@ age_trend_plot <- function(age_list, f, s, q, cus_list = NULL, use_plotly = TRUE
#' @export


age_table_gen <- function(result, q, s){
age_table_gen <- function(result, q = "median", s = "F"){
if(s == "F"){
if("predicted_df_sex" %in% names(result)){
age_table <- result$predicted_df_sex %>% filter(.data[["type"]] == q, .data[["sex"]] == "F") %>% dplyr::select(all_of(c("age", "prediction"))) %>% rename("Percentile.Volume" = "prediction", "Age" = "age")
Expand Down Expand Up @@ -692,8 +689,6 @@ age_table_gen <- function(result, q, s){
)
}

age_table_dt <- age_table %>% DT::datatable(options = list(dom = 'Bfrtip',
buttons = c('csv', 'excel'), columnDefs = list(list(className = 'dt-center',
targets = "_all"))), extensions = 'Buttons')
age_table_dt <- age_table %>% DT::datatable(options = list(dom = 'Bfrtip', buttons = c('csv', 'excel'), columnDefs = list(list(className = 'dt-center', targets = "_all"))), extensions = 'Buttons')
return(age_table_dt)
}
4 changes: 2 additions & 2 deletions R/comfam_shiny.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Batch Effect Interactive Visualization
#'
#' Provide interactive batch/site effect visualization through Shiny app.
#' Provides an interactive visualization of batch or site effects using a Shiny application.
#'
#' @param result A list derived from `visual_prep()` that contains datasets and statistical test results for Shiny visualization.
#' @param after A boolean variable indicating whether the batch effect diagnostic occurs before or after harmonization. The default value is FALSE.
#' @param after A boolean variable indicating whether the batch effect diagnostic occurs before or after harmonization (default: `FALSE`).
#'
#' @import ggplot2
#' @import shiny
Expand Down
10 changes: 5 additions & 5 deletions R/residual_gen.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#'
#' Extract residuals after harmonization.
#'
#' @param type A model function name that is to be used (eg: "lmer", "lm", "gam").
#' @param type A model function name that is to be used (eg: `"lmer"`, `"lm"`, `"gam"`).
#' @param features The names of the features from which to extract residuals.
#' @param covariates Name of covariates supplied to `model`.
#' @param interaction Expression of interaction terms supplied to `model` (eg: "age,diagnosis").
#' @param interaction Expression of interaction terms supplied to `model` (eg: `"age,diagnosis"`).
#' @param random Variable name of a random effect in linear mixed effect model.
#' @param smooth Variable name that requires a smooth function.
#' @param smooth_int_type Indicates the type of interaction in `gam` models. By default, smooth_int_type is set to be "linear", representing linear interaction terms.
#' "categorical-continuous", "factor-smooth" both represent categorical-continuous interactions ("factor-smooth" includes categorical variable as part of the smooth),
#' "tensor" represents interactions with different scales, and "smooth-smooth" represents interaction between smoothed variables.
#' @param smooth_int_type Indicates the type of interaction in `gam` models. By default, `smooth_int_type` is set to be `"linear"`, representing linear interaction terms.
#' `"categorical-continuous"`, `"factor-smooth"` both represent categorical-continuous interactions (`"factor-smooth"` includes categorical variable as part of the smooth),
#' `"tensor"` represents interactions with different scales, and `"smooth-smooth"` represents interaction between smoothed variables.
#' @param df Harmonized dataset to extract residuals from.
#' @param rm variables to remove effects from.
#' @param model A boolean variable indicating whether an existing model is to be used.
Expand Down
12 changes: 6 additions & 6 deletions R/visual_prep.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
#'
#' Prepare relevant datasets and statistical test results for batch/site effect diagnostic visualization.
#'
#' @param type The name of a regression model to be used in batch effect diagnostics stage: "lmer", "lm", "gam".
#' @param type The name of a regression model to be used in batch effect diagnostics stage: `"lmer"`, `"lm"`, `"gam"`.
#' @param features The name of the features to be evaluated.
#' @param batch The name of the batch variable.
#' @param covariates Name of covariates supplied to `model`.
#' @param interaction Expression of interaction terms supplied to `model` (eg: "age,diagnosis").
#' @param interaction Expression of interaction terms supplied to `model` (eg: `"age,diagnosis"`).
#' @param random Variable name of a random effect in linear mixed effect model.
#' @param smooth Variable name that requires a smooth function.
#' @param smooth_int_type Indicates the type of interaction in `gam` models. By default, smooth_int_type is set to be "linear", representing linear interaction terms.
#' "categorical-continuous", "factor-smooth" both represent categorical-continuous interactions ("factor-smooth" includes categorical variable as part of the smooth),
#' "tensor" represents interactions with different scales, and "smooth-smooth" represents interaction between smoothed variables.
#' @param smooth_int_type Indicates the type of interaction in `gam` models. By default, `smooth_int_type` is set to be `"linear"`, representing linear interaction terms.
#' `"categorical-continuous"`, `"factor-smooth"` both represent categorical-continuous interactions (`"factor-smooth"` includes categorical variable as part of the smooth),
#' `"tensor"` represents interactions with different scales, and `"smooth-smooth"` represents interaction between smoothed variables.
#' @param df Dataset to be evaluated.
#' @param cores number of cores used for parallel computing.
#' @param mdmr A boolean variable indicating whether to run the MDMR test. By default, it is set to TRUE.
#' @param mdmr A boolean variable indicating whether to run the MDMR test (default: `TRUE`).
#'
#' @return `visual_prep` returns a list containing the following components:
#' \item{residual_add_df}{Residuals that might contain additive and multiplicative joint batch effects}
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ The ComBatFamQC package offers the following five key functionalities:
- ComBat-GAM (Pomponio et al., 2020)
- CovBat (Chen et al., 2021)

![ComBatQC Shiny](/inst/figure/combat_shiny.png)

- **Interactive Visualization through R Shiny**: The ComBatFamQC package comes with an interactive visualization tool built on R Shiny, providing an intuitive user interface to explore and evaluate batch effects, as well as conduct interactive harmonization if needed. The output is organized into multiple tabs, which includes:

- **Data Overview**: Complete data overview and exploratory analysis
Expand All @@ -59,8 +57,6 @@ The ComBatFamQC package offers the following five key functionalities:
- **Age Trend Plots**
- **Age Trend Table**

![Age Shiny](/inst/figure/age_shiny.png)

- **Residual Generation** \
Generate residual data set, removing specific covariates' effetcs.

Expand Down
12 changes: 7 additions & 5 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "ComBatFamQC",
"description": "Streamline interactive batch effect diagnostics, harmonization, and post-harmonization downstream analysis to greatly simplify the data harmonization process and improve transparency and reproducibility. ",
"name": "ComBatFamQC: Harmonization QC visualization",
"description": "Provides a comprehensive framework for batch effect diagnostics, harmonization, and post-harmonization downstream analysis. Features include interactive visualization tools, robust statistical tests, and a range of harmonization techniques. Additionally, ComBatFamQC enables the creation of life-span age trend plots with estimated age-adjusted centiles and facilitates the generation of covariate-corrected residuals for analytical purposes.",
"name": "ComBatFamQC: Comprehensive Batch Effect Diagnostics and Harmonization",
"relatedLink": "https://zheng206.github.io/ComBatQC-Web/",
"codeRepository": "https://github.com/Zheng206/ComBatFamQC",
"issueTracker": "https://github.com/Zheng206/ComBatFamQC/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.0.1",
"version": "1.0.0",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -393,6 +394,7 @@
},
"SystemRequirements": null
},
"fileSize": "4932.818KB",
"readme": "https://github.com/Zheng206/ComBatFamQC/blob/main/README.md"
"fileSize": "4934.773KB",
"readme": "https://github.com/Zheng206/ComBatFamQC/blob/main/README.md",
"contIntegration": ["https://github.com/Zheng206/ComBatFamQC/actions/workflows/R-CMD-check.yaml", "https://app.codecov.io/gh/Zheng206/ComBatFamQC"]
}
Binary file removed inst/figure/age_shiny.png
Binary file not shown.
Binary file removed inst/figure/combat_shiny.png
Binary file not shown.
2 changes: 1 addition & 1 deletion man/age_shiny.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/age_table_gen.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion man/age_trend_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/combat_harm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80f522a

Please sign in to comment.