Closed FarzanehRah closed 2 years ago
I haven't seen that one before and am not getting that error message with the example code.
Do you have some data and associated script you could provide for context so I can debug further?
Thank you so much for your rapid reply!
data <- read.csv("data.txt", sep ="\t", header = TRUE, stringsAsFactors = FALSE)
data $category_f = factor(data$category, levels=c('regulation','overallProfile_iRNA_Variety','overallProfile_MIR_Variety','overallProfile_SIR_Variety'))
data$Variety_f = factor(data$Variety, levels=c("-", "Manitou", "IsoS8", "Norstar", "IsoW11"))
p <- ggplot(data, aes(x= Clusters, y=TermsDesc, size=Count, color=Pvalue, group=Clusters)) + geom_point(alpha = 0.8) + theme_bw(base_size = 14) + ylab(NULL) + xlab(NULL) +
scale_color_gradient(low = "seagreen", high = "red", space = "Lab", limit = c(0.0, 0.06)) + scale_size(range = c(1,7), breaks = c(2,20,40,60,80,100,119)) +
theme(legend.key=element_blank(),
axis.text.x = element_text(colour = "black", size = 9, angle = 90, vjust = 0.3, hjust = 1, face = "bold"),
axis.text.y = element_text(colour = "black", size = 12, face = "bold"),
legend.text = element_text(size = 10, colour ="black"),
legend.title = element_text(size = 11), panel.background = element_blank(),
panel.border = element_rect(colour = "black", fill = NA, size = 1),
legend.position = "right", panel.grid.major.y = element_line(colour = "grey"))+
facet_grid(enrichment ~ category_f + Variety_f, scales = "free", space = "free",)+
theme(strip.text.y = element_text(size = 10, angle = 45,face = "bold")) + theme(strip.text.x = element_text(size = 10,angle = 90, face = "bold")) + labs(title="Enrichment analysis") + theme(plot.title = element_text(face="bold", size=14))
(p2 <- ggNestedBarChart(p))
You're welcome, and this is helpful!
I took a look at the example, and the main issue is this package is only designed to work with bar plots that look more like p1 in the example using facet_wrap
.
By comparison the plot for p
based on the code you provided involves points, uses facet_grid
, and seems to use a two-level grouping variable (i.e., grouping on both the x- and y-axis of the plot, which is another feature ggNestedBarPlot wasn't designed to do).
I played around with the code briefly to see if there is a way to adapt it to your p
plot, but unfortunately the underlying logic in the ggNestedBarChart
function would require a complete rewrite to make it work with this input, and I'm ultimately not entirely clear on what the output ought to look like either.
Sorry this isn't more helpful!
Thank you so much for your explanation!
You're welcome! If I have ever have time to come back to this package to flesh it out, I'll try to cover more potential use cases. Thanks again for reaching out with questions!
Hello, when I use :
(p2 <- ggNestedBarChart(p))
I get this error:Error during wrapup: subscript out of bounds Error: no more error handlers available (recursive errors?); invoking 'abort' restart
. Any solution? Thank you