Description Usage Arguments Value Note See Also Examples
This method allows to create an ExposomeClust object from an
ExposomeSet object by clustering samples through the exposure
levels. The method is flexible to accept any clustering method
(method
) that allows to obtain a classification (cmethod
)
of the samples. The function assigned to argument method
must have
an argument called data
, waiting for the matrix of exposures
(samples as rows, exposures as columns). If the result object of the
method
has no accessor $classification
, then a cmethod
is required and will be applied on the result of method
to obtain
a labelled vector with the samples' classification.
1 | clustering(object, method, cmethod, ..., warnings = TRUE)
|
object |
|
method |
Function applied to the exposures of |
cmethod |
(optional) Function to obtain the classification from the object
generated with |
... |
Passed to content of |
warnings |
(default |
ExposomeClust
with the original exposures and the
classification of each exposure.
The function assigned to cmethod
will be directy applied to
the result of the method
as: cmethod(model)
; being
model
the result of method
.
classification to see how to obtain the classification of the samples from an ExposomeClust, plotClassification to plot the groups
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | data("exposome")
# EXAMPLE 1: Clustering with mclust
library(mclust)
c <- clustering(expo[12:32, ], method = Mclust, G = 2)
table(classification(c)) # This works since the result of Mclust has an accessor
# $classification
# EXAMPLE 2: Cluseting with flexmix
library(flexmix)
# First we carete a function to apply flexmix to the ExposomeSet
flexmix_clust <- function(data, ...) {
data <- as.matrix(data)
flexmix(formula = data~1, ...)
}
# Then if we apply the method to the ExposomeSet it will crash:
# c <- clustering(expo[12:32, ], method = flexmix_clust, k = 2, model = FLXMCmvnorm())
# Because the method does not know how to obtain the classification for the result
# since flexmix has not an accessor called $classiciation
# We create a function to get the classification
flexmix_clas <- function(model, ...) {
return(clusters(model))
}
# We put it to the ExposomeClust
c <- clustering(expo[12:32, ], method = flexmix_clust, cmethod = flexmix_clas,
k = 2, model = FLXMCmvnorm())
classification(c) # This works because the ExposomeClust has a way to get
# the classification
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.