# Cross Domain SPIEC-EASI

SpiecEasi now includes a convenience wrapper for dealing with multiple taxa sequenced on the same samples, such as 16S and ITS, as seen in Tipton, Müller, et. al. (2018). It assumes that each taxa is in its own data matrix and that all samples are in all data matrices in the same order.

Here’s an example run from the HMP2 project with 16S and Proteomics data:

First we load the data:

    library(SpiecEasi)
    library(phyloseq)
    data(hmp2)

Run the cross-domain SPIEC-EASI pipeline:

    se.hmp2 <- spiec.easi(list(hmp216S, hmp2prot), method='mb', nlambda=40,
                  lambda.min.ratio=1e-2, pulsar.params = list(thresh = 0.05))

Plot the network:

    dtype <- c(rep(1,ntaxa(hmp216S)), rep(2,ntaxa(hmp2prot)))
    plot(adj2igraph(getRefit(se.hmp2)), vertex.color=dtype+1, vertex.size=9)

unnamed-chunk-3-1.png

## Key features of cross-domain analysis

1. Multiple data types: You can analyze different types of microbiome data (e.g., 16S rRNA, ITS, metagenomics) or even different omics data types together.

2. Same samples: All data matrices must have the same samples in the same order.

3. Unified network: The result is a single network where nodes represent features from all data types, and edges represent associations between features across domains.

4. Visualization: Different node colors can be used to distinguish between different data types or domains.

## Example with custom data

    # Example with custom data
    # Assuming you have two data matrices with the same samples
    data1 <- matrix(rpois(100*50, 10), 100, 50)  # First data type
    data2 <- matrix(rpois(100*30, 5), 100, 30)   # Second data type

    # Run cross-domain SPIEC-EASI
    se.cross <- spiec.easi(list(data1, data2), method='mb',
                           lambda.min.ratio=1e-2, nlambda=20,
                           pulsar.params=list(rep.num=50))

    # Create visualization with different colors for each domain
    dtype <- c(rep(1, ncol(data1)), rep(2, ncol(data2)))
    ig.cross <- adj2igraph(getRefit(se.cross))
    plot(ig.cross, vertex.color=dtype+1, vertex.size=6)

unnamed-chunk-5-1.png

## Interpretation

In cross-domain networks:

- Within-domain edges: Represent associations between features of the same type
- Cross-domain edges: Represent associations between features from different data types
- Network structure: Can reveal how different biological systems interact

This approach is particularly useful for understanding how different components of the microbiome (e.g., bacteria vs. fungi) or different biological systems (e.g., microbiome vs. metabolome) interact.

Session info:

    sessionInfo()
    # R version 4.6.0 (2026-04-24)
    # Platform: x86_64-pc-linux-gnu
    # Running under: Ubuntu 24.04.4 LTS
    #
    # Matrix products: default
    # BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
    # LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
    #
    # locale:
    #  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    #  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
    #  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
    #  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
    #  [9] LC_ADDRESS=C               LC_TELEPHONE=C
    # [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
    #
    # time zone: Etc/UTC
    # tzcode source: system (glibc)
    #
    # attached base packages:
    # [1] stats     graphics  grDevices utils     datasets  methods   base
    #
    # other attached packages:
    # [1] phyloseq_1.56.0  SpiecEasi_2.0.0  BiocStyle_2.40.0
    #
    # loaded via a namespace (and not attached):
    #  [1] gtable_0.3.6        shape_1.4.6.1       xfun_0.57
    #  [4] bslib_0.10.0        ggplot2_4.0.3       Biobase_2.72.0
    #  [7] lattice_0.22-9      vctrs_0.7.3         tools_4.6.0
    # [10] generics_0.1.4      biomformat_1.40.0   stats4_4.6.0
    # [13] parallel_4.6.0      cluster_2.1.8.2     pkgconfig_2.0.3
    # [16] Matrix_1.7-5        huge_1.6            data.table_1.18.2.1
    # [19] RColorBrewer_1.1-3  S7_0.2.2            S4Vectors_0.50.0
    # [22] lifecycle_1.0.5     compiler_4.6.0      farver_2.1.2
    # [25] stringr_1.6.0       Biostrings_2.80.0   Seqinfo_1.2.0
    # [28] codetools_0.2-20    permute_0.9-10      htmltools_0.5.9
    # [31] sys_3.4.3           buildtools_1.0.0    sass_0.4.10
    # [34] yaml_2.3.12         glmnet_4.1-10       crayon_1.5.3
    # [37] jquerylib_0.1.4     MASS_7.3-65         cachem_1.1.0
    # [40] vegan_2.7-3         iterators_1.0.14    foreach_1.5.2
    # [43] nlme_3.1-169        digest_0.6.39       stringi_1.8.7
    # [46] reshape2_1.4.5      maketools_1.3.2     splines_4.6.0
    # [49] ade4_1.7-24         fastmap_1.2.0       grid_4.6.0
    # [52] cli_3.6.6           magrittr_2.0.5      survival_3.8-6
    # [55] ape_5.8-1           scales_1.4.0        rmarkdown_2.31
    # [58] XVector_0.52.0      multtest_2.68.0     igraph_2.3.0
    # [61] pulsar_0.3.13       VGAM_1.1-14         evaluate_1.0.5
    # [64] knitr_1.51          IRanges_2.46.0      mgcv_1.9-4
    # [67] rlang_1.2.0         Rcpp_1.1.1-1.1      glue_1.8.1
    # [70] BiocManager_1.30.27 BiocGenerics_0.58.0 jsonlite_2.0.0
    # [73] R6_2.6.1            plyr_1.8.9