config: add tile stuff for all targets. Other functions: many rewrites!
This commit is contained in:
parent
a3e5283a9b
commit
0cc7a8fcae
11 changed files with 163 additions and 200 deletions
|
@ -1,9 +1,9 @@
|
|||
# takes a dataframe and returns the same dataframe with two extra columns for colours and position
|
||||
library('viridis')
|
||||
|
||||
generate_distance_colour_map = function(plot_df,
|
||||
xvar_colname = "position",
|
||||
lig_dist_colname = "ligand_distance",
|
||||
#lig_dist_colours = c("green", "yellow", "orange", "red"),
|
||||
lig_dist_colours = c("green", "yellow", "magenta"),
|
||||
debug = TRUE
|
||||
)
|
||||
{
|
||||
|
@ -16,12 +16,9 @@ generate_distance_colour_map = function(plot_df,
|
|||
lig_min = min(round(plot_df[[lig_dist_colname]]), na.rm = T); lig_min
|
||||
lig_max = max(round(plot_df[[lig_dist_colname]]), na.rm = T); lig_max
|
||||
lig_mean = round(mean(round(plot_df[[lig_dist_colname]]), na.rm = T)); lig_mean
|
||||
|
||||
# Create mapping colour key
|
||||
n_colours = length(sort(unique(round(plot_df[[lig_dist_colname]], digits = 0)))); n_colours
|
||||
|
||||
lig_cols = colorRampPalette(lig_dist_colours)(n_colours); lig_cols
|
||||
ligD_valsR = sort(unique(round(plot_df[[lig_dist_colname]], digits = 0))); ligD_valsR
|
||||
n_colours = length(sort(unique(round(plot_df[[lig_dist_colname]], digits = 0))))
|
||||
lig_cols = magma(n_colours, direction=-1)
|
||||
ligD_valsR = sort(unique(round(plot_df[[lig_dist_colname]], digits = 0)))
|
||||
|
||||
if (debug) {
|
||||
length(ligD_valsR)
|
||||
|
@ -43,15 +40,9 @@ generate_distance_colour_map = function(plot_df,
|
|||
names(ligDcolKey)
|
||||
cat("\nSuccessful: Mapping b/w", lig_dist_colname, "and colours")
|
||||
}
|
||||
#-------------------------------------
|
||||
# merge colour key with plot_df
|
||||
#--------------------------------------
|
||||
plot_df = merge(plot_df, ligDcolKey, by = 'lig_distR')
|
||||
|
||||
# plot_df_check = as.data.frame(cbind(position = plot_df[[xvar_colname]]
|
||||
# , ligD = plot_df[[lig_dist_colname]]
|
||||
# , ligDR = plot_df$lig_distR
|
||||
# , ligD_cols = plot_df$ligD_colours))
|
||||
return(plot_df)
|
||||
}
|
||||
|
||||
|
@ -75,9 +66,9 @@ generate_distance_legend = function(plot_df,
|
|||
geom_tile(aes(fill = .data[[lig_dist_colname]])
|
||||
, colour = "white") +
|
||||
scale_fill_gradient2(midpoint = lig_mean
|
||||
, low = "green"
|
||||
, mid = "yellow"
|
||||
, high = "magenta"
|
||||
, low = magma(3, direction=-1)[1]
|
||||
, mid = magma(3, direction=-1)[2]
|
||||
, high = magma(3, direction=-1)[3]
|
||||
, breaks = labels
|
||||
, limits = c(lig_min, lig_max)
|
||||
, labels = labelsD
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue