added appendix tables script
This commit is contained in:
parent
d984d283c5
commit
4609757efb
1 changed files with 144 additions and 0 deletions
144
scripts/plotting/plotting_thesis/appendix_tables.R
Normal file
144
scripts/plotting/plotting_thesis/appendix_tables.R
Normal file
|
@ -0,0 +1,144 @@
|
|||
#!/usr/bin/env Rscript
|
||||
#source("~/git/LSHTM_analysis/config/alr.R")
|
||||
source("~/git/LSHTM_analysis/config/embb.R")
|
||||
#source("~/git/LSHTM_analysis/config/katg.R")
|
||||
#source("~/git/LSHTM_analysis/config/gid.R")
|
||||
#source("~/git/LSHTM_analysis/config/pnca.R")
|
||||
#source("~/git/LSHTM_analysis/config/rpob.R")
|
||||
|
||||
# get plottting dfs
|
||||
source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R")
|
||||
|
||||
source("~/git/LSHTM_analysis/scripts/plotting/plotting_colnames.R")
|
||||
#=======
|
||||
# output
|
||||
#=======
|
||||
outdir_images = paste0("~/git/Writing/thesis/images/results/", tolower(gene), "/")
|
||||
outdir_stats = paste0(outdir_images,"stats/")
|
||||
|
||||
###################################################################
|
||||
# FIXME: ADD distance to NA when SP replies
|
||||
|
||||
geneL_normal = c("pnca")
|
||||
geneL_na = c("gid", "rpob")
|
||||
geneL_ppi2 = c("alr", "embb", "katg", "rpob")
|
||||
|
||||
# LigDist_colname # from globals used
|
||||
# ppi2Dist_colname #from globals used
|
||||
# naDist_colname #from globals used
|
||||
|
||||
df3 = merged_df3
|
||||
|
||||
# Add adjusted P-values
|
||||
df3$p_adj_fdr = p.adjust(df3$pval_fisher, method = "fdr")
|
||||
df3$signif_fdr = df3$p_adj_fdr
|
||||
df3 = dplyr::mutate(df3
|
||||
, signif_fdr = case_when(signif_fdr == 0.05 ~ "."
|
||||
, signif_fdr <=0.0001 ~ '****'
|
||||
, signif_fdr <=0.001 ~ '***'
|
||||
, signif_fdr <=0.01 ~ '**'
|
||||
, signif_fdr <0.05 ~ '*'
|
||||
, TRUE ~ 'ns'))
|
||||
|
||||
|
||||
|
||||
|
||||
####################################
|
||||
# Appendix: ligand affinity
|
||||
####################################
|
||||
df_lig = df3[df3[[LigDist_colname]]<DistCutOff,]
|
||||
|
||||
|
||||
cols_to_output_lig = c("mutationinformation"
|
||||
, "position"
|
||||
, LigDist_colname
|
||||
, "ligand_affinity_change"
|
||||
, "ligand_outcome"
|
||||
, "mmcsm_lig"
|
||||
, "mmcsm_lig_outcome"
|
||||
, "or_mychisq"
|
||||
, "p_adj_fdr"
|
||||
, "signif_fdr")
|
||||
|
||||
# counting
|
||||
|
||||
Out_df_lig = df_lig[, cols_to_output_lig]
|
||||
Out_df_ligS = Out_df_lig[order(Out_df_lig$or_mychisq, decreasing = T), ]
|
||||
|
||||
delta_symbol = "\u0394"; delta_symbol
|
||||
|
||||
Out_df_ligS$or_mychisq = round(Out_df_ligS$or_mychisq,2)
|
||||
Out_df_ligS$p_adj_fdr = round(Out_df_ligS$p_adj_fdr,2)
|
||||
Out_df_ligS
|
||||
|
||||
colsNames_to_output_lig = c("Mutation"
|
||||
, "position"
|
||||
, paste0("Lig-Dist (", angstroms_symbol, ")")
|
||||
, "mCSM-ligand affinity"
|
||||
, "mCSM ligand_outcome"
|
||||
, "mmCSM-ligand affinity"
|
||||
, "mmCSM ligand_outcome"
|
||||
, "Odds Ratio"
|
||||
, "Adj P-value"
|
||||
, "P-value significance")
|
||||
|
||||
colnames(Out_df_ligS) = colsNames_to_output_lig
|
||||
Out_df_ligS
|
||||
#--------------------
|
||||
# write output file: KS test within grpup
|
||||
#----------------------
|
||||
Out_ligT = paste0(outdir_stats
|
||||
, tolower(gene)
|
||||
, "_lig_muts.csv")
|
||||
|
||||
cat("Output of Ligand muts:", Out_ligT )
|
||||
write.csv(Out_df_ligS, Out_ligT, row.names = FALSE)
|
||||
|
||||
########################################################################
|
||||
####################################
|
||||
# Appendix: PPi2 affinity
|
||||
####################################
|
||||
|
||||
df_ppi2 = df3[df3[[ppi2Dist_colname]]<DistCutOff,]
|
||||
|
||||
|
||||
cols_to_output_ppi2 = c("mutationinformation"
|
||||
, "position"
|
||||
, ppi2Dist_colname
|
||||
, "mcsm_ppi2_affinity"
|
||||
, "mcsm_ppi2_outcome"
|
||||
, "or_mychisq"
|
||||
, "p_adj_fdr"
|
||||
, "signif_fdr")
|
||||
|
||||
# extract output cols
|
||||
Out_df_ppi2 = df_ppi2[, cols_to_output_ppi2]
|
||||
Out_df_ppi2S = Out_df_ppi2[order(Out_df_ppi2$or_mychisq, decreasing = T), ]
|
||||
|
||||
delta_symbol = "\u0394"; delta_symbol
|
||||
|
||||
Out_df_ppi2S$or_mychisq = round(Out_df_ppi2S$or_mychisq,2)
|
||||
Out_df_ppi2S$p_adj_fdr = round(Out_df_ppi2S$p_adj_fdr,2)
|
||||
Out_df_ppi2S
|
||||
|
||||
colsNames_to_output_ppi2 = c("Mutation"
|
||||
, "position"
|
||||
, paste0("PPI2-Dist (", angstroms_symbol, ")")
|
||||
, paste0("mCSM-PPI2 (", delta_symbol, ")")
|
||||
, "mCSM-PPI2 outcome"
|
||||
, "Odds Ratio"
|
||||
, "Adj P-value"
|
||||
, "P-value significance")
|
||||
|
||||
colnames(Out_df_ppi2S) = colsNames_to_output_ppi2
|
||||
Out_df_ppi2S
|
||||
#--------------------
|
||||
# write output file: KS test within grpup
|
||||
#----------------------
|
||||
Out_ppi2T = paste0(outdir_stats
|
||||
, tolower(gene)
|
||||
, "_ppi2_muts.csv")
|
||||
|
||||
cat("Output of PPI2 muts:", Out_ppi2T )
|
||||
write.csv(Out_df_ppi2S, Out_ppi2T, row.names = FALSE)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue