various stuff
This commit is contained in:
parent
5cbaef3d36
commit
415d05ab6e
3 changed files with 99 additions and 76 deletions
|
@ -34,7 +34,7 @@ ColourPalleteMulti = function(df, group, subgroup){
|
||||||
# above function
|
# above function
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
bp_stability_hmap <- function(plotdf = merged_df3
|
bp_stability_hmap <- function(plot_df = merged_df3
|
||||||
, xvar_colname = "position"
|
, xvar_colname = "position"
|
||||||
, yvar_colname = 'duet_scaled' #FIXME: temp, remove
|
, yvar_colname = 'duet_scaled' #FIXME: temp, remove
|
||||||
#, bar_col_colname = "group"
|
#, bar_col_colname = "group"
|
||||||
|
@ -68,30 +68,30 @@ bp_stability_hmap <- function(plotdf = merged_df3
|
||||||
# Build data with colours
|
# Build data with colours
|
||||||
# ~ ligand distance
|
# ~ ligand distance
|
||||||
#=========================
|
#=========================
|
||||||
plotdf = generate_distance_colour_map(plotdf, debug=TRUE)
|
plot_df = generate_distance_colour_map(plot_df, debug=TRUE)
|
||||||
|
|
||||||
# order the df by position and ensure it is a factor
|
# order the df by position and ensure it is a factor
|
||||||
plotdf = plotdf[order(plotdf[[xvar_colname]]), ]
|
plot_df = plot_df[order(plot_df[[xvar_colname]]), ]
|
||||||
plotdf[[xvar_colname]] = factor(plotdf[[xvar_colname]])
|
plot_df[[xvar_colname]] = factor(plot_df[[xvar_colname]])
|
||||||
|
|
||||||
#cat("\nSneak peak:\n")
|
#cat("\nSneak peak:\n")
|
||||||
head(data.frame( plotdf[[xvar_colname]], plotdf[[stability_colname]] ) )
|
head(data.frame( plot_df[[xvar_colname]], plot_df[[stability_colname]] ) )
|
||||||
|
|
||||||
# stability values isolated to help with generating column called: 'group'
|
# stability values isolated to help with generating column called: 'group'
|
||||||
my_grp = plotdf[[stability_colname]]
|
my_grp = plot_df[[stability_colname]]
|
||||||
cat( "\nLength of nsSNPs:", length(my_grp)
|
cat( "\nLength of nsSNPs:", length(my_grp)
|
||||||
, "\nLength of unique values for nsSNPs:", length(unique(my_grp)) )
|
, "\nLength of unique values for nsSNPs:", length(unique(my_grp)) )
|
||||||
|
|
||||||
# Add col: 'group'
|
# Add col: 'group'
|
||||||
plotdf$group = paste0(plotdf[[stability_outcome_colname]], "_", my_grp, sep = "")
|
plot_df$group = paste0(plot_df[[stability_outcome_colname]], "_", my_grp, sep = "")
|
||||||
|
|
||||||
# check unique values in normalised data
|
# check unique values in normalised data
|
||||||
cat("\nNo. of unique values in", stability_colname, "no rounding:"
|
cat("\nNo. of unique values in", stability_colname, "no rounding:"
|
||||||
, length(unique(plotdf[[stability_colname]])))
|
, length(unique(plot_df[[stability_colname]])))
|
||||||
|
|
||||||
# Call the function to create the palette based on the group defined above
|
# Call the function to create the palette based on the group defined above
|
||||||
#subcols_ps
|
#subcols_ps
|
||||||
subcols_bp_hmap = ColourPalleteMulti(plotdf, stability_outcome_colname, stability_colname)
|
subcols_bp_hmap = ColourPalleteMulti(plot_df, stability_outcome_colname, stability_colname)
|
||||||
|
|
||||||
cat("\nNo. of sub colours generated:", length(subcols_bp_hmap))
|
cat("\nNo. of sub colours generated:", length(subcols_bp_hmap))
|
||||||
|
|
||||||
|
@ -100,40 +100,54 @@ bp_stability_hmap <- function(plotdf = merged_df3
|
||||||
# Generate the subcols barplot
|
# Generate the subcols barplot
|
||||||
#-------------------------------
|
#-------------------------------
|
||||||
cowplot::plot_grid(
|
cowplot::plot_grid(
|
||||||
ggplot(plotdf, aes_string(x = xvar_colname
|
ggplot(plot_df, aes_string(x = xvar_colname
|
||||||
# , ordered = T)
|
# , ordered = T)
|
||||||
)) +
|
)) +
|
||||||
geom_bar(aes(fill = group)
|
geom_bar(aes(fill = group)
|
||||||
, colour = "grey") +
|
, colour = "grey") +
|
||||||
|
|
||||||
scale_fill_manual( values = subcols_bp_hmap
|
scale_fill_manual( values = subcols_bp_hmap
|
||||||
, guide = "none") +
|
, guide = "none") +
|
||||||
|
# scale_x_discrete("Position", labels=factor(plot_df$position)) +
|
||||||
|
|
||||||
theme( axis.text.x = element_text(size = my_xaxls
|
theme(
|
||||||
, angle = 90
|
axis.text.x = element_text(size = my_xaxls
|
||||||
, hjust = 1
|
, angle = 90
|
||||||
, vjust = 0.4)
|
, hjust = 1
|
||||||
, axis.text.y = element_text(size = my_yaxls
|
, vjust = 0.4)
|
||||||
, angle = 0
|
, axis.text.y = element_text(size = my_yaxls
|
||||||
, hjust = 1
|
, angle = 0
|
||||||
, vjust = 0)
|
, hjust = 1
|
||||||
, axis.title.x = element_text(size = my_xaxts)
|
, vjust = 0)
|
||||||
, axis.title.y = element_text(size = my_yaxts )
|
, axis.title.x = element_blank()
|
||||||
, plot.title = element_text(size = my_pts
|
#, axis.title.x = element_text(size = my_xaxts)
|
||||||
, hjust = 0.5)) +
|
, axis.title.y = element_text(size = my_yaxts )
|
||||||
|
, plot.title = element_text(size = my_pts
|
||||||
|
, hjust = 0.5)) +
|
||||||
|
|
||||||
labs(title = p_title
|
labs(title = p_title
|
||||||
, x = my_xlab
|
, x = my_xlab
|
||||||
, y = my_ylab),
|
, y = my_ylab),
|
||||||
geom_tile(aes(, tpos0 # heat-mapped distance tiles along the bot
|
NULL,
|
||||||
, width = tW0
|
ggplot(plot_df,
|
||||||
, height = tH0)
|
aes(x=factor(position), # THIS STUPID FUCKING FACTOR THING
|
||||||
, fill = plotdf$ligD_colours
|
)
|
||||||
, colour = plotdf$ligD_colours
|
) +
|
||||||
, linetype = "blank"), #end of distance-heat-bar
|
geom_tile(aes(y=0),
|
||||||
generate_distance_legend(plotdf),
|
fill=plot_df$ligD_colours) +
|
||||||
ncol = 2,
|
scale_x_discrete("Position", labels=factor(plot_df$position)) +
|
||||||
#align = "hv",
|
theme_nothing() +
|
||||||
rel_widths = c(9/10, 0.4/10)
|
theme(plot.background = element_rect(fill = "transparent", colour=NA),
|
||||||
|
plot.margin = margin(t=0,b=0)) +
|
||||||
|
labs(x = NULL, y = NULL), #end of distance-heat-bar
|
||||||
|
NULL,
|
||||||
|
position_annotation(plot_df),
|
||||||
|
#generate_distance_legend(plot_df),
|
||||||
|
ncol = 1,
|
||||||
|
align = "v",
|
||||||
|
rel_heights = c(10,-0.1,1,-0.1,1)
|
||||||
|
#rel_widths = c(9/10, 0.4/10)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
bp_stability_hmap(small_df3)
|
||||||
|
|
|
@ -250,64 +250,73 @@ LogoPlotSnps <- function(plot_df
|
||||||
, axis.title.y = element_text(size = y_tts
|
, axis.title.y = element_text(size = y_tts
|
||||||
, colour = ytt_col)
|
, colour = ytt_col)
|
||||||
|
|
||||||
, plot.background = element_rect(fill = theme_bgc)
|
, plot.background = element_rect(fill = theme_bgc, colour=NA)
|
||||||
)
|
),
|
||||||
,ggseqlogo(tab_wt
|
ggseqlogo(tab_wt
|
||||||
, method = 'custom'
|
, method = 'custom'
|
||||||
, col_scheme = my_logo_col
|
, col_scheme = my_logo_col
|
||||||
, seq_type = 'aa') +
|
, seq_type = 'aa') +
|
||||||
scale_x_continuous(breaks = 1:ncol(tab_wt)
|
scale_x_continuous(breaks = 1:ncol(tab_wt)
|
||||||
, expand = c(0.01,0)
|
, expand = c(0.01,0)
|
||||||
, labels = colnames(tab_wt))+
|
, labels = as.factor(colnames(tab_wt))) +
|
||||||
theme(text = element_text(family="FreeSans")
|
theme(text = element_text(family="FreeSans")
|
||||||
, legend.position = "none"
|
, legend.position = "none"
|
||||||
, axis.text.x = element_blank()
|
, axis.text.x = element_blank()
|
||||||
, axis.text.y = element_blank()
|
, axis.text.y = element_blank()
|
||||||
, axis.title.x = element_blank()
|
, axis.title.x = element_blank()
|
||||||
, axis.title.y = element_blank()
|
, axis.title.y = element_blank()
|
||||||
, plot.background = element_rect(fill = theme_bgc)
|
, plot.background = element_rect(fill = theme_bgc, colour=NA)
|
||||||
) +
|
) +
|
||||||
labs(x=NULL, y=NULL)
|
labs(x=NULL, y=NULL),
|
||||||
,
|
ggplot(
|
||||||
ggplot(data=unique_colour_map2, aes(
|
data=unique_colour_map2,
|
||||||
x=factor(position), 0 # heat-mapped distance tiles along the bot
|
aes(
|
||||||
, fill = position
|
x=factor(position), 0 # heat-mapped distance tiles along the bot
|
||||||
, colour = position
|
, fill = position
|
||||||
, linetype = "blank"
|
, colour = position
|
||||||
)
|
, linetype = "blank"
|
||||||
|
)
|
||||||
) +
|
) +
|
||||||
geom_tile() +
|
geom_tile() +
|
||||||
theme(axis.text.x = element_text(size = x_ats
|
theme(
|
||||||
, angle = x_tangle
|
axis.text.x = element_blank()
|
||||||
, hjust = 1
|
, axis.ticks.x = element_blank()
|
||||||
, vjust = 0.4
|
# axis.text.x = element_text(size = x_ats
|
||||||
, colour = xfont_bgc)
|
# , angle = x_tangle
|
||||||
, axis.text.y = element_blank()
|
# , hjust = 1
|
||||||
, axis.ticks.y = element_blank()
|
# , vjust = 0.4
|
||||||
, axis.title.x = element_text(size = x_tts
|
# , colour = xfont_bgc)
|
||||||
, colour = xtt_col)
|
, axis.text.y = element_blank()
|
||||||
, axis.title.y = element_text(size = y_tts
|
, axis.ticks.y = element_blank()
|
||||||
, colour = ytt_col)
|
, axis.title.x = element_blank()
|
||||||
, legend.title = element_text(size = leg_tts
|
|
||||||
, colour = ytt_col)
|
|
||||||
, legend.text = element_text(size = leg_ts)
|
|
||||||
|
|
||||||
, legend.position = leg_pos
|
# , axis.title.x = element_text(size = x_tts
|
||||||
, legend.direction = leg_dir
|
# , colour = xtt_col)
|
||||||
, plot.background = element_rect(fill = theme_bgc)
|
# , axis.title.y = element_text(size = y_tts
|
||||||
, plot.margin = margin(t=0)
|
# , colour = ytt_col)
|
||||||
, panel.grid=element_blank()
|
# , legend.title = element_text(size = leg_tts
|
||||||
, panel.background = element_rect(fill = theme_bgc)
|
# , colour = ytt_col)
|
||||||
|
, legend.text = element_text(size = leg_ts)
|
||||||
|
|
||||||
|
, legend.position = leg_pos
|
||||||
|
, legend.direction = leg_dir
|
||||||
|
, plot.background = element_rect(fill = theme_bgc, colour=NA)
|
||||||
|
, plot.margin = margin(t=0)
|
||||||
|
, panel.grid=element_blank()
|
||||||
|
, panel.background = element_rect(fill = theme_bgc, colour=NA)
|
||||||
) +
|
) +
|
||||||
scale_x_discrete(x_lab, labels=factor(unique_colour_map$position)) +
|
scale_x_discrete(x_lab, labels=factor(unique_colour_map$position)) +
|
||||||
scale_color_manual(values=unique_colour_map$ligD_colours) +
|
scale_color_manual(values=unique_colour_map$ligD_colours) +
|
||||||
scale_fill_manual(values=unique_colour_map$ligD_colours) +
|
scale_fill_manual(values=unique_colour_map$ligD_colours) +
|
||||||
labs(y = NULL)
|
labs(y = NULL)
|
||||||
, nrow = 3
|
, NULL
|
||||||
|
, position_annotation(plot_df, bg=theme_bgc)
|
||||||
|
, ncol=1
|
||||||
, align = "v"
|
, align = "v"
|
||||||
, rel_heights = c(7/10, 2/7, 1/7))
|
, rel_heights = c(7/10, 2/7,1/7, -0.1, 0.5/7))
|
||||||
#------------------
|
#------------------
|
||||||
# Wild logo plot
|
# Wild logo plot
|
||||||
#------------------
|
#------------------
|
||||||
}
|
}
|
||||||
#LogoPlotSnps(mutable_df3)
|
|
||||||
|
#LogoPlotSnps(small_df3)
|
||||||
|
|
|
@ -27,7 +27,7 @@ wideP_consurf2 <- function(plot_df
|
||||||
, lower_EB_colname = "consurf_ci_lower"
|
, lower_EB_colname = "consurf_ci_lower"
|
||||||
|
|
||||||
, plot_type = "point" # default is point
|
, plot_type = "point" # default is point
|
||||||
, point_colours
|
, point_colours = consurf_bp_colours
|
||||||
, p_size = 2
|
, p_size = 2
|
||||||
, leg_title1 = ""
|
, leg_title1 = ""
|
||||||
, leg_labels = c("0": "Insufficient Data"
|
, leg_labels = c("0": "Insufficient Data"
|
||||||
|
@ -321,7 +321,7 @@ wideP_consurf2 <- function(plot_df
|
||||||
g1_leg = g1_leg + geom_bar(aes_string(fill = sprintf("factor(%s)"
|
g1_leg = g1_leg + geom_bar(aes_string(fill = sprintf("factor(%s)"
|
||||||
, yvar_colourN_colname)))
|
, yvar_colourN_colname)))
|
||||||
|
|
||||||
g1_leg = g1_leg + scale_fill_manual(values = consurf_palette1 , name = leg_title1)
|
g1_leg = g1_leg + scale_fill_manual(values = consurf_bp_colours , name = leg_title1)
|
||||||
g1_leg
|
g1_leg
|
||||||
|
|
||||||
legend1 = get_legend(g1_leg)
|
legend1 = get_legend(g1_leg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue