I am new to plotly, but using this platform as my aim is to produce a plot with 8 different overlaying plots with multiple y axis. I am reviewing genotype data and producing a plot of -log10(p) against BP. My practice code works for the image with reducing opacity of non-causal variants. However as soon as I increase the number of results in my dataset >10 rows the code fails to work? Is there a reason for this in the package. Thank you kindly for advice
test data code;
log <- c(0.28777133, 0.540758335, 0.331055266, 1.068186296, 0.075669015, 0.042105513, 20.156767222, 6.144238628, 5.752272167)
opacity <- c(0.2,0.2,0.2,0.2,0.2,0.2,1,1,1)
data <- data.frame(BP, log, opacity)
data$highlight <- row.names(data) %in% c("7", "8", "9") ###highlight possible causal variants in practice dataset
### Display plot
fig <- plot_ly(width = 1200, height = 600)
fig <- fig %>% add_trace(data= data,
x = ~BP,
y = ~log,
color = ~highlight,
name = "",
mode = "markers",
type = "scatter",
marker = list(size = 8),
colors = c("purple", "red"),
opacity=opacity)
fig ```
# works with practice data
``` BP <- c(117068919, 117072803, 117074604, 117075231, 117076684, 117077326, 117078553, 117080817, 117083725, 117086188, 117086549, 117087412 )
log <- c(0.28777133, 0.540758335, 0.331055266, 1.068186296, 0.075669015, 0.042105513, 20.156767222, 6.144238628, 5.752272167, 0.042201225, 0.460923901, 0.450016389 )
data <- data.frame(BP, log)
data$highlight <- row.names(data) %in% c("1", "2", "3", "4", "5")
data$opacity[data$highlight==F]<-0.2
data$opacity[data$highlight==T]<-1
table(data$highlight)
data2<-data[rev(order(data$opacity)),]
data2<-data2[1:10,]
fig <- plot_ly(width = 1200, height = 600)
fig <- fig %>% add_trace(data= Crohns2,
x = ~BP,
y = ~log,
color = ~highlight,
name = "",
mode = "markers",
type = "scatter",
marker = list(size = 8),
colors = c("purple", "red"),
opacity=opacity)
fig ### doesnt work with > 10 rows
data3<-data[rev(order(data$opacity)),]
data3<-data3[1:9,]
fig <- plot_ly(width = 1200, height = 600)
fig <- fig %>% add_trace(data= data3,
x = ~BP,
y = ~log,
color = ~highlight,
name = "",
mode = "markers",
type = "scatter",
marker = list(size = 8),
colors = c("purple", "red"),
opacity=opacity)
fig ``` ## does work with 9 rows