# NOT RUN {
# Load the data set.
data( liverlipidome )
# Convert the data into wide format, where each lipid is one column and
# each sample is one row.
liverlipidome.wide <-
tidyr::pivot_wider(
data = liverlipidome,
names_from = Lipid_Name,
values_from = Lipid_Level
)
# Create a mapping of the lipid names.
names.mapping <-
map_lipid_names( x = unique( liverlipidome$"Lipid_Name" ) )
# Compute the regression models.
result.limma <-
compute_models_with_limma(
x = liverlipidome.wide,
dependent.variables = names.mapping$"Name",
independent.variables = c( "Diagnosis" ),
F.test = TRUE # Compute an F-test for a factor variable.
)
# Compute the F-test.
result.limma <- compute_F_test_with_limma( x = result.limma )
# Print a figure of the F-test.
# }
# NOT RUN {
figure.output <-
heatmap_lipidome_from_limma(
x = result.limma,
names.mapping = names.mapping,
F.test = TRUE,
axis.x.carbons = FALSE,
class.facet = "wrap",
plot.all = FALSE,
plot.individual = TRUE,
scales = "free",
space = "free"
)
# }
# NOT RUN {
# Compute pairwise post-hoc comparisons between the factor levels for
# the dependent variables (i.e., lipids) with a significant F-test result.
result.limma <-
compute_post_hoc_test_with_limma(
x = result.limma,
remap.level.names = TRUE
)
# Print a figure of all post-hoc comparisons.
# }
# NOT RUN {
figure.output <-
heatmap_lipidome_from_limma(
x = result.limma$"result.post.hoc.test",
names.mapping = names.mapping,
axis.x.carbons = FALSE,
plot.all = TRUE,
plot.individual = FALSE,
scales = "free",
space = "free"
)
# }
# NOT RUN {
# Specify the contrasts of the post-hoc comparison that will be included
# in the figure.
contrasts.included <-
c( "DiagnosisSteatosis", "DiagnosisNASH", "DiagnosisCirrhosis" )
# Get the omitted contrasts based on the above definition.
contrasts.omitted <-
colnames( result.limma$"result.post.hoc.test"$"p.value" )[
!(
colnames( result.limma$"result.post.hoc.test"$"p.value" ) %in%
contrasts.included
)
]
# Find dependent variables (i.e., lipids) that have any significant
# difference.
has.any.significant <-
apply(
X =
result.limma$"result.post.hoc.test"$"p.value"[
,
contrasts.included
],
MAR = 2,
FUN = p.adjust,
method = "BH"
)
has.any.significant <-
rownames(
has.any.significant[
apply(
X = has.any.significant < 0.05,
MAR = 1,
FUN = any
),
]
)
# Include in the figure only lipid classes that have at least four
# significant differences.
classes.included <-
names(
which(
table(
names.mapping[
make.names( has.any.significant ), "Class"
]
) > 4
)
)
classes.omitted <- unique( names.mapping$"Class" )
classes.omitted <-
classes.omitted[ !( classes.omitted ) %in% classes.included ]
# Print a figure of the selected post-hoc-comparisons.
figure.output <-
heatmap_lipidome_from_limma(
x = result.limma$"result.post.hoc.test",
names.mapping = names.mapping,
axis.x.carbons = FALSE,
omit.class = classes.omitted,
omit.factor = contrasts.omitted,
plot.all = TRUE,
plot.individual = FALSE,
scales = "free",
space = "free"
)
# }
Run the code above in your browser using DataLab