ococrook / bandle

An R package for Bayesian analysis of differential localisation experiments
https://ococrook.github.io/bandle/
5 stars 1 forks source link

mcmc_plot_probs error #7

Closed JosieAC closed 3 years ago

JosieAC commented 3 years ago

The mcmc_plot_probs gives following error:

Warning messages:
1: In depth(vp) : reached elapsed time limit
2: Computation failed in `stat_ydensity()`:
'weights' must all be finite 

Think line 38-39 is the issue - comma and bracket in wrong place(?): https://github.com/ococrook/bandle/blob/c727b343af955565f9153533fd31248bcb05ccb3/R/bandle-plots.R#L38

The below edit seems to work for me (where params = bandleres, fname = "Q14147") :

ch <- chains(bandleres)[[1]]
dfr <- as.data.frame(ch@nicheProb[[1]]["Q14147", , ])
dfr_long <- data.frame(Organelle = rep(names(dfr), each = nrow(dfr)),
                       Probability = unlist(dfr, use.names = FALSE),
                       row.names = NULL,
                       stringsAsFactors = FALSE)
gg2 <- ggplot(dfr_long,
              aes(Organelle, Probability),
                  width = Probability) +
  geom_violin(aes(fill = Organelle), scale = "width", bw = 0.5)
gg2 <- gg2 + theme_bw() +
  scale_fill_manual(values = pRoloc::getStockcol()[seq_len(nrow(dfr))]) +
  theme(axis.text.x = element_text(angle = 90, hjust = 1),
        axis.title.x = element_blank())
gg2 <- gg2 +
  ylab("Membership Probability") +
  ggtitle(paste0("Distribution of Subcellular Membership for Protein ", "Q14147" ))
gg2 <- gg2 +
  theme(legend.position = "none")
gg2
ococrook commented 3 years ago

thanks Josie, I'll have a play tomorrow and update!

JosieAC commented 3 years ago

Thank you! 👍

JosieAC commented 3 years ago

Just an additional comment on this function (possibly just personal preference though) - the text is quite small. Have used the following which seems like a nice size (also rotated labels to fit):

gg2 <- gg2 + theme_bw() +
  scale_fill_manual(values = pRoloc::getStockcol()[seq_len(nrow(dfr))]) +
  theme(text = element_text(size=15), axis.text.x = element_text(angle = 45, hjust = 1),
        axis.title.x = element_blank())
ococrook commented 3 years ago

cheers! I have a look at a few options and see what works but if it's a good default then I'll go with that :)

ococrook commented 3 years ago

@JosieAC Should work now! sorry for the delay. I agree with the text size change they are much better. Careful not to set bw = 0.5 this big as it will distor the violins. I suggest about somwhere between 0.05 to 0.1 is usually good, maybe higher if its quite lumpy.

ococrook commented 3 years ago

Could you close the issue when you've check it works for you?

JosieAC commented 3 years ago

Hi Olly,

Sorry I've been off the end of this week. I'll check this today.

On 2021-04-22 21:41, Oliver M. Crook wrote:

Could you close the issue when you've check it works for you?

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or unsubscribe [2].

Links:

[1] https://github.com/ococrook/bandle/issues/7#issuecomment-825170470 [2] https://github.com/notifications/unsubscribe-auth/AL2R32XPPTYC62EFPKTP6Y3TKCCWTANCNFSM426AIMCQ

JosieAC commented 3 years ago

image

Works fine now, thank you :)