replaced single quotes with double in R scripts
This commit is contained in:
parent
5e1b39cea0
commit
7d1ecbb660
5 changed files with 113 additions and 113 deletions
|
@ -1,5 +1,5 @@
|
|||
getwd()
|
||||
setwd('~/git/LSHTM_analysis/scripts/plotting')
|
||||
setwd("~/git/LSHTM_analysis/scripts/plotting")
|
||||
getwd()
|
||||
|
||||
#########################################################
|
||||
|
@ -22,48 +22,48 @@ getwd()
|
|||
|
||||
#########################################################
|
||||
#%% variable assignment: input and output paths & filenames
|
||||
drug = 'pyrazinamide'
|
||||
gene = 'pncA'
|
||||
gene_match = paste0(gene,'_p.')
|
||||
drug = "pyrazinamide"
|
||||
gene = "pncA"
|
||||
gene_match = paste0(gene,"_p.")
|
||||
cat(gene_match)
|
||||
|
||||
#=============
|
||||
# directories
|
||||
#=============
|
||||
datadir = paste0('~/git/Data')
|
||||
indir = paste0(datadir, '/', drug, '/input')
|
||||
outdir = paste0('~/git/Data', '/', drug, '/output')
|
||||
datadir = paste0("~/git/Data")
|
||||
indir = paste0(datadir, "/", drug, "/input")
|
||||
outdir = paste0("~/git/Data", "/", drug, "/output")
|
||||
|
||||
#======
|
||||
# input
|
||||
#======
|
||||
#in_filename = 'mcsm_complex1_normalised.csv'
|
||||
in_filename_params = paste0(tolower(gene), '_all_params.csv')
|
||||
infile_params = paste0(outdir, '/', in_filename_params)
|
||||
cat(paste0('Input file 1:', infile_params) )
|
||||
#in_filename = "mcsm_complex1_normalised.csv"
|
||||
in_filename_params = paste0(tolower(gene), "_all_params.csv")
|
||||
infile_params = paste0(outdir, "/", in_filename_params)
|
||||
cat(paste0("Input file 1:", infile_params) )
|
||||
|
||||
#=======
|
||||
# output
|
||||
#=======
|
||||
# plot 1
|
||||
basic_bp_duet = 'basic_barplot_PS.svg'
|
||||
plot_basic_bp_duet = paste0(outdir, '/plots/', basic_bp_duet)
|
||||
basic_bp_duet = "basic_barplot_PS.svg"
|
||||
plot_basic_bp_duet = paste0(outdir, "/plots/", basic_bp_duet)
|
||||
|
||||
# plot 2
|
||||
pos_count_duet = 'position_count_PS.svg'
|
||||
plot_pos_count_duet = paste0(outdir, '/plots/', pos_count_duet)
|
||||
pos_count_duet = "position_count_PS.svg"
|
||||
plot_pos_count_duet = paste0(outdir, "/plots/", pos_count_duet)
|
||||
|
||||
#%%===============================================================
|
||||
###########################
|
||||
# Read file: struct params
|
||||
###########################
|
||||
cat('Reading struct params including mcsm:', in_filename_params)
|
||||
cat("Reading struct params including mcsm:", in_filename_params)
|
||||
|
||||
my_df = read.csv(infile_params
|
||||
#, stringsAsFactors = F
|
||||
, header = T)
|
||||
|
||||
cat('Input dimensions:', dim(my_df))
|
||||
cat("Input dimensions:", dim(my_df))
|
||||
|
||||
# clear variables
|
||||
rm(in_filename_params, infile_params)
|
||||
|
@ -74,22 +74,22 @@ str(my_df)
|
|||
|
||||
# check for duplicate mutations
|
||||
if ( length(unique(my_df$mutationinformation)) != length(my_df$mutationinformation)){
|
||||
cat(paste0('CAUTION:', ' Duplicate mutations identified'
|
||||
, '\nExtracting these...'))
|
||||
cat(paste0("CAUTION:", " Duplicate mutations identified"
|
||||
, "\nExtracting these..."))
|
||||
dup_muts = my_df[duplicated(my_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'))
|
||||
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"))
|
||||
my_df_u = my_df[!duplicated(my_df$mutationinformation),]
|
||||
}else{
|
||||
cat(paste0('No duplicate mutations detected'))
|
||||
cat(paste0("No duplicate mutations detected"))
|
||||
my_df_u = my_df
|
||||
}
|
||||
|
||||
upos = unique(my_df_u$position)
|
||||
cat('Dim of clean df:'); cat(dim(my_df_u))
|
||||
cat('\nNo. of unique mutational positions:'); cat(length(upos))
|
||||
cat("Dim of clean df:"); cat(dim(my_df_u))
|
||||
cat("\nNo. of unique mutational positions:"); cat(length(upos))
|
||||
|
||||
########################################################################
|
||||
# end of data extraction and cleaning for plots #
|
||||
|
@ -109,9 +109,9 @@ library(ggplot2)
|
|||
#****************
|
||||
# Plot 1:Count of stabilising and destabilsing muts
|
||||
#****************
|
||||
#svg('basic_barplots_PS.svg')
|
||||
#svg("basic_barplots_PS.svg")
|
||||
svg(plot_basic_bp_duet)
|
||||
print(paste0('plot filename:', basic_bp_duet))
|
||||
print(paste0("plot filename:", basic_bp_duet))
|
||||
|
||||
my_ats = 25 # axis text size
|
||||
my_als = 22 # axis label size
|
||||
|
@ -138,7 +138,7 @@ prinfFile = g + geom_bar(aes(fill = duet_outcome)
|
|||
, plot.title = element_blank()) +
|
||||
labs(title = ""
|
||||
, y = "Number of SNPs"
|
||||
#, fill='DUET Outcome'
|
||||
#, fill="DUET Outcome"
|
||||
) +
|
||||
scale_fill_discrete(name = "DUET Outcome"
|
||||
, labels = c("Destabilising", "Stabilising"))
|
||||
|
@ -178,9 +178,9 @@ foo = select(df, mutationinformation
|
|||
#write.csv(foo, "/pos_count_freq.csv")
|
||||
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
#svg('position_count_PS.svg')
|
||||
#svg("position_count_PS.svg")
|
||||
svg(plot_pos_count_duet)
|
||||
print(paste0('plot filename:', plot_pos_count_duet))
|
||||
print(paste0("plot filename:", plot_pos_count_duet))
|
||||
|
||||
my_ats = 25 # axis text size
|
||||
my_als = 22 # axis label size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue