updated un[aired stats with n_obs_complete and removed mediator vitd from sam and npa
This commit is contained in:
parent
1b5d353060
commit
a2dbecd03d
5 changed files with 165 additions and 65 deletions
|
@ -67,8 +67,8 @@ ci = which(is.na(lf_t1$value))
|
|||
lf_t1_comp = lf_t1[-which(is.na(lf_t1$value)),]
|
||||
stats_un_t1 = compare_means(value~obesity
|
||||
, group.by = "mediator"
|
||||
#, data = lf_t1
|
||||
, data = lf_t1_comp
|
||||
, data = lf_t1
|
||||
#, data = lf_t1_comp
|
||||
, paired = FALSE
|
||||
, p.adjust.method = my_adjust_method)
|
||||
|
||||
|
@ -79,10 +79,20 @@ stats_un_t1$timepoint = "t1"
|
|||
stats_un_t1 = as.data.frame(stats_un_t1)
|
||||
class(stats_un_t1)
|
||||
|
||||
# calculate n_obs for each mediator
|
||||
n_t1 = data.frame(table(lf_t1_comp$mediator))
|
||||
colnames(n_t1) = c("mediator", "n_obs")
|
||||
n_t1$mediator = as.character(n_t1$mediator)
|
||||
#----------------------------------------
|
||||
# calculate n_obs for each mediator: t1
|
||||
#----------------------------------------
|
||||
#n_t1 = data.frame(table(lf_t1_comp$mediator))
|
||||
n_t1_all = data.frame(table(lf_t1$mediator))
|
||||
colnames(n_t1_all) = c("mediator", "n_obs")
|
||||
n_t1_all$mediator = as.character(n_t1_all$mediator)
|
||||
|
||||
n_t1_comp = data.frame(table(lf_t1_comp$mediator))
|
||||
colnames(n_t1_comp) = c("mediator", "n_obs_complete")
|
||||
n_t1_comp$mediator = as.character(n_t1_comp$mediator)
|
||||
|
||||
merge_cols = intersect(names(n_t1_all), names(n_t1_comp)); merge_cols
|
||||
n_t1= merge(n_t1_all, n_t1_comp, by = merge_cols, all = T)
|
||||
|
||||
#==================================
|
||||
# Merge: merge stats + n_obs df
|
||||
|
@ -119,8 +129,8 @@ lf_t2_comp = lf_t2[-which(is.na(lf_t2$value)),]
|
|||
|
||||
stats_un_t2 = compare_means(value~obesity
|
||||
, group.by = "mediator"
|
||||
#, data = lf_t2
|
||||
, data = lf_t2_comp
|
||||
, data = lf_t2
|
||||
#, data = lf_t2_comp
|
||||
, paired = FALSE
|
||||
, p.adjust.method = my_adjust_method)
|
||||
# add timepoint and convert to df
|
||||
|
@ -128,10 +138,20 @@ stats_un_t2$timepoint = "t2"
|
|||
stats_un_t2 = as.data.frame(stats_un_t2)
|
||||
class(stats_un_t2)
|
||||
|
||||
# calculate n_obs for each mediator
|
||||
n_t2 = data.frame(table(lf_t2_comp$mediator))
|
||||
colnames(n_t2) = c("mediator", "n_obs")
|
||||
n_t2$mediator = as.character(n_t2$mediator)
|
||||
#----------------------------------------
|
||||
# calculate n_obs for each mediator: t2
|
||||
#----------------------------------------
|
||||
#n_t2 = data.frame(table(lf_t2_comp$mediator))
|
||||
n_t2_all = data.frame(table(lf_t2$mediator))
|
||||
colnames(n_t2_all) = c("mediator", "n_obs")
|
||||
n_t2_all$mediator = as.character(n_t2_all$mediator)
|
||||
|
||||
n_t2_comp = data.frame(table(lf_t2_comp$mediator))
|
||||
colnames(n_t2_comp) = c("mediator", "n_obs_complete")
|
||||
n_t2_comp$mediator = as.character(n_t2_comp$mediator)
|
||||
|
||||
merge_cols = intersect(names(n_t2_all), names(n_t2_comp)); merge_cols
|
||||
n_t2= merge(n_t2_all, n_t2_comp, by = merge_cols, all = T)
|
||||
|
||||
#==================================
|
||||
# Merge: merge stats + n_obs df
|
||||
|
@ -168,8 +188,8 @@ lf_t3_comp = lf_t3[-which(is.na(lf_t3$value)),]
|
|||
|
||||
stats_un_t3 = compare_means(value~obesity
|
||||
, group.by = "mediator"
|
||||
#, data = lf_t3
|
||||
, data = lf_t3_comp
|
||||
, data = lf_t3
|
||||
#, data = lf_t3_comp
|
||||
, paired = FALSE
|
||||
, p.adjust.method = my_adjust_method)
|
||||
|
||||
|
@ -178,11 +198,20 @@ stats_un_t3$timepoint = "t3"
|
|||
stats_un_t3 = as.data.frame(stats_un_t3)
|
||||
class(stats_un_t3)
|
||||
|
||||
#----------------------------------------
|
||||
# calculate n_obs for each mediator: t3
|
||||
#----------------------------------------
|
||||
#n_t3 = data.frame(table(lf_t3_comp$mediator))
|
||||
n_t3_all = data.frame(table(lf_t3$mediator))
|
||||
colnames(n_t3_all) = c("mediator", "n_obs")
|
||||
n_t3_all$mediator = as.character(n_t3_all$mediator)
|
||||
|
||||
# calculate n_obs for each mediator
|
||||
n_t3 = data.frame(table(lf_t3_comp$mediator))
|
||||
colnames(n_t3) = c("mediator", "n_obs")
|
||||
n_t3$mediator = as.character(n_t3$mediator)
|
||||
n_t3_comp = data.frame(table(lf_t3_comp$mediator))
|
||||
colnames(n_t3_comp) = c("mediator", "n_obs_complete")
|
||||
n_t3_comp$mediator = as.character(n_t3_comp$mediator)
|
||||
|
||||
merge_cols = intersect(names(n_t3_all), names(n_t3_comp)); merge_cols
|
||||
n_t3 = merge(n_t3_all, n_t3_comp, by = merge_cols, all = T)
|
||||
|
||||
#==================================
|
||||
# Merge: merge stats + n_obs df
|
||||
|
@ -289,6 +318,7 @@ my_col_order2 = c("mediator"
|
|||
, "timepoint"
|
||||
, "sample_type"
|
||||
, "n_obs"
|
||||
, "n_obs_complete"
|
||||
, "group1"
|
||||
, "group2"
|
||||
, "method"
|
||||
|
@ -318,6 +348,7 @@ colnames(combined_unpaired_stats_f) = c("mediator"
|
|||
, "timepoint"
|
||||
, "sample_type"
|
||||
, "n_obs"
|
||||
, "n_obs_complete"
|
||||
, "group1"
|
||||
, "group2"
|
||||
, "method"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue