zdk123 / SpiecEasi

Sparse InversE Covariance estimation for Ecological Association and Statistical Inference
GNU General Public License v3.0
195 stars 68 forks source link

getOptX doesn't type check input object #86

Closed xuebaliang closed 5 years ago

xuebaliang commented 5 years ago

hello, I have a question about the procedure for estimating the inverse covariance matrix. The below is my code: for mb method: mb.res = sparseiCov(data = clr.data, method = 'mb') mb.icov = getOptBeta(mb.res) for gl methods: gl.res = sparseiCov(clr.data, method = 'glasso') gl.icov = getOptiCov(gl.res) where the clr.data is the data matrix after implement central log ratio transformation. However, i get the above error. But when i use your code from two yeas ago, it works, like this: for mb method mb.res = sparseiCov(data = clr.data, method = 'mb', lambda.min.ratio = 1e-3, nlambda = 15) mb.res = icov.select(mb.res, criterion = 'stars') mb.icov = symBeta(getOptBeta(mb.res), mode='ave') for gl method gl.res = sparseiCov(clr.data, method = 'glasso', lambda.min.ratio = 1e-3, nlambda = 15) gl.res = icov.select(gl.res, criterion = 'stars') gl.icov = gl.res$opt.icov therefore, i want to know how to get the inverse covariance matrix of two methods from your newest code. I hope you can write the code for me in my data form or the way i can understand. Thanks very much.

zdk123 commented 5 years ago

I am actually surprised that the old code worked. The sparseiCov doesn't do model selection and so there is no optimal graph to choose from. As explained in the README, please run spiec.easi(clr.data, method='mb').

I can add better error handling for calling getOptX on non-spiec.easi objects...

xuebaliang commented 5 years ago

Thanks for your answer. thus i should do: for mb method, mb.res = spiec.easi(clr.data, method='mb',...), but is the object mb.res the optimal graph? or i should do more to obtain the unique precision matrix, such as mb.icov = getOptBeta(mb.res)?

zdk123 commented 5 years ago

the latter is the correct approach. See the README for an example run: https://github.com/zdk123/SpiecEasi#analysis-of-american-gut-data

xuebaliang commented 5 years ago

ok,thank you, i just run the whole code as you say. But i can't find the optimal graph, namely the best estimated precision matrix through model selection. For example, i just can get the below results: huge::huge.roc(mb.res$est$path, graph, verbose=FALSE) True Postive Rate: from 0 to 0.8514286 False Positive Rate: from 0 to 1.022857 Area under Curve: 0.6609116 Maximum F1 Score: 0.6425384 where mb.res is obtained by function spiec.easi .

zdk123 commented 5 years ago

I don't have enough information about your data / setup to judge this output behavior. However, this is now off-topic, so please file a new issue if you can describe the problem you are seeing together with a reproducible example. thank you.