Closed antoine4ucsd closed 8 months ago
Maybe you can put your attempt, the code here? It helps finding a solution
thank you. here;s an example.
# scatter not working (ideally woule like the size ~ Avg and color ~ Pct but fine if only ~ Pct
data|>
group_by(pid)|>
e_charts(Gene,timeline = TRUE) |>
e_scatter(predicted.celltype,Avg) |>
# e_theme("infographic") |>
e_legend(show=T)|>
e_x_axis(axisLabel = list(rotate = 90))
# heatmap working
data|>
group_by(pid)|>
e_charts(Gene,timeline = TRUE) |>
e_heatmap(predicted.celltype, Avg) |>
e_theme("infographic") |>
e_visual_map(Avg)|>
[data.csv](https://github.com/JohnCoene/echarts4r/files/13260061/data.csv)
e_legend(show=T)|>
e_x_axis(axisLabel = list(rotate = 90))
thank you!
Something like this?
data <- read.csv("https://github.com/JohnCoene/echarts4r/files/13260061/data.csv") %>%
mutate(predicted.celltypeNumber = as.numeric(factor(predicted.celltype )) )
data|>
group_by(pid)|>
e_charts(Gene, timeline = TRUE) |>
e_scatter(predicted.celltypeNumber, Avg, bind = predicted.celltype,
itemStyle = list(color = "darkgreen")) |>
e_visual_map(predicted.celltypeNumber, dimension = 1,
inRange = list(color = c("darkgreen", "lightgreen")),
inverse = TRUE) |>
e_legend(show=T)|>
e_x_axis(show = FALSE, axisLabel = list(rotate = 90)) |>
e_y_axis(show = FALSE)
Promising I will play around this code and get back to you Thank you so much !
I looked into the solution proposed by helgasoft with echarty and it does the job very nicely. thank you all for your contributions. this is exciting to see such a great community.
when trying your code, I noticed the y axis were not laeblined. Ideally I would need to discrete (text) label, to be shown.
I assume it starts with something around those lines?
data|>
group_by(pid)|>
e_charts(Gene, timeline = TRUE) |>
e_scatter(predicted.celltypeNumber, Avg, bind = predicted.celltype,
itemStyle = list(color = "darkgreen")) |>
e_visual_map(predicted.celltypeNumber, dimension = 1,
inRange = list(color = c("darkgreen", "lightgreen")),
inverse = TRUE) |>
e_legend(show=T)|>
e_x_axis(show = T, axisLabel = list(rotate = 90)) |>
e_y_axis(show = T,
formatter = htmlwidgets::JS("
function(params){
return('<strong>' + params.name )
}
"))
I wonder if you could help or guide me to where I can learn these 'advanced' options also is there a way to scale the dot size limits? can the size and color be scaled differently? one being the Pct and the other being the Avg?
I have other question but will stop here for now ;-)
thank you!
Your first example did not contain labels. I tried the chart look like that one. But ofcourse I understand what you would like to see. By the way, I could not find the echarty solution you mentioned.
sorry about that. the label would have been predicted.celltype (currenty, the label is the predicted.celltype.number). does that help?
echarty solution is here: https://gist.github.com/helgasoft/e914fe6f4a9ed9407f78e41cb18b3aaa#gistcomment-4750586
echarty is highly customizable. However at least a part of what is done there, can be easlily done by echarts4r as well::
library(dplyr)
library(echarts4r)
data <- read.csv("https://github.com/JohnCoene/echarts4r/files/13260061/data.csv") %>%
mutate(Avg = ifelse(Avg == 0, NA, Avg))
data|>
group_by(pid)|>
e_charts(Gene, timeline = TRUE) |>
e_heatmap(predicted.celltype, Avg) |>
e_add_unnested("symbolSize", Avg) |>
e_visual_map(Avg) |>
e_legend(show=T) |>
e_x_axis(axisLabel = list(rotate= 90))
yes, for the heatmap this is great. was just trying the dot plot with size ~Avg and color ~Pct. not sure if this is too complicated. anyway,thank you!
Sorry for misunderstanding your question(s).
Is this what you are looking for? You can play with the scale to give the bubles te size you prefer:
data <- read.csv("https://github.com/JohnCoene/echarts4r/files/13260061/data.csv") %>%
mutate(Avg = ifelse(Avg == 0, NA, Avg))
data|>
group_by(pid)|>
e_charts(Gene, timeline = TRUE) |>
e_scatter(predicted.celltype, Avg, scale = function(x) scales::rescale(x, to = c(10, 70))) |>
e_visual_map(Avg, dimension = 2) |>
e_x_axis(type = "category", axisLabel = list(rotate = 90)) |>
e_y_axis(type = "category") |>
e_data(data, predicted.celltypeNumber)
I think this is it! I will play around it and confirm asap thank you!
I confirm it works perfectly. Exactly what I was looking for. I need to get more familiar with some of the arguments above but this is great! thank you again
For me the excitement about echarts4r really grew once I realized the possibilities in building and tweaking charts just doesn't stop with the great job that @JohnCoene did with this package. You can do almost anything when getting familiar with https://echarts.apache.org/en/option.html#title itself. Almost any option or argument is reachable from within @JohnCoene's echarts4r functions. Powerful!
cannot agree more. sky is the limit (and my skillset...) thank you all
Hello thank you for your impressive set of tools. I am trying to make a dot heatmap like below (in ggplot2) I tried a scatter plot but does not seem to work with discete y axis? Is there a workaround? thank you!