renamed file

This commit is contained in:
Tanushree Tunstall 2020-11-02 12:05:55 +00:00
parent ee35e1cb20
commit 9fc9a5852b
5 changed files with 96 additions and 40 deletions

110
boxplot_stat_all.R Normal file → Executable file
View file

@ -3,19 +3,31 @@ getwd()
setwd("~/git/mosaic_2020/") setwd("~/git/mosaic_2020/")
getwd() getwd()
############################################################### ###############################################################
#=============
# Input
#=============
source("boxplot_stat_function.R") source("boxplot_stat_function.R")
source("plot_data.R") source("plot_data.R")
#============= #=============
# Output: # Output
#============= #=============
outfile_bp = paste0("boxplots_stats_all", ".pdf") outfile_bp = paste0("boxplots_stats_all", ".pdf")
output_boxplot_stats = paste0(outdir_plots, outfile_bp); output_boxplot_stats output_boxplot_stats = paste0(outdir_plots, outfile_bp); output_boxplot_stats
pdf(output_boxplot_stats, width=22, height=16) pdf(output_boxplot_stats, width=22, height=16)
###############################################################
#=========================== #===============================
# data assignment for plots
#===============================
#-------------
# NPA # NPA
#=========================== #-------------
my_sample_npa = "NPA" my_sample_npa = "NPA"
fp_npa = length(unique(lf_fp_npa$mosaic)); fp_npa
cat("\nPlotting boxplots with stats for:", my_sample_npa
, "\n========================================================\n")
plots_npa = doMyPlots(lf_fp_npa) plots_npa = doMyPlots(lf_fp_npa)
npa_plot = ggpubr::ggarrange(plotlist = plots_npa npa_plot = ggpubr::ggarrange(plotlist = plots_npa
, align = "hv" , align = "hv"
@ -24,36 +36,64 @@ npa_plot = ggpubr::ggarrange(plotlist = plots_npa
, common.legend = T) , common.legend = T)
#npa_plot #npa_plot
npa_plot_annot = annotate_figure(npa_plot npa_plot_annot = annotate_figure(npa_plot
, top = text_grob(my_sample_npa, color = "blue", face = "bold", size = 14) , top = text_grob(my_sample_npa
, bottom = text_grob("Mosaic data\nFlu positive adults (n=133)" , color = "blue"
, face = "bold"
, size = 14)
, bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_npa, ")")
, color = "blue" , color = "blue"
, hjust = 1, x = 0.98, face = "italic", size = 10) , hjust = 1
, left = text_grob("Levels (pg/ml)", color = "black", rot = 90, size = 18)) , x = 0.98
, face = "italic"
, size = 10)
, left = text_grob("Levels (pg/ml)"
, color = "black"
, rot = 90
, size = 18))
npa_plot_annot npa_plot_annot
#dev.off() #dev.off()
#=========================== #-------------
# SAM # SAM
#=========================== #-------------
my_sample_sam = "SAM" #my_sample_sam = "SAM"
plots_sam = doMyPlots(lf_fp_sam) #fp_sam = length(unique(lf_fp_sam$mosaic)); fp_sam
sam_plot = ggpubr::ggarrange(plotlist = plots_sam
, align = "hv" #cat("\nPlotting boxplots with stats for:", my_sample_sam
, ncol = 7 # , "\n========================================================\n")
, nrow = 5
, common.legend = T) #plots_sam = doMyPlots(lf_fp_sam)
#sam_plot = ggpubr::ggarrange(plotlist = plots_sam
# , align = "hv"
# , ncol = 7
# , nrow = 5
# , common.legend = T)
#sam_plot #sam_plot
sam_plot_annot = annotate_figure(sam_plot #sam_plot_annot = annotate_figure(sam_plot
, top = text_grob(my_sample_sam, color = "blue", face = "bold", size = 14) # , top = text_grob(my_sample_sam
, bottom = text_grob("Mosaic data\nFlu positive adults (n=133)" # , color = "blue"
, color = "blue" # , face = "bold"
, hjust = 1, x = 0.98, face = "italic", size = 10) # , size = 14)
, left = text_grob("Levels (pg/ml)", color = "black", rot = 90, size = 18)) # , bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_sam, ")")
sam_plot_annot # , color = "blue"
# , hjust = 1
# , x = 0.98
# , face = "italic"
# , size = 10)
# , left = text_grob("Levels (pg/ml)"
# , color = "black"
# , rot = 90
# , size = 18))
#sam_plot_annot
#dev.off() #dev.off()
#=========================== #-------------
# SERUM # SERUM
#=========================== #-------------
my_sample_serum = "serum" my_sample_serum = "serum"
fp_serum = length(unique(lf_fp_serum$mosaic)); fp_serum
cat("\nPlotting boxplots with stats for:", my_sample_serum
, "\n========================================================\n")
plots_serum = doMyPlots(lf_fp_serum) plots_serum = doMyPlots(lf_fp_serum)
serum_plot = ggpubr::ggarrange(plotlist = plots_serum serum_plot = ggpubr::ggarrange(plotlist = plots_serum
, align = "hv" , align = "hv"
@ -62,10 +102,20 @@ serum_plot = ggpubr::ggarrange(plotlist = plots_serum
, common.legend = T) , common.legend = T)
#serum_plot #serum_plot
serum_plot_annot = annotate_figure(serum_plot serum_plot_annot = annotate_figure(serum_plot
, top = text_grob(my_sample_serum, color = "blue", face = "bold", size = 14) , top = text_grob(my_sample_serum
, bottom = text_grob("Mosaic data\nFlu positive adults (n=133)" , color = "blue"
, face = "bold"
, size = 14)
, bottom = text_grob(paste0("Mosaic data\nFlu positive adults (n=", fp_serum, ")")
, color = "blue" , color = "blue"
, hjust = 1, x = 0.98, face = "italic", size = 10) , hjust = 1
, left = text_grob("Levels (pg/ml)", color = "black", rot = 90, size = 18)) , x = 0.98
, face = "italic"
, size = 10)
, left = text_grob("Levels (pg/ml)"
, color = "black"
, rot = 90
, size = 18))
serum_plot_annot serum_plot_annot
dev.off() dev.off()
###############################################################

0
boxplot_stat_function.R Normal file → Executable file
View file

15
boxplot_stat_test.R → boxplot_stat_function_test.R Normal file → Executable file
View file

@ -11,6 +11,7 @@ source("plot_data.R")
my_sample_name = "SAM" my_sample_name = "SAM"
to_remove = c("ifna2a", "il29") to_remove = c("ifna2a", "il29")
lf_fp_sam2 = lf_fp_sam[!lf_fp_sam$mediator%in%to_remove,] lf_fp_sam2 = lf_fp_sam[!lf_fp_sam$mediator%in%to_remove,]
lf_fp_sam3 = lf_fp_sam[lf_fp_sam$mediator%in%to_remove,]
foo = doMyPlots(lf_fp_sam2) foo = doMyPlots(lf_fp_sam2)
@ -23,11 +24,19 @@ pdf(output_boxplot_stats, width=22, height=16)
#baz=cowplot::plot_grid(plotlist=foo, align = 'hv', ncol=2, nrow=2) #baz=cowplot::plot_grid(plotlist=foo, align = 'hv', ncol=2, nrow=2)
foo_annot = annotate_figure(foo foo_annot = annotate_figure(foo
, top = text_grob(my_sample_name, color = "blue", face = "bold", size = 14) , top = text_grob(my_sample_name
, color = "blue"
, face = "bold"
, size = 14)
, bottom = text_grob("Mosaic data\nFlu positive adults (n=133)" , bottom = text_grob("Mosaic data\nFlu positive adults (n=133)"
, color = "blue" , color = "blue"
, hjust = 1, x = 0.98, face = "italic", size = 10) , hjust = 1, x = 0.98
, left = text_grob("Levels (pg/ml)", color = "black", rot = 90, size = 18) , face = "italic"
, size = 10)
, left = text_grob("Levels (pg/ml)"
, color = "black"
, rot = 90
, size = 18)
) )
foo_annot foo_annot
dev.off() dev.off()

0
boxplot_with_stats.R Normal file → Executable file
View file

11
plot_data.R Normal file → Executable file
View file

@ -6,7 +6,7 @@ getwd()
# TASK: boxplots at T1 # TASK: boxplots at T1
# FIXME: currently not rendering, problem with NAs for stats? # FIXME: currently not rendering, problem with NAs for stats?
############################################################ ############################################################
my_samples = "npa_sam_serum"
#============= #=============
# Input # Input
#============= #=============
@ -15,12 +15,6 @@ source("data_extraction_formatting.R")
# check: adult variable and age variable discrepancy! # check: adult variable and age variable discrepancy!
metadata_all$mosaic[metadata_all$adult==1 & metadata_all$age<=18] metadata_all$mosaic[metadata_all$adult==1 & metadata_all$age<=18]
#=============
# Output:
#=============
outfile_bp = paste0("boxplots_linear_", my_samples, ".pdf")
output_boxplot = paste0(outdir_plots, outfile_bp); output_boxplot
#=============================== #===============================
# data assignment for plots # data assignment for plots
#================================ #================================
@ -36,6 +30,7 @@ lf_fp_npa$obesity = as.factor(lf_fp_npa$obesity)
table(lf_fp_npa$mediator) table(lf_fp_npa$mediator)
head(lf_fp_npa$value[lf_fp_npa$mediator == "vitd"]) head(lf_fp_npa$value[lf_fp_npa$mediator == "vitd"])
lf_fp_npa = lf_fp_npa[!lf_fp_npa$mediator == "vitd",] lf_fp_npa = lf_fp_npa[!lf_fp_npa$mediator == "vitd",]
table(lf_fp_npa$mediator)
#----------- #-----------
# sam # sam
@ -49,6 +44,7 @@ lf_fp_sam$obesity = as.factor(lf_fp_sam$obesity)
table(lf_fp_sam$mediator) table(lf_fp_sam$mediator)
head(lf_fp_sam$value[lf_fp_sam$mediator == "vitd"]) head(lf_fp_sam$value[lf_fp_sam$mediator == "vitd"])
lf_fp_sam = lf_fp_sam[!lf_fp_sam$mediator == "vitd",] lf_fp_sam = lf_fp_sam[!lf_fp_sam$mediator == "vitd",]
table(lf_fp_sam$mediator)
#----------- #-----------
# serum # serum
@ -59,4 +55,5 @@ lf_fp_serum$timepoint = paste0("t", lf_fp_serum$timepoint)
lf_fp_serum$timepoint = as.factor(lf_fp_serum$timepoint) lf_fp_serum$timepoint = as.factor(lf_fp_serum$timepoint)
lf_fp_serum$obesity = as.factor(lf_fp_serum$obesity) lf_fp_serum$obesity = as.factor(lf_fp_serum$obesity)
head(lf_fp_sam$value[lf_fp_serum$mediator == "vitd"])
######################################################################## ########################################################################