a massive waste of time
This commit is contained in:
parent
8d6c148fff
commit
4147a6b90f
3 changed files with 726 additions and 620 deletions
File diff suppressed because it is too large
Load diff
|
@ -12,20 +12,19 @@ geneL_na = c("gid", "rpob")
|
|||
geneL_ppi2 = c("alr", "embb", "katg", "rpob")
|
||||
|
||||
if (tolower(gene)%in%geneL_na){
|
||||
|
||||
infilename_nca = paste0("/home/tanu/git/Misc/mcsm_na_dist/"
|
||||
, tolower(gene), "_nca_distances.csv")
|
||||
, tolower(gene), "_nca_distances.csv")
|
||||
}
|
||||
#========================================================
|
||||
# plotting_data(): formatting data for plots
|
||||
# input args:
|
||||
## input csv file
|
||||
## lig cut off dist, default = 10 Ang
|
||||
## input csv file
|
||||
## lig cut off dist, default = 10 Ang
|
||||
# output: list of 4 dfs, that need to be decompressed
|
||||
## my_df
|
||||
## my_df_u
|
||||
## my_df_u_lig
|
||||
## dup_muts
|
||||
## my_df
|
||||
## my_df_u
|
||||
## my_df_u_lig
|
||||
## dup_muts
|
||||
#========================================================
|
||||
#lig_dist_colname = 'ligand_distance' or global var LigDist_colname
|
||||
#lig_dist_cutoff = 10 or global var LigDist_cutoff
|
||||
|
@ -34,80 +33,121 @@ plotting_data <- function(df
|
|||
, gene # ADDED
|
||||
, lig_dist_colname
|
||||
, lig_dist_cutoff) {
|
||||
my_df = data.frame()
|
||||
my_df_u = data.frame()
|
||||
my_df_u_lig = data.frame()
|
||||
dup_muts = data.frame()
|
||||
my_df = data.frame()
|
||||
my_df_u = data.frame()
|
||||
my_df_u_lig = data.frame()
|
||||
dup_muts = data.frame()
|
||||
|
||||
#===========================
|
||||
# Read file: struct params
|
||||
#===========================
|
||||
#df = read.csv(infile_params, header = T)
|
||||
#===========================
|
||||
# Read file: struct params
|
||||
#===========================
|
||||
#df = read.csv(infile_params, header = T)
|
||||
|
||||
cat("\nInput dimensions:", dim(df))
|
||||
cat("\nInput dimensions:", dim(df))
|
||||
|
||||
#==================================
|
||||
# extract unique mutation entries
|
||||
#==================================
|
||||
#==================================
|
||||
# extract unique mutation entries
|
||||
#==================================
|
||||
|
||||
# check for duplicate mutations
|
||||
if ( length(unique(df$mutationinformation)) != length(df$mutationinformation)){
|
||||
cat(paste0("\nCAUTION:", " Duplicate mutations identified"
|
||||
, "\nExtracting these...\n"))
|
||||
#cat(my_df[duplicated(my_df$mutationinformation),])
|
||||
dup_muts = df[duplicated(df$mutationinformation),]
|
||||
dup_muts_nu = length(unique(dup_muts$mutationinformation))
|
||||
cat(paste0("\nDim of duplicate mutation df:", nrow(dup_muts)
|
||||
, "\nNo. of unique duplicate mutations:", dup_muts_nu
|
||||
, "\n\nExtracting df with unique mutations only\n"))
|
||||
my_df_u = df[!duplicated(df$mutationinformation),]
|
||||
}else{
|
||||
cat(paste0("\nNo duplicate mutations detected\n"))
|
||||
my_df_u = df
|
||||
}
|
||||
# check for duplicate mutations
|
||||
if ( length(unique(df$mutationinformation)) != length(df$mutationinformation)){
|
||||
cat(paste0("\nCAUTION:", " Duplicate mutations identified"
|
||||
, "\nExtracting these...\n"))
|
||||
#cat(my_df[duplicated(my_df$mutationinformation),])
|
||||
dup_muts = df[duplicated(df$mutationinformation),]
|
||||
dup_muts_nu = length(unique(dup_muts$mutationinformation))
|
||||
cat(paste0("\nDim of duplicate mutation df:", nrow(dup_muts)
|
||||
, "\nNo. of unique duplicate mutations:", dup_muts_nu
|
||||
, "\n\nExtracting df with unique mutations only\n"))
|
||||
my_df_u = df[!duplicated(df$mutationinformation),]
|
||||
} else {
|
||||
cat(paste0("\nNo duplicate mutations detected\n"))
|
||||
my_df_u = df
|
||||
}
|
||||
|
||||
upos = unique(my_df_u$position)
|
||||
cat("\nDim of clean df:"); cat(dim(my_df_u), "\n")
|
||||
cat("\nNo. of unique mutational positions:"); cat(length(upos), "\n")
|
||||
#===============================================
|
||||
# ADD : na distance column for genes with nucleic acid affinity
|
||||
#===============================================
|
||||
#gid_na_distcol
|
||||
if (tolower(gene)%in%geneL_na){
|
||||
upos = unique(my_df_u$position)
|
||||
cat("\nDim of clean df:"); cat(dim(my_df_u), "\n")
|
||||
cat("\nNo. of unique mutational positions:"); cat(length(upos), "\n")
|
||||
#===============================================
|
||||
# ADD : na distance column for genes with nucleic acid affinity
|
||||
#===============================================
|
||||
# if (tolower(gene)%in%geneL_na){
|
||||
#
|
||||
# distcol_nca_name = read.csv(infilename_nca, header = F)
|
||||
# head(distcol_nca_name)
|
||||
# colnames(distcol_nca_name) <- c("mutationinformation", "nca_distance")
|
||||
# head(distcol_nca_name)
|
||||
# class(distcol_nca_name)
|
||||
#
|
||||
# mcol = colnames(distcol_nca_name)[colnames(distcol_nca_name)%in%colnames(my_df_u)]
|
||||
# mcol
|
||||
# head(my_df_u$mutationinformation)
|
||||
# head(distcol_nca_name$mutationinformation)
|
||||
#
|
||||
# my_df_u = merge(my_df_u, distcol_nca_name,
|
||||
# by = "mutationinformation",
|
||||
# all = T)
|
||||
#
|
||||
# }
|
||||
|
||||
distcol_nca_name = read.csv(infilename_nca, header = F)
|
||||
head(distcol_nca_name)
|
||||
colnames(distcol_nca_name) <- c("mutationinformation", "nca_distance")
|
||||
head(distcol_nca_name)
|
||||
class(distcol_nca_name)
|
||||
if (tolower(gene)%in%geneL_na){
|
||||
distcol_nca_name = read.csv(infilename_nca, header = F)
|
||||
|
||||
mcol = colnames(distcol_nca_name)[colnames(distcol_nca_name)%in%colnames(my_df_u)]
|
||||
mcol
|
||||
head(my_df_u$mutationinformation)
|
||||
head(distcol_nca_name$mutationinformation)
|
||||
if (tolower(gene)=='rpob'){
|
||||
print('WARNING: running special-case handler for rpoB')
|
||||
|
||||
my_df_u = merge(my_df_u, distcol_nca_name,
|
||||
by = "mutationinformation",
|
||||
all = T)
|
||||
# create 5uhc equivalent column for mutationinformation
|
||||
my_df_u$X5uhc_mutationinformation = paste0(my_df_u$wild_type,
|
||||
my_df_u$X5uhc_position,
|
||||
my_df_u$mutant_type)
|
||||
|
||||
}
|
||||
#===============================================
|
||||
# extract mutations <10 Angstroms and symbol
|
||||
#===============================================
|
||||
table(my_df_u[[lig_dist_colname]] < lig_dist_cutoff)
|
||||
colnames(distcol_nca_name) <- c("X5uhc_mutationinformation", "nca_distance")
|
||||
|
||||
my_df_u_lig = my_df_u[my_df_u[[lig_dist_colname]] < lig_dist_cutoff,]
|
||||
# do stuff here
|
||||
mcol = colnames(distcol_nca_name)[colnames(distcol_nca_name)%in%colnames(my_df_u)]
|
||||
cat(paste0("\nMerging for gene: ", tolower(gene), "\non column: ", mcol))
|
||||
|
||||
cat(paste0("There are ", nrow(my_df_u_lig), " sites lying within 10\u212b of the ligand\n"))
|
||||
head(my_df_u$mutationinformation)
|
||||
head(distcol_nca_name$X5uhc_mutationinformation)
|
||||
|
||||
# return list of DFs
|
||||
my_df = df
|
||||
#df_names = c("my_df", "my_df_u", "my_df_u_lig", "dup_muts")
|
||||
all_df = list(my_df, my_df_u, my_df_u_lig, dup_muts)
|
||||
#all_df = Map(setNames, all_df, df_names)
|
||||
my_df_u = merge(my_df_u, distcol_nca_name,
|
||||
by = "X5uhc_mutationinformation",
|
||||
all = T)
|
||||
|
||||
return(all_df)
|
||||
} else {
|
||||
head(distcol_nca_name)
|
||||
colnames(distcol_nca_name) <- c("mutationinformation", "nca_distance")
|
||||
head(distcol_nca_name)
|
||||
class(distcol_nca_name)
|
||||
mcol = colnames(distcol_nca_name)[colnames(distcol_nca_name)%in%colnames(my_df_u)]
|
||||
cat(paste0("\nMerging for gene: ", tolower(gene), "\non column: ", mcol))
|
||||
head(my_df_u$mutationinformation)
|
||||
head(distcol_nca_name$mutationinformation)
|
||||
|
||||
my_df_u = merge(my_df_u, distcol_nca_name,
|
||||
by = "mutationinformation",
|
||||
all = T)
|
||||
}
|
||||
}
|
||||
|
||||
#===============================================
|
||||
# extract mutations <10 Angstroms and symbol
|
||||
#===============================================
|
||||
table(my_df_u[[lig_dist_colname]] < lig_dist_cutoff)
|
||||
|
||||
my_df_u_lig = my_df_u[my_df_u[[lig_dist_colname]] < lig_dist_cutoff,]
|
||||
|
||||
cat(paste0("There are ", nrow(my_df_u_lig), " sites lying within 10\u212b of the ligand\n"))
|
||||
|
||||
# return list of DFs
|
||||
my_df = df
|
||||
#df_names = c("my_df", "my_df_u", "my_df_u_lig", "dup_muts")
|
||||
all_df = list(my_df, my_df_u, my_df_u_lig, dup_muts)
|
||||
#all_df = Map(setNames, all_df, df_names)
|
||||
|
||||
return(all_df)
|
||||
}
|
||||
########################################################################
|
||||
# end of data extraction and cleaning for plots #
|
||||
########################################################################
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ pd_df = plotting_data(mcsm_df
|
|||
my_df = pd_df[[1]]
|
||||
my_df_u = pd_df[[2]] # this forms one of the input for combining_dfs_plotting()
|
||||
|
||||
max_ang <- round(max(my_df_u[LigDist_colname]))
|
||||
min_ang <- round(min(my_df_u[LigDist_colname]))
|
||||
max_ang <- round(max(my_df_u[[LigDist_colname]]))
|
||||
min_ang <- round(min(my_df_u[[LigDist_colname]]))
|
||||
|
||||
cat("\nLigand distance colname:", LigDist_colname
|
||||
, "\nThe max distance", gene, "structure df" , ":", max_ang, "\u212b"
|
||||
|
@ -128,6 +128,11 @@ geneL_normal = c("pnca")
|
|||
geneL_na = c("gid", "rpob")
|
||||
geneL_ppi2 = c("alr", "embb", "katg", "rpob")
|
||||
|
||||
# geneL_normal = c("pnca")
|
||||
# geneL_both = c("rpob")
|
||||
# geneL_ppi2 = c("alr", "embb", "katg")
|
||||
# geneL_na = c("gid")
|
||||
|
||||
all_dm_om_df = dm_om_wf_lf_data(df = merged_df3, gene = gene)
|
||||
|
||||
wf_duet = all_dm_om_df[['wf_duet']]
|
||||
|
@ -158,15 +163,27 @@ lf_provean = all_dm_om_df[['lf_provean']]
|
|||
wf_dist_gen = all_dm_om_df[['wf_dist_gen']]
|
||||
lf_dist_gen = all_dm_om_df[['lf_dist_gen']]
|
||||
|
||||
# ppi2 genes
|
||||
if (tolower(gene)%in%geneL_ppi2){
|
||||
wf_mcsm_ppi2 = all_dm_om_df[['wf_mcsm_ppi2']]
|
||||
lf_mcsm_ppi2 = all_dm_om_df[['lf_mcsm_ppi2']]
|
||||
}
|
||||
|
||||
# na genes
|
||||
if (tolower(gene)%in%geneL_na){
|
||||
wf_mcsm_na = all_dm_om_df[['wf_mcsm_na']]
|
||||
lf_mcsm_na = all_dm_om_df[['lf_mcsm_na']]
|
||||
}
|
||||
|
||||
if (tolower(gene)%in%geneL_ppi2){
|
||||
wf_mcsm_ppi2 = all_dm_om_df[['wf_mcsm_ppi2']]
|
||||
lf_mcsm_ppi2 = all_dm_om_df[['lf_mcsm_ppi2']]
|
||||
}
|
||||
# both ppi2+na genes:: NOT NEEDED Here as its is handled by the two ifs above
|
||||
# if (tolower(gene)%in%geneL_both){
|
||||
# wf_mcsm_ppi2 = all_dm_om_df[['wf_mcsm_ppi2']]
|
||||
# lf_mcsm_ppi2 = all_dm_om_df[['lf_mcsm_ppi2']]
|
||||
#
|
||||
# wf_mcsm_na = all_dm_om_df[['wf_mcsm_na']]
|
||||
# lf_mcsm_na = all_dm_om_df[['lf_mcsm_na']]
|
||||
# }
|
||||
|
||||
|
||||
s2 = c("\nSuccessfully sourced other_plots_data.R")
|
||||
cat(s2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue