This is a test version of Biostars. For the public version, visit https://www.biostars.org.
ANOVA results viz from ssGSEA

Hi there

I did an ANOVA test for some enriched pathways resulting from ssGSEA. Now, I have some issues regarding the visualization of the results. Also, I am not sure how I can set a threshold to visualize only statistically significant results?

enter image description here

visualization ssgsea anova

1 answer

If you sort by p.value you can head the dataframe to the desired number of bars; or use FDR to have a fixed threshold. Similarly you can make a barplot of pathway against log-pvalue or log-FDR; and potentially color by the significance of another group. Like this (not tested):

dat$fdr <- p.adjust(dat$p.value)
dat$fdr.EMT <- p.adjust(dat$EMT_like_cellsvCAF.pvalue)
dat$signif.EMT <- ifelse(dat$fdr.EMT < 0.05, 'EMTvsCAF-signif', 'NS')
dat$pathway <- rownames(dat)
dat <- dat[order(dat$p.value, decreasing=False),]
desired.num.bars <- 15
ggplot(dat[1:desired.num.bars,]) + geom_bar(aes(x=pathway, y=-log10(fdr), fill=signif.EMT), stat='identity')

Thank you for your quick response LChart

I could follow the code. However, some problems I faced. For example, what is NS? it means non-significant? If so, I do not want to be this in the results. Also, I got an error when I was running the last code for ggplot:

"Error in geom_bar(): ! Problem while computing stat. ℹ Error occurred in the 1st layer. Caused by error in setup_params(): ! stat_count() must only have an x or y aesthetic. Run rlang::last_error() to see where the error occurred."

I forgot the stat='identity' in geom_bar

Hi LChart Thank you for your reply. SO, I did not see your response which is so weird. I added the stat = 'identity' into the geom_bar but still get the error:

ggplot(output[1:desired.num.bars,]) + geom_bar(aes(x=pathways, y=-log10(fdr),
                                               fill=signif.EMT,
                                               stat = 'identity'))



Error in `geom_bar()`:

! Problem while computing stat. ℹ Error occurred in the 1st layer. Caused by error in setup_params(): ! stat_count() must only have an x or y aesthetic. Run rlang::last_trace() to see where the error occurred. Warning message: In geom_bar(aes(x = pathways, y = -log10(fdr), fill = signif.EMT, : Ignoring unknown aesthetics: stat

stat is an argument to geom_bar, not to aes (move it outside the parenthesis)

Log in to answer this question.