added function for stats from lf data
This commit is contained in:
parent
eb19efd287
commit
14d1ec84ab
4 changed files with 137 additions and 50 deletions
21
scripts/functions/lf_unpaired_stats.R
Normal file
21
scripts/functions/lf_unpaired_stats.R
Normal file
|
@ -0,0 +1,21 @@
|
|||
library(ggpubr)
|
||||
###################################################################
|
||||
|
||||
lf_unpaired_stats <- function(lf_data
|
||||
, lf_stat_value = "param_value"
|
||||
, lf_stat_group = "mutation_info"
|
||||
, lf_col_statvars = "param_type"
|
||||
, my_paired = FALSE
|
||||
, stat_adj = "none"){
|
||||
|
||||
stat_formula = as.formula(paste0(lf_stat_value, "~", lf_stat_group))
|
||||
|
||||
my_stat_df = compare_means(stat_formula
|
||||
, group.by = lf_col_statvars
|
||||
, data = lf_data
|
||||
, paired = my_paired
|
||||
, p.adjust.method = stat_adj)
|
||||
|
||||
|
||||
return(my_stat_df)
|
||||
}
|
|
@ -1,8 +1,49 @@
|
|||
my_stat_ps = compare_means(param_value~mutation_info, group.by = "param_type"
|
||||
, data = df_lf_ps, paired = FALSE, p.adjust.method = "BH")
|
||||
library(ggpubr)
|
||||
###################################################################
|
||||
|
||||
my_unpaired_stats <- function(lf_data
|
||||
, lf_stat_value = "param_value"
|
||||
, lf_stat_group = "mutation_info"
|
||||
, lf_col_statvars = "param_type"
|
||||
, my_paired = FALSE
|
||||
, stat_adj = "none"){
|
||||
|
||||
stat_formula = as.formula(paste0(lf_stat_value, "~", lf_stat_group))
|
||||
|
||||
my_stat_df = compare_means(stat_formula
|
||||
, group.by = lf_col_statvars
|
||||
, data = lf_data
|
||||
, paired = my_paired
|
||||
, p.adjust.method = stat_adj)
|
||||
|
||||
|
||||
return(my_stat_df)
|
||||
}
|
||||
|
||||
#####################
|
||||
# call stat function
|
||||
#####################
|
||||
stat_results_df <- my_unpaired_stats(lf_data = lf_duet
|
||||
, lf_stat_value = "param_value"
|
||||
, lf_stat_group = "mutation_info"
|
||||
, lf_col_statvars = "param_type"
|
||||
, my_paired = FALSE
|
||||
, stat_adj = "none"
|
||||
)
|
||||
|
||||
y_value = "param_value"
|
||||
|
||||
#################################
|
||||
my_comparisons <- list( c("DM", "OM") )
|
||||
|
||||
my_ats = 22 # axis text size
|
||||
my_als = 20 # axis label size
|
||||
my_fls = 20 # facet label size
|
||||
my_pts = 22 # plot title size
|
||||
|
||||
####################################
|
||||
|
||||
|
||||
stat_bp_mut <- function(df
|
||||
, x_bp_cateog = "mutation_info"
|
||||
, y_var = "param_value"
|
||||
|
@ -16,7 +57,12 @@ stat_bp_mut <- function(df
|
|||
#, stat_label = "p.format")
|
||||
, stat_label = "p.signif" )
|
||||
|
||||
p1 = ggplot(df_lf_ps, aes(x = mutation_info
|
||||
|
||||
#############################
|
||||
y_value = "param_value"
|
||||
|
||||
|
||||
p1 = ggplot(lf_duet, aes(x = mutation_info
|
||||
, y = eval(parse(text = y_value)) )) +
|
||||
facet_wrap(~ param_type
|
||||
, nrow = 1
|
||||
|
@ -48,4 +94,7 @@ p1 = ggplot(df_lf_ps, aes(x = mutation_info
|
|||
, method = "wilcox.test"
|
||||
, paired = FALSE
|
||||
#, label = "p.format")
|
||||
, label = "p.signif")
|
||||
, label = "p.signif")
|
||||
|
||||
p1
|
||||
|
||||
|
|
17
scripts/functions/test_lf_unpaired_stats.R
Normal file
17
scripts/functions/test_lf_unpaired_stats.R
Normal file
|
@ -0,0 +1,17 @@
|
|||
setwd("~/git/LSHTM_analysis/scripts/functions")
|
||||
source("lf_unpaired_stats.R")
|
||||
|
||||
# run other_plots_data.R
|
||||
# to get the df you want to test this function
|
||||
|
||||
|
||||
#####################
|
||||
# call stat function
|
||||
#####################
|
||||
stat_results_df <- lf_unpaired_stats(lf_data = lf_duet
|
||||
, lf_stat_value = "param_value"
|
||||
, lf_stat_group = "mutation_info"
|
||||
, lf_col_statvars = "param_type"
|
||||
, my_paired = FALSE
|
||||
, stat_adj = "none"
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue