SNP -> SAV for thesis plots
This commit is contained in:
parent
777d3765cf
commit
db7e2912e1
31 changed files with 145 additions and 145 deletions
|
@ -1,6 +1,6 @@
|
|||
########################################
|
||||
# Lineage barplot
|
||||
# Lineage and nsSNP count barplot
|
||||
# Lineage and SAV count barplot
|
||||
# Lineage Diversity barplot
|
||||
########################################
|
||||
|
||||
|
@ -28,7 +28,7 @@ lin_count_bp <- function( lf_data = lin_lf
|
|||
, leg_location = "top"
|
||||
, y_log10 = FALSE
|
||||
, y_scale_percent = FALSE
|
||||
, y_label = c("Count", "SNP diversity")
|
||||
, y_label = c("Count", "SAV diversity")
|
||||
, ...
|
||||
#, y_label = c("Count")
|
||||
) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
########################################
|
||||
# Lineage barplot
|
||||
# Lineage and nsSNP count barplot
|
||||
# Lineage and SAV count barplot
|
||||
# Lineage Diversity barplot
|
||||
########################################
|
||||
|
||||
|
@ -29,8 +29,8 @@ lin_count_bp_diversity <- function( lf_data = lin_wf
|
|||
, leg_location = "top"
|
||||
, y_log10 = FALSE
|
||||
, y_scale_percent = FALSE
|
||||
#, y_label = c("Count", "SNP diversity")
|
||||
, y_label = c("SNP diversity")
|
||||
#, y_label = c("Count", "SAV diversity")
|
||||
, y_label = c("SAV diversity")
|
||||
, bp_plot_title = ""
|
||||
, title_colour = "chocolate4"
|
||||
, subtitle_text = NULL
|
||||
|
|
|
@ -47,7 +47,7 @@ bp_stability_hmap <- function(plot_df = merged_df3
|
|||
my_yaxts = 10, # y-axis text size
|
||||
my_pts = 10 # plot-title size
|
||||
, my_xlab = "Position"
|
||||
, my_ylab = "No. of nsSNPs"
|
||||
, my_ylab = "No. of SAVs"
|
||||
|
||||
# Custom 2: x-axis: geom tiles ~ lig distance
|
||||
#, A_xvar_lig = T
|
||||
|
@ -75,8 +75,8 @@ bp_stability_hmap <- function(plot_df = merged_df3
|
|||
|
||||
# stability values isolated to help with generating column called: 'group'
|
||||
my_grp = plot_df[[stability_colname]]
|
||||
# cat( "\nLength of nsSNPs:", length(my_grp)
|
||||
# , "\nLength of unique values for nsSNPs:", length(unique(my_grp)) )
|
||||
# cat( "\nLength of SAVs:", length(my_grp)
|
||||
# , "\nLength of unique values for SAVs:", length(unique(my_grp)) )
|
||||
#
|
||||
# Add col: 'group'
|
||||
plot_df$group = paste0(plot_df[[stability_outcome_colname]], "_", my_grp, sep = "")
|
||||
|
|
|
@ -40,7 +40,7 @@ DataED_PFM <- function(msaSeq_mut
|
|||
dash_control <- modifyList(dash_control_default, dash_control)
|
||||
|
||||
############################################
|
||||
# Data processing for logo plot for nsSNPS
|
||||
# Data processing for logo plot for SAVS
|
||||
###########################################
|
||||
|
||||
cat("\nLength of MSA", length(msaSeq_mut))
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
# For my case, this is called "lineage_labels"
|
||||
# This column has short labels like L1, L2, L3, etc.
|
||||
# if this is left empty, then the lineage_column_name will be used
|
||||
# id_colname : sample-id column. Used to calculate SNP count
|
||||
# snp_colname : SNP column. Used to calculate SNP diversity
|
||||
# id_colname : sample-id column. Used to calculate SAV count
|
||||
# snp_colname : SAV column. Used to calculate SAV diversity
|
||||
|
||||
# RETURNS: List
|
||||
# WF and LF data for lineage-wise snp count and snp diversity
|
||||
|
@ -142,7 +142,7 @@ lineage_plot_data <- function(plot_df
|
|||
lin_wf
|
||||
|
||||
#----------------------
|
||||
# Add SNP diversity
|
||||
# Add SAV diversity
|
||||
#----------------------
|
||||
lin_wf$snp_diversity = lin_wf$num_snps_u/lin_wf$total_samples
|
||||
lin_wf
|
||||
|
@ -150,7 +150,7 @@ lineage_plot_data <- function(plot_df
|
|||
#----------------------
|
||||
# Add some formatting
|
||||
#----------------------
|
||||
# SNP diversity
|
||||
# SAV diversity
|
||||
lin_wf$snp_diversity_f = round( (lin_wf$snp_diversity * 100), digits = 0)
|
||||
lin_wf$snp_diversity_f = paste0(lin_wf$snp_diversity_f, "%")
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ LogoPlotMSA <- function(# unified_msa # <- not needed any more because we have '
|
|||
}
|
||||
|
||||
#####################################
|
||||
# Generating logo plots for nsSNPs
|
||||
# Generating logo plots for SAVs
|
||||
#####################################
|
||||
PlotlogolasL <- list()
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
# ...other params
|
||||
|
||||
# Returns: Logo plot from combined data containing all nsSNPs per position.
|
||||
# Helps to see the overview of SNP diversity
|
||||
# Returns: Logo plot from combined data containing all SAVs per position.
|
||||
# Helps to see the overview of SAV diversity
|
||||
|
||||
# TODO: SHINY
|
||||
# select/drop down: omit_snp_count
|
||||
|
@ -37,7 +37,7 @@ LogoPlotSnps <- function(plot_df
|
|||
, omit_snp_count = c(0) # can be 1, 2, etc.
|
||||
, my_logo_col = "chemistry"
|
||||
, x_lab = "Position"
|
||||
, y_lab = "nsSNP Count"
|
||||
, y_lab = "SAV Count"
|
||||
, x_ats = 6 # text size
|
||||
, x_tangle = 90 # text angle
|
||||
, y_ats = 10
|
||||
|
@ -63,7 +63,7 @@ LogoPlotSnps <- function(plot_df
|
|||
omit_snp_count <- as.numeric(unlist(str_extract_all(omit_snp_count, regex("[0-9]+"))))
|
||||
}
|
||||
############################################
|
||||
# Data processing for logo plot for nsSNPS
|
||||
# Data processing for logo plot for SAVS
|
||||
############################################
|
||||
|
||||
# Generate "ligand distance" colour map
|
||||
|
@ -84,7 +84,7 @@ LogoPlotSnps <- function(plot_df
|
|||
max_mut = max(table(mutable_df[[x_axis_colname]]))
|
||||
|
||||
# Subset Data as specified by user
|
||||
cat("\nDisplaying nsSNP position frequency:\n")
|
||||
cat("\nDisplaying SAV position frequency:\n")
|
||||
print(table(mutable_df$mut_pos_occurrence))
|
||||
|
||||
if ( (length(omit_snp_count) ==1) && (omit_snp_count == 0) ){
|
||||
|
@ -93,8 +93,8 @@ LogoPlotSnps <- function(plot_df
|
|||
max_mult_mut = max(table(my_data_snp[[x_axis_colname]]))
|
||||
if (debug) {
|
||||
cat("\nNo filtering requested:"
|
||||
, "\nTotal no. of nsSNPs:", sum(table(mutable_df$mut_pos_occurrence))
|
||||
, "\nTotal no. of nsSNPs omitted:", sum(table(mutable_df$mut_pos_occurrence)[omit_snp_count])
|
||||
, "\nTotal no. of SAVs:", sum(table(mutable_df$mut_pos_occurrence))
|
||||
, "\nTotal no. of SAVs omitted:", sum(table(mutable_df$mut_pos_occurrence)[omit_snp_count])
|
||||
, "\nDim of data:", dim(my_data_snp)
|
||||
, "\nNo. of positions:", length(u)
|
||||
, "\nMax no. of muts at any position:", max_mult_mut)
|
||||
|
@ -109,15 +109,15 @@ LogoPlotSnps <- function(plot_df
|
|||
max_mult_mut = max(table(my_data_snp[[x_axis_colname]]))
|
||||
if (debug) {
|
||||
if (got_rows == exp_nrows) {
|
||||
cat("\nPass: Position with the stated nsSNP frequency filtered:", omit_snp_count
|
||||
, "\nTotal no. of nsSNPs:", sum(table(mutable_df$mut_pos_occurrence))
|
||||
, "\nTotal no. of nsSNPs omitted:", sum(table(mutable_df$mut_pos_occurrence)[omit_snp_count])
|
||||
cat("\nPass: Position with the stated SAV frequency filtered:", omit_snp_count
|
||||
, "\nTotal no. of SAVs:", sum(table(mutable_df$mut_pos_occurrence))
|
||||
, "\nTotal no. of SAVs omitted:", sum(table(mutable_df$mut_pos_occurrence)[omit_snp_count])
|
||||
, "\nDim of subsetted data:", dim(my_data_snp)
|
||||
, "\nNo. of positions:", length(u)
|
||||
, "\nMax no. of muts at any position:", max_mult_mut)
|
||||
} else {
|
||||
|
||||
cat("\nFAIL:Position with the stated nsSNP frequency COULD NOT be filtered..."
|
||||
cat("\nFAIL:Position with the stated SAV frequency COULD NOT be filtered..."
|
||||
, "\nExpected:",exp_nrows
|
||||
, "\nGot:", got_rows )
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ LogoPlotSnps <- function(plot_df
|
|||
position_mt = as.numeric(colnames(tab_mt))
|
||||
position_wt = as.numeric(colnames(tab_wt))
|
||||
#####################################
|
||||
# Generating logo plots for nsSNPs
|
||||
# Generating logo plots for SAVs
|
||||
#####################################
|
||||
#-------------------
|
||||
# Mutant logo plot
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env Rscript
|
||||
|
||||
#########################################################
|
||||
# TASK: function for barplot showing no. of sites with nsSNP
|
||||
# TASK: function for barplot showing no. of sites with SAV
|
||||
# count
|
||||
#########################################################
|
||||
# load libraries and functions
|
||||
|
@ -11,7 +11,7 @@ library(dplyr)
|
|||
|
||||
theme_set(theme_grey())
|
||||
#=================================================================
|
||||
# site_snp_count_bp(): barplots for no. of sites and nsSNP count
|
||||
# site_snp_count_bp(): barplots for no. of sites and SAV count
|
||||
# input args
|
||||
## df containing data to plot
|
||||
## df column name containing site/position numbers
|
||||
|
@ -31,7 +31,7 @@ site_snp_count_bp <- function (plotdf,
|
|||
axis_label_size = 10,#22
|
||||
subtitle_size = 10,#20
|
||||
geom_ls = 10,
|
||||
xaxis_title = "Number of nsSNPs",
|
||||
xaxis_title = "Number of SAVs",
|
||||
yaxis_title = "Number of Sites",
|
||||
title_colour = "chocolate4",
|
||||
subtitle_text = NULL,
|
||||
|
@ -82,7 +82,7 @@ site_snp_count_bp <- function (plotdf,
|
|||
# sanity check
|
||||
if(tot_muts == nrow(plotdf)){
|
||||
cat("\nPASS: total number of mutations match"
|
||||
, "\nTotal no. of nsSNPs:", tot_muts)
|
||||
, "\nTotal no. of SAVs:", tot_muts)
|
||||
} else{
|
||||
cat("\nWARNING: total no. of muts = ", tot_muts
|
||||
, "\nExpected = ", nrow(plotdf))
|
||||
|
@ -106,13 +106,13 @@ site_snp_count_bp <- function (plotdf,
|
|||
, table(snpsBYpos_df$snpsBYpos)
|
||||
, "\n")
|
||||
|
||||
# calculating total no. of sites associated with nsSNPs
|
||||
# calculating total no. of sites associated with SAVs
|
||||
tot_sites = sum(table(snpsBYpos_df$snpsBYpos))
|
||||
|
||||
# sanity check
|
||||
if(tot_sites == length(unique(plotdf$position))){
|
||||
cat("\nPASS: total number of mutation sites match"
|
||||
, "\nTotal no. of sites with nsSNPs:", tot_sites)
|
||||
, "\nTotal no. of sites with SAVs:", tot_sites)
|
||||
} else{
|
||||
cat("WARNING: total no. of sites = ", tot_sites
|
||||
, "\nExpected = ", length(unique(plotdf$position)))
|
||||
|
@ -121,7 +121,7 @@ site_snp_count_bp <- function (plotdf,
|
|||
# FIXME: should really be legend title
|
||||
# but atm being using as plot title
|
||||
#my_leg_title
|
||||
bp_plot_title = paste0("Total nsSNPs: ", tot_muts
|
||||
bp_plot_title = paste0("Total SAVs: ", tot_muts
|
||||
, "\nTotal sites: ", tot_sites)
|
||||
|
||||
#-------------
|
||||
|
|
|
@ -22,7 +22,7 @@ stability_count_bp <- function(plotdf
|
|||
, lts = 10#20 # legend text size
|
||||
, ltis = 11#22 # label title size
|
||||
, geom_ls = 10 # geom_label size
|
||||
, yaxis_title = "Number of nsSNPs"
|
||||
, yaxis_title = "Number of SAVs"
|
||||
, bp_plot_title = ""
|
||||
, label_categories #= c("LEVEL1", "LEVEL2")
|
||||
, title_colour = "chocolate4"
|
||||
|
|
|
@ -62,7 +62,7 @@ lig_dist = 10
|
|||
stability_count_bp(plotdf = my_df_u_lig
|
||||
, df_colname = "ligand_outcome"
|
||||
, leg_title = "Ligand outcome"
|
||||
, yaxis_title = paste0("Number of nsSNPs\nLigand dist: <", lig_dist, "\u212b")
|
||||
, yaxis_title = paste0("Number of SAVs\nLigand dist: <", lig_dist, "\u212b")
|
||||
#, bp_plot_title = "Sites < 10 Ang of ligand"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ source ('get_plotting_dfs.R')
|
|||
source("../functions/bp_lineage.R")
|
||||
|
||||
#########################################
|
||||
# Lineage and SNP count: lineage lf data
|
||||
# Lineage and SAV count: lineage lf data
|
||||
#########################################
|
||||
#=========================
|
||||
# Data: All lineages or
|
||||
|
@ -35,7 +35,7 @@ lin_count_bp(lin_lf_plot = lin_lf
|
|||
, y_label = "Count")
|
||||
|
||||
###############################################
|
||||
# Lineage SNP diversity count: lineage wf data
|
||||
# Lineage SAV diversity count: lineage wf data
|
||||
###############################################
|
||||
#=========================
|
||||
# Data: All lineages or
|
||||
|
@ -59,4 +59,4 @@ lin_count_bp(lin_wf_plot = lin_wf
|
|||
, x_lab_angle = 90
|
||||
, my_xats = 20
|
||||
, y_scale_percent = T
|
||||
, y_label = "SNP diversity")
|
||||
, y_label = "SAV diversity")
|
||||
|
|
|
@ -37,7 +37,7 @@ LP1<- LogoPlotCustomH (plot_df = merged_df3
|
|||
)
|
||||
|
||||
########################################
|
||||
# Logo plot showing nsSNPs by positions
|
||||
# Logo plot showing SAVs by positions
|
||||
# wild-type and mutant aa
|
||||
# script: logoP_snp.R
|
||||
########################################
|
||||
|
@ -48,7 +48,7 @@ LP2<- LogoPlotSnps(plot_df = merged_df3
|
|||
, omit_snp_count = c(0)# can be 0,1, 2, etc.# DD
|
||||
, my_logo_col = "chemistry" #DD
|
||||
, x_lab = "Wild-type position"
|
||||
, y_lab = "nsSNP count"
|
||||
, y_lab = "SAV count"
|
||||
, x_ats = 10
|
||||
, x_tangle = 90
|
||||
, y_ats = 15
|
||||
|
@ -87,7 +87,7 @@ LP3<- LogoPlotMSA(unified_msa
|
|||
, x_axis_offset_filtered = 0.05
|
||||
, y_axis_offset = 0.05
|
||||
#, y_breaks = c(0, 2, 4, 6, 8, 10, 12)
|
||||
, x_lab_mut = "nsSNP-position"
|
||||
, x_lab_mut = "SAV-position"
|
||||
#, y_lab_mut
|
||||
, x_ats = 10
|
||||
, x_tangle = 90
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue