stephenslab / mashr

An R package for multivariate adaptive shrinkage.
https://stephenslab.github.io/mashr
Other
87 stars 19 forks source link

The new function mash_estimate_corr_em does not work on mashr 0.2.50 #101

Closed hh622 closed 2 years ago

hh622 commented 2 years ago

Hello authors, thank you for devloping the great package mashr! I found that the mash_estimate_corr_em function does not work in the latest version of mashr 0.2.50. I have tried to run the R/est_cor.R script locally, it still did not work because it needed to call other functions. I am wondering that is because the mashr 0.2.50 does not include the newest functions or I did something wrong from my side? By the way, I would like to use mashr to do a meta-analysis on three tissues (i.e. three conditions) for combining evidence for a differential gene expression analysis. I generated RNAseq data on the three tissues of the same population, and they of course have some correlation. I plan to do the data-driven analysis by accounting for correlations (I found that using the “canonical” covariance even got more DE genes than the Fisher method, which is not expected). So I would like to get some hints from the authors: would three conditions be too few to perform mash analysis? If not, would the data-driven+accounting for correlations be the best option for my case? Thank you so much in advance! Best, Haixiao

stephens999 commented 2 years ago

Can you say more about what you mean by "does not work"? Can you give an example with code and data of what you are running and what the error is?

Can you open a separate issue with other questions so we deal with one issue at a time? Thanks!

hh622 commented 2 years ago

I was using an older version of mashr, and I encountered the error after I updated to version 0.2.50 but without restarting R. After restarting R, the function mash_estimate_corr_em works well. Sorry about that. I will post my second question separately. Thanks!

GabrielHoffman commented 2 years ago

I am having the same issue when I install from CRAN. It looks like the function mash_estimate_corr_em() is not being exported

library(mashr)
#> Loading required package: ashr

packageVersion("mashr")
#> [1] '0.2.50'

set.seed(1)
simdata = simple_sims(500,5,1)
V = matrix(0.5,5,5)
diag(V) = 1
simdata$Bhat = simdata$B + mvtnorm::rmvnorm(2000, sigma = V)

data   = mash_set_data(simdata$Bhat, simdata$Shat)
V.simple = estimate_null_correlation_simple(data)
data.Vsimple = mash_update_data(data, V=V.simple)

U.c = cov_canonical(data.Vsimple) 
m.Vsimple = mash(data.Vsimple, U.c) # fits with correlations because data.V includes correlation information 
#>  - Computing 2000 x 151 likelihood matrix.
#>  - Likelihood calculations took 0.04 seconds.
#>  - Fitting model with 151 mixture components.
#>  - Model fitting took 0.17 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.01 seconds.

V.em = mash_estimate_corr_em(data, U.c, details = TRUE)
#> Error in mash_estimate_corr_em(data, U.c, details = TRUE): could not find function "mash_estimate_corr_em"

But installing from GitHub works, even though both version are 0.2.50

pcarbo commented 2 years ago

@GabrielHoffman Yes it appears that the version of the package on CRAN does not export this function. @GabrielHoffman can you please try installing mashr from GitHub instead?

GabrielHoffman commented 2 years ago

Yeah, it works with the GitHub version