fix many plot functions to stop them using the "g=ggplot()" pattern,
which annoyingly throws away lots of useful data that RShiny needs for clickable plots. Also split the "flame bar" for ligand distance out into separate functions in generate_distance_colour_map.R. This can now be easily incorporated into any "wide" graph showing all positions.
This commit is contained in:
parent
e498d46f8b
commit
bdbc97c40a
8 changed files with 1323 additions and 725 deletions
|
@ -16,7 +16,7 @@ lineage_distP <- function(plotdf
|
|||
, all_lineages = F
|
||||
, use_lineages = c("L1", "L2", "L3", "L4")
|
||||
, with_facet = F
|
||||
, facet_wrap_var = ""
|
||||
, facet_wrap_var = "" # FIXME: document what this is for
|
||||
, fill_categ = "mutation_info_labels"
|
||||
, fill_categ_cols = c("#E69F00", "#999999")
|
||||
, my_ats = 15 # axis text size
|
||||
|
@ -30,46 +30,44 @@ lineage_distP <- function(plotdf
|
|||
, leg_label = "")
|
||||
|
||||
{
|
||||
|
||||
if(!all_lineages){
|
||||
plotdf = plotdf[plotdf[[y_axis]]%in%use_lineages,]
|
||||
}
|
||||
|
||||
LinDistP = ggplot(plotdf, aes_string(x = x_axis
|
||||
, y = y_axis))+
|
||||
|
||||
geom_density_ridges(aes_string(fill = fill_categ)
|
||||
, scale = 3
|
||||
, size = 0.3
|
||||
, alpha = 0.8) +
|
||||
scale_x_continuous(expand = c(0.01, 0.01)) +
|
||||
#coord_cartesian( xlim = c(-1, 1)) +
|
||||
scale_fill_manual(values = fill_categ_cols) +
|
||||
theme(axis.text.x = element_text(size = my_ats
|
||||
, angle = 90
|
||||
, hjust = 1
|
||||
, vjust = 0.4)
|
||||
, axis.text.y = element_text(size = my_ats)
|
||||
, axis.title.x = element_text(size = my_ats)
|
||||
, axis.title.y = element_blank()
|
||||
, strip.text = element_text(size = my_strip_ts)
|
||||
, legend.text = element_text(size = my_leg_ts)
|
||||
, legend.title = element_text(size = my_leg_title)
|
||||
, legend.position = c(0.8, 0.9)) +
|
||||
labs(x = x_lab
|
||||
, fill = leg_label)
|
||||
|
||||
if (with_facet){
|
||||
|
||||
# used reformulate or make as formula
|
||||
#fwv = reformulate(facet_wrap_var)
|
||||
fwv = as.formula(paste0("~", facet_wrap_var))
|
||||
|
||||
LinDistP = LinDistP +
|
||||
if(!all_lineages){
|
||||
plotdf = plotdf[plotdf[[y_axis]]%in%use_lineages,]
|
||||
}
|
||||
|
||||
ggplot(plotdf, aes_string(x = x_axis
|
||||
, y = y_axis))+
|
||||
|
||||
geom_density_ridges(aes_string(fill = fill_categ)
|
||||
, scale = 3
|
||||
, size = 0.3
|
||||
, alpha = 0.8) +
|
||||
scale_x_continuous(expand = c(0.01, 0.01)) +
|
||||
#coord_cartesian( xlim = c(-1, 1)) +
|
||||
scale_fill_manual(values = fill_categ_cols) +
|
||||
theme(axis.text.x = element_text(size = my_ats
|
||||
, angle = 90
|
||||
, hjust = 1
|
||||
, vjust = 0.4)
|
||||
, axis.text.y = element_text(size = my_ats)
|
||||
, axis.title.x = element_text(size = my_ats)
|
||||
, axis.title.y = element_blank()
|
||||
, strip.text = element_text(size = my_strip_ts)
|
||||
, legend.text = element_text(size = my_leg_ts)
|
||||
, legend.title = element_text(size = my_leg_title)
|
||||
, legend.position = c(0.8, 0.9)) +
|
||||
labs(x = x_lab
|
||||
, fill = leg_label) +
|
||||
|
||||
# FIXME: This didn't work BEFORE i fixed the ggplot() assignment thing!!!
|
||||
if (with_facet){
|
||||
|
||||
# used reformulate or make as formula
|
||||
#fwv = reformulate(facet_wrap_var)
|
||||
fwv = as.formula(paste0("~", facet_wrap_var))
|
||||
|
||||
facet_wrap(fwv) +
|
||||
theme(legend.position = leg_pos_wf
|
||||
, legend.direction = leg_dir_wf)
|
||||
}
|
||||
|
||||
return(LinDistP)
|
||||
theme(legend.position = leg_pos_wf
|
||||
, legend.direction = leg_dir_wf)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue