Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spiec easi in multiple steps #256

Open
gastronaut82 opened this issue Mar 19, 2024 · 8 comments
Open

spiec easi in multiple steps #256

gastronaut82 opened this issue Mar 19, 2024 · 8 comments

Comments

@gastronaut82
Copy link

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?

@blacruz17
Copy link

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!

@zdk123
Copy link
Owner

zdk123 commented Apr 25, 2024

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
Copy link
Owner

zdk123 commented Apr 25, 2024

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.

@blacruz17
Copy link

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

@zdk123
Copy link
Owner

zdk123 commented Apr 29, 2024

For pulsar, X can be any data matrix.

@wfgui
Copy link

wfgui commented Aug 7, 2024

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

@zdk123
Copy link
Owner

zdk123 commented Aug 7, 2024 via email

@wfgui
Copy link

wfgui commented Aug 8, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants