-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ricoderks/dev
Dev
- Loading branch information
Showing
15 changed files
with
508 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: lipidomics | ||
Type: Package | ||
Title: Lipidomics workflow | ||
Version: 0.5 | ||
Version: 0.6.0 | ||
Author: Rico Derks | ||
Maintainer: Rico Derks <[email protected]> | ||
Description: Lipidomics workflow to proces the result files (export alignment) | ||
|
@@ -10,6 +10,7 @@ License: GPL (>= 3) | |
Encoding: UTF-8 | ||
LazyData: true | ||
Imports: | ||
broom, | ||
dplyr, | ||
DT, | ||
ggCPM, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#' @title Create box plot | ||
#' | ||
#' @description Create box plot. | ||
#' | ||
#' @param lipid_data tibble with all the lipid data and test data | ||
#' @param title title of the plot | ||
#' | ||
#' @return plotly object | ||
#' | ||
#' @importFrom magrittr %>% | ||
#' @importFrom dplyr filter select | ||
#' @importFrom tidyr unnest | ||
#' @importFrom rlang .data | ||
#' @importFrom plotly plot_ly layout hide_legend | ||
#' | ||
#' @author Rico Derks | ||
#' | ||
box_plot <- function(lipid_data, title = "") { | ||
# create the plot | ||
p <- lipid_data %>% | ||
plot_ly(x = ~my_group_info, | ||
y = ~value, | ||
text = ~sample_name, | ||
color = ~my_group_info, | ||
type = "box", | ||
boxpoints = "all", | ||
jitter = 0.4, | ||
pointpos = 0) %>% | ||
layout(title = list(text = title, | ||
x = 0), | ||
yaxis = list(title = "Value", | ||
exponentformat = "E"), | ||
xaxis = list(title = "Group")) %>% | ||
hide_legend() | ||
|
||
return(p) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#' @title Do a Mann-Whitney U test on all lipids | ||
#' | ||
#' @description Do a Mann-Whitney U test on all lipids | ||
#' | ||
#' @param lipid_data tibble in tidy format, already nested | ||
#' | ||
#' @details A Mann-Whitney U test will be done for each lipid. Also the p-value will be corrected | ||
#' for multiple testing. | ||
#' | ||
#' @return a tibble with the results and the following columns | ||
#' model_test contains the model information for each lipid (nested) | ||
#' pvalue contains the uncorrected pvalue | ||
#' pvalue_cor contains the corrected pvalue | ||
#' fc the fold change estimate1/estimate2 | ||
#' | ||
#' @import tidyselect | ||
#' @importFrom dplyr mutate group_by summarise pull | ||
#' @importFrom tidyr pivot_wider | ||
#' @importFrom magrittr %>% | ||
#' @importFrom rlang .data | ||
#' @importFrom purrr map map_dbl | ||
#' @importFrom broom tidy | ||
#' @importFrom stats p.adjust | ||
#' | ||
#' @author Rico Derks | ||
#' | ||
do_mwtest <- function(lipid_data) { | ||
results <- lipid_data %>% | ||
mutate(model_test = map(.x = .data$test_data, | ||
.f = ~ broom::tidy(wilcox.test(formula = value ~ my_group_info, | ||
data = .x))), | ||
pvalue = map_dbl(.x = .data$model_test, | ||
.f = ~ .x$p.value), | ||
pvalue_adj = p.adjust(.data$pvalue, | ||
method = "BH"), | ||
p_log10 = -log10(.data$pvalue), | ||
p_log10_adj = -log10(.data$pvalue_adj)) | ||
|
||
return(results) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#' @title Do a t-test on all lipids | ||
#' | ||
#' @description Do a t-test on all lipids. | ||
#' | ||
#' @param lipid_data tibble in tidy format, already nested | ||
#' | ||
#' @details A t-test will be done for each lipid. Also the p-value will be corrected | ||
#' for multiple testing. | ||
#' | ||
#' @return a tibble with the results and the following columns | ||
#' model_test contains the model information for each lipid (nested) | ||
#' pvalue contains the uncorrected pvalue | ||
#' pvalue_cor contains the corrected pvalue | ||
#' fc the fold change estimate1/estimate2 | ||
#' | ||
#' @import tidyselect | ||
#' @importFrom dplyr mutate | ||
#' @importFrom magrittr %>% | ||
#' @importFrom rlang .data | ||
#' @importFrom purrr map map_dbl | ||
#' @importFrom broom tidy | ||
#' @importFrom stats p.adjust | ||
#' | ||
#' @author Rico Derks | ||
#' | ||
do_ttest <- function(lipid_data) { | ||
results <- lipid_data %>% | ||
mutate(model_test = map(.x = .data$test_data, | ||
.f = ~ broom::tidy(t.test(formula = value ~ my_group_info, | ||
data = .x)) %>% | ||
# calculate the fold change | ||
mutate(fc = estimate1 / estimate2)), | ||
pvalue = map_dbl(.x = .data$model_test, | ||
.f = ~ .x$p.value), | ||
pvalue_adj = p.adjust(.data$pvalue, | ||
method = "BH"), | ||
p_log10 = -log10(.data$pvalue), | ||
p_log10_adj = -log10(.data$pvalue_adj)) | ||
|
||
return(results) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.