But again that would be manual, I have 400 samples (400 Plots) like this divided into 8 batches and do this manually would take a lot of time.
Hi Everyone
I have written function that make coverage plots iteratively and saves it in an object (here l). Is there a way to convert list of plotly plots into an HTML output where we have 6 plots in a single row and so on. I want these plots to be interactive because these are coverage plots for aligned bam files for around 20 samples and sometime we intend to inspect regions of dropout by zooming in.
l <- lapply(cov$group, function(x){
g <-ggplot(df[[x]]) +
geom_rect(aes(xmin = V2, xmax = V3, ymin = 0, ymax = V4), col="blue", fill="blue")+geom_hline(aes(yintercept = 20))+
theme_minimal()+theme(axis.text=element_text(size=17),
axis.title=element_text(size=17,face="bold"))+xlab(paste(x, "Cov:",percent(round(cov[cov$group==x,]$coverage)/100)))
ggplotly(g)
})
I am aware about subplot but it doesn't accept list of plots like wrap_plots. However wrap_plots doesn't wrap HTML widgets.
I came across these posts but I am not HTML expert so it's kinda hard for me how can I use list of plots as an input:
2 answers
I would just follow what they did in this link of yours: https://stackoverflow.com/questions/65606653/r-saving-multiple-html-widgets-together
wiget1 <- ggplotly(g)
or
wiget1 <- l[[1]]
and make a bunch of wigets just like the answer to that question. you may have to figure out the how they are stored via lapply but if in doubt do it manually in a for loop. you probably can do it as below:
doc <- htmltools::tagList(
div(l[[1], style = "float:left;width:50%;"),
div(l[[2]],style = "float:left;width:50%;"),
div(l[[3]], style = "float:left;width:50%;"),
)
## etc...
htmltools::save_html(html = doc, file = "C://Users//Me//Desktop//widgets.html")
maybe try:
doc <- htmltools::tagList(lapply(l,function(x) div(x, style = "float:left;width:50%;")))
htmltools::save_html(html = doc, file = "widgets.html")
Have you tried making an html Markdown document?
Log in to answer this question.