SpiecEasi icon indicating copy to clipboard operation
SpiecEasi copied to clipboard

spiec easi in multiple steps

Open gastronaut82 opened this issue 11 months ago • 8 comments

If I am starting with a relative abundance table (I don't have raw counts), I wanted to run Spiec-Easi in multiple steps, so that I can use my relative abundance table (with a tiny pseudocount added) that I can do CLR transformation on first, then build the networks. Currently, the SPIEC EASI function does this all in one step - can I do in steps?

gastronaut82 avatar Mar 19 '24 13:03 gastronaut82

Hi! I just wanted to add myself to this issue since I have the same problem. I am using data coming from different sources and using a batch correction method that returns CLR-transformed data, so I need a way to build the networks on data that are already CLR-transformed. Is there any way to do this??

Thanks!

blacruz17 avatar Apr 23 '24 16:04 blacruz17

I have a branch for this now - it's not fully tested but should be equivalent to master for this purpose.

devtools::install_github("zdk123/SpiecEasi", ref="latentcor")
library(SpiecEasi)

## prenormalization
X <- X/rowSums(X)

# For CLR without the pseudocount:
se <- spiec.easi(X, method='mb', lambda.min.ratio=1e-2, nlambda=15, norm.params=list(method='clr'))

zdk123 avatar Apr 25 '24 01:04 zdk123

Not doing any internal normalizations is out of scope for this package, but if you just want to run the "spiec.easi" pipeline (graphical lasso + StARS model selection) on arbitrary inputs, you can just run the pulsar package directly. https://cran.r-project.org/web/packages/pulsar/vignettes/pulsar.html

You could run something like:

lmax <- getMaxCov(X)
lams <- getLamPath(lmax, lmax*.05, len=40)

hugeargs <- list(lambda=lams, verbose=FALSE)
out.p    <- pulsar(X, fun=huge, fargs=hugeargs, rep.num=20, criterion='stars', seed=10010))
fit.p    <- refit(out.p)

which will be equivalent to spiec.easi for pseudo count + clr normalized data for X.

zdk123 avatar Apr 25 '24 01:04 zdk123

Hi, thanks! So, just to make sure, X would be my pseudocount + CLR-transformed abundance matrix?

blacruz17 avatar Apr 29 '24 12:04 blacruz17

For pulsar, X can be any data matrix.

zdk123 avatar Apr 29 '24 13:04 zdk123

For pulsar, X can be any data matrix.

Does spiec easi perform clr transformations on data matrices before running? If I input a CLR data matrix, will the steps be repeated?

se.gl.amgut <- spiec.easi(amgut1.filt, method='glasso', lambda.min.ratio=1e-2,
                          nlambda=20, pulsar.params=list(rep.num=50))

1

wfgui avatar Aug 07 '24 09:08 wfgui

Yes

On Wed, Aug 7, 2024, 5:25 AM wfgui @.***> wrote:

For pulsar, X can be any data matrix.

Does spiec easi perform clr transformations on data matrices before running? 1.png (view on web) https://github.com/user-attachments/assets/56e7e8a3-df70-4371-9126-75cb251768d4

— Reply to this email directly, view it on GitHub https://github.com/zdk123/SpiecEasi/issues/256#issuecomment-2273025268, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUD2RG5SPVHAMJN3KNSL3LZQHR2BAVCNFSM6AAAAABE5TMVGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZTGAZDKMRWHA . You are receiving this because you commented.Message ID: @.***>

zdk123 avatar Aug 07 '24 19:08 zdk123

Yes On Wed, Aug 7, 2024, 5:25 AM wfgui @.> wrote: For pulsar, X can be any data matrix. Does spiec easi perform clr transformations on data matrices before running? 1.png (view on web) https://github.com/user-attachments/assets/56e7e8a3-df70-4371-9126-75cb251768d4 — Reply to this email directly, view it on GitHub <#256 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUD2RG5SPVHAMJN3KNSL3LZQHR2BAVCNFSM6AAAAABE5TMVGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZTGAZDKMRWHA . You are receiving this because you commented.Message ID: @.>

This means that I don't need to perform CLR conversion anymore. Just hand over the data matrix to spiec easi, and the spiec easi pipeline will perform CLR conversion.Thanks!

wfgui avatar Aug 08 '24 00:08 wfgui