Ошибка в with (gglayout $ yaxis, if (идентичный (tickmode, "auto")) ticktext else tickvals) [[1]]: индекс вне границ - PullRequest
0 голосов
/ 03 апреля 2020

Я пытаюсь использовать эту библиотеку: https://github.com/swarchal/platetools и немного изменить код, чтобы я мог создавать интерактивные фотографии на пластинах

я добавил следующее: function:

plt384_alt<- function (platemap, size = 5, shape = 22) 
{
  shape <- parse_shape(shape)
  ggplotly(ggplot(data = platemap, aes_string(x = "Column", y = "Row")) + 
    geom_point(data = expand.grid(seq(1, 24), seq(1, 16)), 
               aes_string(x = "Var1", y = "Var2"), color = "grey90", 
               fill = "white", shape = shape, size = size - 2, alpha = 0.1) + 
    geom_point(aes_string(fill = "values"), colour = "gray20", 
               shape = shape, size = size) + coord_fixed(ratio = (24.5/24)/(16.5/16), 
                xlim = c(0.5, 24.5), ylim = c(0.5, 16.5)) + scale_y_reverse(breaks = seq(1,16), labels = LETTERS[1:16]) + 
      scale_x_continuous(position = "top", breaks = seq(1, 24)) + xlab("") + ylab(""))
}

и переходите в свою функцию, в которой они вызывают

raw_map_alt <- function (data, well, plate = 96, ...) 
{
  platemap <- plate_map(data, well)
  if (plate == 96) {
    plt <- plt96(platemap, ...) + theme_bw()
  }
  else if (plate == 384) {
    plt <- plt384_alt(platemap, ...) + theme_bw()
  }
  else if (plate == 1536L) {
    plt <- plt1536(platemap, ...) + theme_bw()
  }
  else {
    stop("Invalid argument for 'plate'. \nOption: 96, 384 or 1536", 
         call. = FALSE)
  }
  return(plt)
}

Но когда я вызываю эту функцию

raw_map_alt(data = df384$vals,
            well = df384$wells,
            plate = 384)

Я получаю следующее ошибка

Ошибка в с (gglayout $ yaxis, if (идентичный (tickmode, "auto")) ticktext else tickvals) [[1]]: нижний индекс вне границ Дополнительно: предупреждающее сообщение: In L $ marker $ color [idx] <- aes2plotly (data, params, "fill") [idx]: </p>

Ошибка в with (gglayout $ yaxis, if (идентичный (tickmode, "auto")) ticktext else tickvals) [[1]]: индекс за пределами границ

Может кто-нибудь помочь мне объяснить, что происходит?

фиктивные данные

wells <- num_to_well(1:384, plate = 384)
vals <- rnorm(length(wells))
df384 <- data.frame(wells, vals)

raw_map_alt(data = df384$vals,
            well = df384$wells,
            plate = 384)

также опубликовать функцию parse_shape, выполненную в platetool

parse_shape <- function(shape) {
    if (is.numeric(shape)) {
        return(shape)
    } else if (is.character(shape)) {
        # R is the worst
        # why is it `tolower` and not `to.lower` or `toLower` ????
        if (tolower(shape) == "circle") {
            return(21L)
        } else if (tolower(shape) == "round") {
            return(21L)
        } else if (tolower(shape) == "square") {
            return(22L)
        } else {
            stop("invalid parameter for shape")
        }
    } else {stop("invalid parameter for shape")}
}

Спасибо

...