added quick summary to see sig meds just before writing file

This commit is contained in:
Tanushree Tunstall 2020-11-20 12:36:55 +00:00
parent 17aebc26e8
commit 1562a09631
8 changed files with 63 additions and 29 deletions

View file

@ -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)
@ -129,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
@ -188,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)
@ -361,9 +361,23 @@ colnames(combined_unpaired_stats_f) = c("mediator"
, "p_bon_signif")
colnames(combined_unpaired_stats_f)
#---------------
# quick summary
#---------------
# count how many meds are significant
n_sig = length(combined_unpaired_stats_f$mediator[combined_unpaired_stats_f$p_signif<0.05 & !is.na(combined_unpaired_stats_f$p_signif<0.05)])
sig_meds = combined_unpaired_stats_f[(combined_unpaired_stats_f$p_signif<0.05 & !is.na(combined_unpaired_stats_f$p_signif<0.05)),]
sig_meds$med_time = paste0(sig_meds$mediator, "@", sig_meds$timepoint)
cat("\nTotal no. of statistically significant mediators in", toupper(my_sample_type)
, "are:", n_sig
, "\nThese are:", sig_meds$med_time)
########################################################################
#******************
# write output file
#******************
cat("UNpaired stats for groups will be:", flu_stats_time_unpaired)
write.csv(combined_unpaired_stats_f, flu_stats_time_unpaired, row.names = FALSE)
#write.csv(combined_unpaired_stats_f, flu_stats_time_unpaired, row.names = FALSE)