adde asthma and severity analysis dir
This commit is contained in:
parent
3338de800a
commit
74c4dd878c
6 changed files with 749 additions and 0 deletions
139
asthma/boxplot_stat_linear.R
Executable file
139
asthma/boxplot_stat_linear.R
Executable file
|
@ -0,0 +1,139 @@
|
||||||
|
#!/usr/bin/Rscript
|
||||||
|
getwd()
|
||||||
|
setwd("~/git/mosaic_2020/")
|
||||||
|
getwd()
|
||||||
|
###############################################################
|
||||||
|
# TASK: boxplots with stats for NPA, SAM and SERUM
|
||||||
|
# for each mediator, at each timepoint by group
|
||||||
|
|
||||||
|
# TODO: check boxplot_stat_function.R
|
||||||
|
# output plots even if stats fail due to data containing only LLODs
|
||||||
|
# however for a given mediator, if there is error for ANY timepoint
|
||||||
|
# stats will not be added for the entire plot! To be handled in
|
||||||
|
# next iteration!
|
||||||
|
###############################################################
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Input
|
||||||
|
#=============
|
||||||
|
source("boxplot_stat_function.R")
|
||||||
|
source("plot_data_a.R")
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Output
|
||||||
|
#=============
|
||||||
|
outfile_bp = paste0("boxplots_stats_all_A-%03d.svg")
|
||||||
|
output_boxplot_stats = paste0(outdir_plots, outfile_bp); output_boxplot_stats
|
||||||
|
svg(output_boxplot_stats, width=22, height=16)
|
||||||
|
###############################################################
|
||||||
|
#===============================
|
||||||
|
# data assignment for plots
|
||||||
|
#===============================
|
||||||
|
table(lf_fp_npa$mediator)
|
||||||
|
table(lf_fp_npa$T1_resp_score, lf_fp_npa$timepoint, lf_fp_npa$mediator == "eotaxin")
|
||||||
|
|
||||||
|
#-------------
|
||||||
|
# NPA
|
||||||
|
#-------------
|
||||||
|
title_npa = "NPA (asthma)"
|
||||||
|
fp_npa = length(unique(lf_fp_npa$mosaic)); fp_npa
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_npa
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_npa = doMyPlotsStats(lf_fp_npa)
|
||||||
|
npa_plot = ggpubr::ggarrange(plotlist = plots_npa
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#npa_plot
|
||||||
|
npa_plot_annot = annotate_figure(npa_plot
|
||||||
|
, top = text_grob(title_npa
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP asthma adults (n=", fp_npa, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
npa_plot_annot
|
||||||
|
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
|
||||||
|
#-------------
|
||||||
|
# SAM: NO STATS
|
||||||
|
# FIXME: error handling!
|
||||||
|
# For now, just calling plotting function without stats
|
||||||
|
#-------------
|
||||||
|
title_sam = "SAM (asthma)"
|
||||||
|
fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_sam
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
#plots_sam = doMyPlots(lf_fp_sam)
|
||||||
|
plots_sam = doMyPlotsStats(lf_fp_sam)
|
||||||
|
sam_plot = ggpubr::ggarrange(plotlist = plots_sam
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#sam_plot
|
||||||
|
sam_plot_annot = annotate_figure(sam_plot
|
||||||
|
, top = text_grob(title_sam
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP asthma adults (n=", fp_sam, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
sam_plot_annot
|
||||||
|
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
|
||||||
|
#-------------
|
||||||
|
# SERUM
|
||||||
|
#-------------
|
||||||
|
title_serum = "SERUM (asthma)"
|
||||||
|
fp_serum = length(unique(lf_fp_serum$mosaic)); fp_serum
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_serum
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_serum = doMyPlotsStats(lf_fp_serum)
|
||||||
|
serum_plot = ggpubr::ggarrange(plotlist = plots_serum
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#serum_plot
|
||||||
|
serum_plot_annot = annotate_figure(serum_plot
|
||||||
|
, top = text_grob(title_serum
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP asthma adults (n=", fp_serum, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
serum_plot_annot
|
||||||
|
dev.off()
|
||||||
|
###############################################################
|
||||||
|
# END OF SCRIPT #
|
||||||
|
###############################################################
|
177
asthma/boxplot_stat_log.R
Executable file
177
asthma/boxplot_stat_log.R
Executable file
|
@ -0,0 +1,177 @@
|
||||||
|
#!/usr/bin/Rscript
|
||||||
|
getwd()
|
||||||
|
setwd("~/git/mosaic_2020/")
|
||||||
|
getwd()
|
||||||
|
###############################################################
|
||||||
|
# TASK: boxplots with stats for NPA, SAM and SERUM but with log scale
|
||||||
|
# for each mediator, at each timepoint, by group
|
||||||
|
|
||||||
|
# TODO: check boxplot_stat_function.R
|
||||||
|
# output plots even if stats fail due to data containing only LLODs
|
||||||
|
# however for a given mediator, if there is error for ANY timepoint
|
||||||
|
# stats will not be added for the entire plot! To be handled in
|
||||||
|
# next iteration!
|
||||||
|
###############################################################
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Input
|
||||||
|
#=============
|
||||||
|
source("boxplot_stat_function.R")
|
||||||
|
source("plot_data_a.R")
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Output
|
||||||
|
#=============
|
||||||
|
outfile_bp = paste0("boxplots_stats_all_A_LOG-%03d.svg")
|
||||||
|
output_boxplot_stats = paste0(outdir_plots, outfile_bp); output_boxplot_stats
|
||||||
|
svg(output_boxplot_stats, width=22, height=16)
|
||||||
|
###############################################################
|
||||||
|
#===============================
|
||||||
|
# data assignment for plots
|
||||||
|
#===============================
|
||||||
|
#----------------------------------------
|
||||||
|
#-------
|
||||||
|
# NPA
|
||||||
|
#-------
|
||||||
|
# vl data juggling with 0!
|
||||||
|
vl_temp_fix = lf_fp_npa[lf_fp_npa$mediator=="vl_pfu_ul",]
|
||||||
|
vl_temp_fix$value[1:20]
|
||||||
|
vl_temp_fix$value[vl_temp_fix$value == 0] <- 1
|
||||||
|
vl_temp_fix$value[1:20]
|
||||||
|
|
||||||
|
orig_nrow = nrow(lf_fp_npa); orig_nrow; table(lf_fp_npa$mediator)
|
||||||
|
lf_fp_npa = lf_fp_npa[!lf_fp_npa$mediator=="vl_pfu_ul",]
|
||||||
|
temp_nrow = nrow(lf_fp_npa); temp_nrow; table(lf_fp_npa$mediator)
|
||||||
|
|
||||||
|
# add vl_temp_fix back
|
||||||
|
lf_fp_npa = rbind(lf_fp_npa, vl_temp_fix)
|
||||||
|
revised_nrow = nrow(lf_fp_npa); revised_nrow
|
||||||
|
|
||||||
|
orig_nrow == revised_nrow
|
||||||
|
|
||||||
|
head(lf_fp_npa$value)
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
# log all values and reassign
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
lf_fp_npa$value = log10(lf_fp_npa$value)
|
||||||
|
head(lf_fp_npa$value)
|
||||||
|
vl_temp_fix2 = lf_fp_npa[lf_fp_npa$mediator=="vl_pfu_ul",]
|
||||||
|
vl_temp_fix2$value[1:20]
|
||||||
|
|
||||||
|
#------------------------------------------
|
||||||
|
title_npa = "NPA (asthma)"
|
||||||
|
fp_npa = length(unique(lf_fp_npa$mosaic)); fp_npa
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_npa
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_npa = doMyPlotsStats(lf_fp_npa)
|
||||||
|
npa_plot = ggpubr::ggarrange(plotlist = plots_npa
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#npa_plot
|
||||||
|
npa_plot_annot = annotate_figure(npa_plot
|
||||||
|
, top = text_grob(title_npa
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP asthma adults (n=", fp_npa, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
npa_plot_annot
|
||||||
|
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
|
||||||
|
#-------------
|
||||||
|
# SAM
|
||||||
|
#-------------
|
||||||
|
head(lf_fp_sam$value)
|
||||||
|
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
# log all values and reassign
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
lf_fp_sam$value = log10(lf_fp_sam$value)
|
||||||
|
head(lf_fp_sam$value)
|
||||||
|
|
||||||
|
title_sam = "SAM (asthma)"
|
||||||
|
fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_sam
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_sam = doMyPlotsStats(lf_fp_sam)
|
||||||
|
sam_plot = ggpubr::ggarrange(plotlist = plots_sam
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#sam_plot
|
||||||
|
sam_plot_annot = annotate_figure(sam_plot
|
||||||
|
, top = text_grob(title_sam
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP asthma adults (n=", fp_sam, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
sam_plot_annot
|
||||||
|
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
|
||||||
|
#------------------------------------------
|
||||||
|
#-------------
|
||||||
|
# SERUM
|
||||||
|
#-------------
|
||||||
|
head(lf_fp_serum$value)
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
# log all values and reassign
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
lf_fp_serum$value = log10(lf_fp_serum$value)
|
||||||
|
head(lf_fp_serum$value)
|
||||||
|
|
||||||
|
title_serum = "SERUM (asthma)"
|
||||||
|
fp_serum = length(unique(lf_fp_serum$mosaic)); fp_serum
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_serum
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_serum = doMyPlotsStats(lf_fp_serum)
|
||||||
|
serum_plot = ggpubr::ggarrange(plotlist = plots_serum
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#serum_plot
|
||||||
|
serum_plot_annot = annotate_figure(serum_plot
|
||||||
|
, top = text_grob(title_serum
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP asthma adults (n=", fp_serum, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
serum_plot_annot
|
||||||
|
dev.off()
|
||||||
|
###############################################################
|
||||||
|
# END OF SCRIPT #
|
||||||
|
###############################################################
|
||||||
|
|
59
plot_data_a.R
Executable file
59
plot_data_a.R
Executable file
|
@ -0,0 +1,59 @@
|
||||||
|
#!/usr/bin/Rscript
|
||||||
|
getwd()
|
||||||
|
setwd("~/git/mosaic_2020/")
|
||||||
|
getwd()
|
||||||
|
############################################################
|
||||||
|
# TASK: boxplots at T1
|
||||||
|
# FIXME: currently not rendering, problem with NAs for stats?
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Input
|
||||||
|
#=============
|
||||||
|
#source("data_extraction_formatting_non_asthmatics.R")
|
||||||
|
source("data_extraction_mediators.R")
|
||||||
|
|
||||||
|
#===============================
|
||||||
|
# data assignment for plots
|
||||||
|
#================================
|
||||||
|
#-----------
|
||||||
|
# npa
|
||||||
|
#-----------
|
||||||
|
wf_fp_npa = npa_wf[npa_wf$asthma == 1,]
|
||||||
|
lf_fp_npa = npa_lf[npa_lf$asthma == 1,]
|
||||||
|
lf_fp_npa$timepoint = paste0("t", lf_fp_npa$timepoint)
|
||||||
|
lf_fp_npa$timepoint = as.factor(lf_fp_npa$timepoint)
|
||||||
|
lf_fp_npa$obesity = as.factor(lf_fp_npa$obesity)
|
||||||
|
|
||||||
|
table(lf_fp_npa$mediator)
|
||||||
|
head(lf_fp_npa$value[lf_fp_npa$mediator == "vitd"])
|
||||||
|
lf_fp_npa = lf_fp_npa[!lf_fp_npa$mediator == "vitd",]
|
||||||
|
table(lf_fp_npa$mediator)
|
||||||
|
|
||||||
|
#-----------
|
||||||
|
# sam
|
||||||
|
#-----------
|
||||||
|
wf_fp_sam = sam_wf[sam_wf$asthma == 1,]
|
||||||
|
lf_fp_sam = sam_lf[sam_lf$asthma == 1,]
|
||||||
|
lf_fp_sam$timepoint = paste0("t", lf_fp_sam$timepoint)
|
||||||
|
lf_fp_sam$timepoint = as.factor(lf_fp_sam$timepoint)
|
||||||
|
lf_fp_sam$obesity = as.factor(lf_fp_sam$obesity)
|
||||||
|
|
||||||
|
table(lf_fp_sam$mediator)
|
||||||
|
head(lf_fp_sam$value[lf_fp_sam$mediator == "vitd"])
|
||||||
|
lf_fp_sam = lf_fp_sam[!lf_fp_sam$mediator == "vitd",]
|
||||||
|
table(lf_fp_sam$mediator)
|
||||||
|
|
||||||
|
#-----------
|
||||||
|
# serum
|
||||||
|
#-----------
|
||||||
|
wf_fp_serum = serum_wf[serum_wf$asthma == 1,]
|
||||||
|
lf_fp_serum = serum_lf[serum_lf$asthma == 1,]
|
||||||
|
lf_fp_serum$timepoint = paste0("t", lf_fp_serum$timepoint)
|
||||||
|
lf_fp_serum$timepoint = as.factor(lf_fp_serum$timepoint)
|
||||||
|
lf_fp_serum$obesity = as.factor(lf_fp_serum$obesity)
|
||||||
|
|
||||||
|
head(lf_fp_sam$value[lf_fp_serum$mediator == "vitd"])
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
rm(npa_lf, npa_wf, sam_lf, sam_wf, serum_lf, serum_wf)
|
58
plot_data_s.R
Normal file
58
plot_data_s.R
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#!/usr/bin/Rscript
|
||||||
|
getwd()
|
||||||
|
setwd("~/git/mosaic_2020/")
|
||||||
|
getwd()
|
||||||
|
############################################################
|
||||||
|
# TASK: boxplots at T1
|
||||||
|
# FIXME: currently not rendering, problem with NAs for stats?
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Input
|
||||||
|
#=============
|
||||||
|
source("data_extraction_mediators.R")
|
||||||
|
|
||||||
|
#===============================
|
||||||
|
# data assignment for plots
|
||||||
|
#================================
|
||||||
|
#-----------
|
||||||
|
# npa
|
||||||
|
#-----------
|
||||||
|
wf_fp_npa = npa_wf[npa_wf$T1_resp_score == 3,]
|
||||||
|
lf_fp_npa = npa_lf[npa_lf$T1_resp_score == 3,]
|
||||||
|
lf_fp_npa$timepoint = paste0("t", lf_fp_npa$timepoint)
|
||||||
|
lf_fp_npa$timepoint = as.factor(lf_fp_npa$timepoint)
|
||||||
|
lf_fp_npa$obesity = as.factor(lf_fp_npa$obesity)
|
||||||
|
|
||||||
|
table(lf_fp_npa$mediator)
|
||||||
|
head(lf_fp_npa$value[lf_fp_npa$mediator == "vitd"])
|
||||||
|
lf_fp_npa = lf_fp_npa[!lf_fp_npa$mediator == "vitd",]
|
||||||
|
table(lf_fp_npa$mediator)
|
||||||
|
|
||||||
|
#-----------
|
||||||
|
# sam
|
||||||
|
#-----------
|
||||||
|
wf_fp_sam = sam_wf[sam_wf$T1_resp_score == 3,]
|
||||||
|
lf_fp_sam = sam_lf[sam_lf$T1_resp_score == 3,]
|
||||||
|
lf_fp_sam$timepoint = paste0("t", lf_fp_sam$timepoint)
|
||||||
|
lf_fp_sam$timepoint = as.factor(lf_fp_sam$timepoint)
|
||||||
|
lf_fp_sam$obesity = as.factor(lf_fp_sam$obesity)
|
||||||
|
|
||||||
|
table(lf_fp_sam$mediator)
|
||||||
|
head(lf_fp_sam$value[lf_fp_sam$mediator == "vitd"])
|
||||||
|
lf_fp_sam = lf_fp_sam[!lf_fp_sam$mediator == "vitd",]
|
||||||
|
table(lf_fp_sam$mediator)
|
||||||
|
|
||||||
|
#-----------
|
||||||
|
# serum
|
||||||
|
#-----------
|
||||||
|
wf_fp_serum = serum_wf[serum_wf$T1_resp_score == 3,]
|
||||||
|
lf_fp_serum = serum_lf[serum_lf$T1_resp_score == 3,]
|
||||||
|
lf_fp_serum$timepoint = paste0("t", lf_fp_serum$timepoint)
|
||||||
|
lf_fp_serum$timepoint = as.factor(lf_fp_serum$timepoint)
|
||||||
|
lf_fp_serum$obesity = as.factor(lf_fp_serum$obesity)
|
||||||
|
|
||||||
|
head(lf_fp_sam$value[lf_fp_serum$mediator == "vitd"])
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
rm(npa_lf, npa_wf, sam_lf, sam_wf, serum_lf, serum_wf, fp_adults_ics)
|
139
severe/boxplot_stat_linear.R
Executable file
139
severe/boxplot_stat_linear.R
Executable file
|
@ -0,0 +1,139 @@
|
||||||
|
#!/usr/bin/Rscript
|
||||||
|
getwd()
|
||||||
|
setwd("~/git/mosaic_2020/")
|
||||||
|
getwd()
|
||||||
|
###############################################################
|
||||||
|
# TASK: boxplots with stats for NPA, SAM and SERUM
|
||||||
|
# for each mediator, at each timepoint by group
|
||||||
|
|
||||||
|
# TODO: check boxplot_stat_function.R
|
||||||
|
# output plots even if stats fail due to data containing only LLODs
|
||||||
|
# however for a given mediator, if there is error for ANY timepoint
|
||||||
|
# stats will not be added for the entire plot! To be handled in
|
||||||
|
# next iteration!
|
||||||
|
###############################################################
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Input
|
||||||
|
#=============
|
||||||
|
source("boxplot_stat_function.R")
|
||||||
|
source("plot_data_s.R")
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Output
|
||||||
|
#=============
|
||||||
|
outfile_bp = paste0("boxplots_stats_all_Sev-%03d.svg")
|
||||||
|
output_boxplot_stats = paste0(outdir_plots, outfile_bp); output_boxplot_stats
|
||||||
|
svg(output_boxplot_stats, width=22, height=16)
|
||||||
|
###############################################################
|
||||||
|
#===============================
|
||||||
|
# data assignment for plots
|
||||||
|
#===============================
|
||||||
|
table(lf_fp_npa$mediator)
|
||||||
|
table(lf_fp_npa$T1_resp_score, lf_fp_npa$timepoint, lf_fp_npa$mediator == "eotaxin")
|
||||||
|
|
||||||
|
#-------------
|
||||||
|
# NPA
|
||||||
|
#-------------
|
||||||
|
title_npa = "NPA (severe)"
|
||||||
|
fp_npa = length(unique(lf_fp_npa$mosaic)); fp_npa
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_npa
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_npa = doMyPlotsStats(lf_fp_npa)
|
||||||
|
npa_plot = ggpubr::ggarrange(plotlist = plots_npa
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#npa_plot
|
||||||
|
npa_plot_annot = annotate_figure(npa_plot
|
||||||
|
, top = text_grob(title_npa
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP severe adults (n=", fp_npa, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
npa_plot_annot
|
||||||
|
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
|
||||||
|
#-------------
|
||||||
|
# SAM: NO STATS
|
||||||
|
# FIXME: error handling!
|
||||||
|
# For now, just calling plotting function without stats
|
||||||
|
#-------------
|
||||||
|
title_sam = "SAM (severe)"
|
||||||
|
fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_sam
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
#plots_sam = doMyPlots(lf_fp_sam)
|
||||||
|
plots_sam = doMyPlotsStats(lf_fp_sam)
|
||||||
|
sam_plot = ggpubr::ggarrange(plotlist = plots_sam
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#sam_plot
|
||||||
|
sam_plot_annot = annotate_figure(sam_plot
|
||||||
|
, top = text_grob(title_sam
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP severe adults (n=", fp_sam, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
sam_plot_annot
|
||||||
|
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
|
||||||
|
#-------------
|
||||||
|
# SERUM
|
||||||
|
#-------------
|
||||||
|
title_serum = "SERUM (severe)"
|
||||||
|
fp_serum = length(unique(lf_fp_serum$mosaic)); fp_serum
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_serum
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_serum = doMyPlotsStats(lf_fp_serum)
|
||||||
|
serum_plot = ggpubr::ggarrange(plotlist = plots_serum
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#serum_plot
|
||||||
|
serum_plot_annot = annotate_figure(serum_plot
|
||||||
|
, top = text_grob(title_serum
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP severe adults (n=", fp_serum, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
serum_plot_annot
|
||||||
|
dev.off()
|
||||||
|
###############################################################
|
||||||
|
# END OF SCRIPT #
|
||||||
|
###############################################################
|
177
severe/boxplot_stat_log.R
Executable file
177
severe/boxplot_stat_log.R
Executable file
|
@ -0,0 +1,177 @@
|
||||||
|
#!/usr/bin/Rscript
|
||||||
|
getwd()
|
||||||
|
setwd("~/git/mosaic_2020/")
|
||||||
|
getwd()
|
||||||
|
###############################################################
|
||||||
|
# TASK: boxplots with stats for NPA, SAM and SERUM but with log scale
|
||||||
|
# for each mediator, at each timepoint, by group
|
||||||
|
|
||||||
|
# TODO: check boxplot_stat_function.R
|
||||||
|
# output plots even if stats fail due to data containing only LLODs
|
||||||
|
# however for a given mediator, if there is error for ANY timepoint
|
||||||
|
# stats will not be added for the entire plot! To be handled in
|
||||||
|
# next iteration!
|
||||||
|
###############################################################
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Input
|
||||||
|
#=============
|
||||||
|
source("boxplot_stat_function.R")
|
||||||
|
source("plot_data_s.R")
|
||||||
|
|
||||||
|
#=============
|
||||||
|
# Output
|
||||||
|
#=============
|
||||||
|
outfile_bp = paste0("boxplots_stats_all_Sev_LOG-%03d.svg")
|
||||||
|
output_boxplot_stats = paste0(outdir_plots, outfile_bp); output_boxplot_stats
|
||||||
|
svg(output_boxplot_stats, width=22, height=16)
|
||||||
|
###############################################################
|
||||||
|
#===============================
|
||||||
|
# data assignment for plots
|
||||||
|
#===============================
|
||||||
|
#----------------------------------------
|
||||||
|
#-------
|
||||||
|
# NPA
|
||||||
|
#-------
|
||||||
|
# vl data juggling with 0!
|
||||||
|
vl_temp_fix = lf_fp_npa[lf_fp_npa$mediator=="vl_pfu_ul",]
|
||||||
|
vl_temp_fix$value[1:20]
|
||||||
|
vl_temp_fix$value[vl_temp_fix$value == 0] <- 1
|
||||||
|
vl_temp_fix$value[1:20]
|
||||||
|
|
||||||
|
orig_nrow = nrow(lf_fp_npa); orig_nrow; table(lf_fp_npa$mediator)
|
||||||
|
lf_fp_npa = lf_fp_npa[!lf_fp_npa$mediator=="vl_pfu_ul",]
|
||||||
|
temp_nrow = nrow(lf_fp_npa); temp_nrow; table(lf_fp_npa$mediator)
|
||||||
|
|
||||||
|
# add vl_temp_fix back
|
||||||
|
lf_fp_npa = rbind(lf_fp_npa, vl_temp_fix)
|
||||||
|
revised_nrow = nrow(lf_fp_npa); revised_nrow
|
||||||
|
|
||||||
|
orig_nrow == revised_nrow
|
||||||
|
|
||||||
|
head(lf_fp_npa$value)
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
# log all values and reassign
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
lf_fp_npa$value = log10(lf_fp_npa$value)
|
||||||
|
head(lf_fp_npa$value)
|
||||||
|
vl_temp_fix2 = lf_fp_npa[lf_fp_npa$mediator=="vl_pfu_ul",]
|
||||||
|
vl_temp_fix2$value[1:20]
|
||||||
|
|
||||||
|
#------------------------------------------
|
||||||
|
title_npa = "NPA (severe)"
|
||||||
|
fp_npa = length(unique(lf_fp_npa$mosaic)); fp_npa
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_npa
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_npa = doMyPlotsStats(lf_fp_npa)
|
||||||
|
npa_plot = ggpubr::ggarrange(plotlist = plots_npa
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#npa_plot
|
||||||
|
npa_plot_annot = annotate_figure(npa_plot
|
||||||
|
, top = text_grob(title_npa
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP severe adults (n=", fp_npa, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
npa_plot_annot
|
||||||
|
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
|
||||||
|
#-------------
|
||||||
|
# SAM
|
||||||
|
#-------------
|
||||||
|
head(lf_fp_sam$value)
|
||||||
|
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
# log all values and reassign
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
lf_fp_sam$value = log10(lf_fp_sam$value)
|
||||||
|
head(lf_fp_sam$value)
|
||||||
|
|
||||||
|
title_sam = "SAM (severe)"
|
||||||
|
fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_sam
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_sam = doMyPlotsStats(lf_fp_sam)
|
||||||
|
sam_plot = ggpubr::ggarrange(plotlist = plots_sam
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#sam_plot
|
||||||
|
sam_plot_annot = annotate_figure(sam_plot
|
||||||
|
, top = text_grob(title_sam
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP severe adults (n=", fp_sam, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
sam_plot_annot
|
||||||
|
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#
|
||||||
|
#------------------------------------------
|
||||||
|
#-------------
|
||||||
|
# SERUM
|
||||||
|
#-------------
|
||||||
|
head(lf_fp_serum$value)
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
# log all values and reassign
|
||||||
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
lf_fp_serum$value = log10(lf_fp_serum$value)
|
||||||
|
head(lf_fp_serum$value)
|
||||||
|
|
||||||
|
title_serum = "SERUM (severe)"
|
||||||
|
fp_serum = length(unique(lf_fp_serum$mosaic)); fp_serum
|
||||||
|
|
||||||
|
cat("\nPlotting boxplots with stats for:", title_serum
|
||||||
|
, "\n========================================================\n")
|
||||||
|
|
||||||
|
plots_serum = doMyPlotsStats(lf_fp_serum)
|
||||||
|
serum_plot = ggpubr::ggarrange(plotlist = plots_serum
|
||||||
|
, align = "hv"
|
||||||
|
, ncol = 7
|
||||||
|
, nrow = 5
|
||||||
|
, common.legend = T)
|
||||||
|
#serum_plot
|
||||||
|
serum_plot_annot = annotate_figure(serum_plot
|
||||||
|
, top = text_grob(title_serum
|
||||||
|
, color = "blue"
|
||||||
|
, face = "bold"
|
||||||
|
, size = 18)
|
||||||
|
, bottom = text_grob(paste0("Mosaic data\nFP severe adults (n=", fp_serum, ")")
|
||||||
|
, color = "blue"
|
||||||
|
, hjust = 1
|
||||||
|
, x = 0.98
|
||||||
|
, face = "italic"
|
||||||
|
, size = 15)
|
||||||
|
, left = text_grob("Levels (pg/ml)"
|
||||||
|
, color = "black"
|
||||||
|
, rot = 90
|
||||||
|
, size = 18))
|
||||||
|
serum_plot_annot
|
||||||
|
dev.off()
|
||||||
|
###############################################################
|
||||||
|
# END OF SCRIPT #
|
||||||
|
###############################################################
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue