Skip to contents

Import MicrobiotaProcess object for PARAFAC modelling

Usage

importMicrobiotaProcess(MPobject, subjectIDs, thirdMode, taxa_are_rows = TRUE)

Arguments

MPobject

MicrobiotaProcess object containing at least an OTU table and sample information, preferably also taxonomic information.

subjectIDs

Column name in the sample information corresponding to the subject IDs.

thirdMode

Column name in the sample information corresponding to the study design aspect to put in the third mode of the data cube.

taxa_are_rows

Boolean specifying if the taxa are in the rows of the OTU table (TRUE) or not (FALSE).

Value

List object containing:

  • 'data': data cube

  • 'mode1': metadata of the subject mode

  • 'mode2': taxonomy information

  • 'mode3': metadata of the third mode

Examples

# \donttest{
library(MicrobiotaProcess)
#> MicrobiotaProcess v1.16.1 For help:
#> https://github.com/YuLab-SMU/MicrobiotaProcess/issues
#> 
#> If you use MicrobiotaProcess in published research, please cite the
#> paper:
#> 
#> Shuangbin Xu, Li Zhan, Wenli Tang, Qianwen Wang, Zehan Dai, Lang Zhou,
#> Tingze Feng, Meijun Chen, Tianzhi Wu, Erqiang Hu, Guangchuang Yu.
#> MicrobiotaProcess: A comprehensive R package for deep mining
#> microbiome. The Innovation. 2023, 4(2):100388. doi:
#> 10.1016/j.xinn.2023.100388
#> 
#> Export the citation to BibTex by citation('MicrobiotaProcess')
#> 
#> This message can be suppressed by:
#> suppressPackageStartupMessages(library(MicrobiotaProcess))
#> 
#> Attaching package: ‘MicrobiotaProcess’
#> The following object is masked from ‘package:stats’:
#> 
#>     filter

# Generate synthetic data
sample_info = data.frame(Sample = factor(c("S1", "S2", "S3", "S4", "S5")),
                         time = factor(c("T1", "T2", "T1", "T2", "T1")))
otu_table = matrix(runif(25, min = 0, max = 100), nrow = 5, ncol = 5,
                   dimnames = list(paste0("OTU", 1:5), sample_info$Sample))

taxonomy_table = data.frame(OTU = paste0("OTU", 1:5),
                            Kingdom = rep("King", 5),
                            Phylum = rep("Phy", 5),
                            Class = rep("Cla", 5),
                            Order = rep("Ord", 5),
                            Family = rep("Fam", 5),
                            Genus = rep("Gen", 5))

# Create Summarized Experiment
synthetic_SE = SummarizedExperiment::SummarizedExperiment(
               assays = list(otu = otu_table),
               colData = sample_info,
               rowData = taxonomy_table)

# Convert to MicrobiotaProcess object
synthetic_MPSE = as.MPSE(synthetic_SE)

dataset = importMicrobiotaProcess(synthetic_MPSE,
                                  subjectIDs = "Sample",
                                  thirdMode = "time",
                                  taxa_are_rows = TRUE)
# }