zdk123 / SpiecEasi

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

whether it‘s suitable to solve the ‘Optimal lambda’ warning by bumping up ‘thresh’ value? #190

Open Xuyifei-NAU opened 3 years ago

Xuyifei-NAU commented 3 years ago

Hello Zach,

Thank you for this great package!

I'm trying to construct a network including bacterial and fungal communities with an ASV table.

I got an empty network and a warning message Optimal lambda may be larger than the supplied values after running the following codes.

sp.ea.pb <- spiec.easi(list(sub.ps.16s2,sub.ps.18s2), method = 'glasso', lambda.min.ratio = 0.0001,
                       nlambda = 100,pulsar.params = list(thresh = 0.05,rep.num=20,seed=888,ncores=80))

I changed thelambda.min.ratio (0.1, 0.01, 0.001 and 0.0001)and nlambda'(10, 50, 100, 200), the warning was still here and the output ofsp.ea.pb$select$stars$summary` was similar to the followed.

[1] 0.0000000 0.1366915 0.2175010 0.2595366 0.2808470 0.2916973 0.2978203 0.3015875 0.3039185 0.3055491 0.3068049 0.3076960 0.3084920 0.3090693 0.3095720
[16] 0.3099620 0.3102642 0.3105042 0.3107978 0.3110010 0.3112093 0.3114144 0.3115889 0.3117538 0.3118837 0.3119805 0.3120458 0.3121454 0.3122588 0.3123619
[31] 0.3124692 0.3125433 0.3126652 0.3127241 0.3127903 0.3128627 0.3129345 0.3130128 0.3130675 0.3131262 0.3131546 0.3132181 0.3132419 0.3132601 0.3133237
[46] 0.3133693 0.3134292 0.3134947 0.3135088 0.3135159 0.3135442 0.3135907 0.3136031 0.3136622 0.3136710 0.3137020 0.3137609 0.3137609 0.3137947 0.3138216
[61] 0.3138261 0.3138559 0.3139260 0.3139714 0.3139714 0.3139714 0.3139714 0.3139714 0.3139960 0.3139960 0.3139960 0.3140023 0.3140242 0.3140592 0.3140934
[76] 0.3140934 0.3140934 0.3140934 0.3140934 0.3140964 0.3140964 0.3141321 0.3141321 0.3141473 0.3141473 0.3141473 0.3141473 0.3141473 0.3141473 0.3141473
[91] 0.3141473 0.3141473 0.3141473 0.3142686 0.3142686 0.3142686 0.3142686 0.3142686 0.3142686 0.3142686

I figured out a pattern of the output of sp.ea.pb$select$stars$summary, the first value is 0, and the second value directly exceeds thresh which was set as 0.05 by default, the following values are distributed around 0.314.

Could you help me figure out the reason for these data distribution patterns and solve that?

Due to that pattern, I set the thresh up to 0.3, it worked and did not show any warnings. And is that suitable to set the thresh to a large value to avoid the warning of Optimal lambda may be larger than the supplied values?

zdk123 commented 2 years ago

Actually in this case lambda.min.ratio is too low (most of the networks in the lambda path are completely connected). The optimal graph at a threshold of .05 is actually between the first two values of lambda, so you need to sample between those two values.