Learn R Programming

parafac4microbiome (version 1.1.2)

calculateSparsity: Calculate sparsity across the feature mode of a multi-way array.

Description

Calculate sparsity across the feature mode of a multi-way array.

Usage

calculateSparsity(dataset, considerGroups = FALSE, groupVariable = "")

Value

Vector of sparsity fractions (N x J) where N is the number of groups and J is the number of features.

Arguments

dataset

See Fujita2023, Shao2019 or vanderPloeg2024.

considerGroups

Consider subject groups in calculating sparsity (default FALSE)

groupVariable

Column name in dataset$mode1 that should be used to consider groups (default "")

Examples

Run this code
# No groups
sparsity = calculateSparsity(Fujita2023)
length(sparsity)
hist(sparsity)

# Consider groups
colnames(Shao2019$mode1)
sparsity = calculateSparsity(Shao2019, considerGroups=TRUE, groupVariable="Delivery_mode")
dim(sparsity)
hist(sparsity[1,])
hist(sparsity[2,])

Run the code above in your browser using DataLab