I have made a bit of progress. Looking at the error:
Error in grDevices::col2rgb(colour, TRUE) : invalid color name 'A'
I looked at the traceback and found the line alpha(coords$colour_inner, coords$alpha) which I had altered in my code relative to geom_point(). Looking at the alpha() function it calls grDevices::col2rgb() so I think this accounts for the error.
I can reproduce the colours observed by @joels using alpha() and the observation that the colours are different to the ones ggplot2 uses by default was astute.
library(tidyverse)
alpha(sort(unique(mtcars$carb)), 1) ==
palette()[sort(unique(mtcars$carb))] %>% # This just converts the strings to hex
col2rgb() %>%
BBmisc::convertColsToList() %>%
map(~ rgb(.x[1], .x[2], .x[3], 255, maxColorValue=255)) %>%
unlist()
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE
Created on 2018-04-02 by the reprex package (v0.2.0).
The problem therefore lies in what is being passed to alpha() which is coords. If I look inside coords I see it is a dataframe where the data is transformed by what I believe is the transform() function from base mediated by the panel_parems object. Significantly, aes values called "colour" get converted into hex values in geom_point() but not my "colour_inner" in geom_point_en(). Instead I get the aforementioned different set of colours from the `alpha()' call if the values are numeric and the error if they are not. This code demonstrates this:
library(ggplot2)
# Test geom_point
GeomPoint_test <- ggproto("GeomPoint_test", Geom,
required_aes = c("x", "y"),
non_missing_aes = c("size", "shape", "colour"),
default_aes = aes(
shape = 19, colour = "black", size = 1.5, fill = NA,
alpha = NA, stroke = 0.5
),
draw_panel = function(data, panel_params, coord, na.rm = FALSE) {
coords <- coord$transform(data, panel_params)
print(head(coords))
},
draw_key = draw_key_point
)
geom_point_test <- function(mapping = NULL, data = NULL,
stat = "identity", position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE) {
layer(
data = data,
mapping = mapping,
stat = stat,
geom = GeomPoint_test,
position = position,
show.legend = show.legend,
inherit.aes = inherit.aes,
params = list(
na.rm = na.rm,
...
)
)
}
# Test geom_point_en
GeomPointEn_test <- ggproto("GeomPointEn_test", Geom,
required_aes = c("x", "y"),
non_missing_aes = c("size", "shape", "colour_inner", "colour_outer", "encirc"),
default_aes = aes(
shape = 19, colour_inner = "black", colour_outer = "red",
size = 1.5, fill = NA, alpha = NA, stroke = 0.5, encric = NA
),
draw_key = draw_key_point,
draw_panel = function(data, panel_params, coord, na.rm = FALSE) {
coords <- coord$transform(data, panel_params)
print(head(coords))
}
)
geom_point_en_test <- function(mapping = NULL, data = NULL,
stat = "identity", position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE) {
layer(
data = data,
mapping = mapping,
stat = stat,
geom = GeomPointEn_test,
position = position,
show.legend = show.legend,
inherit.aes = inherit.aes,
params = list(
na.rm = na.rm,
...
)
)
}
# Coords output for geom_point() with numeric column
ggplot(mtcars, aes(wt, mpg, colour = carb)) +
geom_point_test()
#> colour x y PANEL group shape size fill alpha stroke
#> 1 #2E618B 0.3027707 0.4555126 1 -1 19 1.5 NA NA 0.5
#> 2 #2E618B 0.3620441 0.4555126 1 -1 19 1.5 NA NA 0.5
#> 3 #132B43 0.2330374 0.5251451 1 -1 19 1.5 NA NA 0.5
#> 4 #132B43 0.4410753 0.4709865 1 -1 19 1.5 NA NA 0.5
#> 5 #1C3C5A 0.4933753 0.3665377 1 -1 19 1.5 NA NA 0.5
#> 6 #132B43 0.4980242 0.3433269 1 -1 19 1.5 NA NA 0.5
#> Error in gList(structure(list(name = "grill.gTree.13", gp = NULL, vp = NULL, : only 'grobs' allowed in "gList"
# Coords output for geom_point() with non-numeric column
ggplot(mtcars, aes(wt, mpg, colour = factor(carb))) +
geom_point_test()
#> colour x y PANEL group shape size fill alpha stroke
#> 1 #00BFC4 0.3027707 0.4555126 1 4 19 1.5 NA NA 0.5
#> 2 #00BFC4 0.3620441 0.4555126 1 4 19 1.5 NA NA 0.5
#> 3 #F8766D 0.2330374 0.5251451 1 1 19 1.5 NA NA 0.5
#> 4 #F8766D 0.4410753 0.4709865 1 1 19 1.5 NA NA 0.5
#> 5 #B79F00 0.4933753 0.3665377 1 2 19 1.5 NA NA 0.5
#> 6 #F8766D 0.4980242 0.3433269 1 1 19 1.5 NA NA 0.5
#> Error in gList(structure(list(name = "grill.gTree.27", gp = NULL, vp = NULL, : only 'grobs' allowed in "gList"
# Coords output for geom_point_en() with numeric column
ggplot(mtcars, aes(wt, mpg, colour_inner = carb)) +
geom_point_en_test()
#> x y colour_inner PANEL group shape colour_outer size
#> 1 0.3027707 0.4555126 4 1 -1 19 red 1.5
#> 2 0.3620441 0.4555126 4 1 -1 19 red 1.5
#> 3 0.2330374 0.5251451 1 1 -1 19 red 1.5
#> 4 0.4410753 0.4709865 1 1 -1 19 red 1.5
#> 5 0.4933753 0.3665377 2 1 -1 19 red 1.5
#> 6 0.4980242 0.3433269 1 1 -1 19 red 1.5
#> fill alpha stroke encric
#> 1 NA NA 0.5 NA
#> 2 NA NA 0.5 NA
#> 3 NA NA 0.5 NA
#> 4 NA NA 0.5 NA
#> 5 NA NA 0.5 NA
#> 6 NA NA 0.5 NA
#> Error in gList(structure(list(name = "grill.gTree.41", gp = NULL, vp = NULL, : only 'grobs' allowed in "gList"
# Coords output for geom_point_en() with non-numeric column
ggplot(mtcars, aes(wt, mpg, colour_inner = factor(carb))) +
geom_point_en_test()
#> x y colour_inner PANEL group shape colour_outer size
#> 1 0.3027707 0.4555126 4 1 4 19 red 1.5
#> 2 0.3620441 0.4555126 4 1 4 19 red 1.5
#> 3 0.2330374 0.5251451 1 1 1 19 red 1.5
#> 4 0.4410753 0.4709865 1 1 1 19 red 1.5
#> 5 0.4933753 0.3665377 2 1 2 19 red 1.5
#> 6 0.4980242 0.3433269 1 1 1 19 red 1.5
#> fill alpha stroke encric
#> 1 NA NA 0.5 NA
#> 2 NA NA 0.5 NA
#> 3 NA NA 0.5 NA
#> 4 NA NA 0.5 NA
#> 5 NA NA 0.5 NA
#> 6 NA NA 0.5 NA
#> Error in gList(structure(list(name = "grill.gTree.55", gp = NULL, vp = NULL, : only 'grobs' allowed in "gList"

Created on 2018-04-02 by the reprex package (v0.2.0).
I have not yet worked how this is occurring. The panel_parems object is a complicated list and the docs say "You should consider this an opaque data structure: don't look inside it". I have and found nothing that might transform colour values. I am also not convinced that I have the right transform() function and that there might be some internal ggplot2 stuff I havn't found yet occurring.