WormTensor
Install WormTensor
package from CRAN or GitHub in
advance and then type the code below in the R console window.
library(WormTensor)
worm_download
is a function to retrieve data from
figshare for a total of 28 animals (24 normal and 4 noisy). If there is
no argument, mSBD distance matrices (including 24 normal animals) will
be downloaded.
<- worm_download() object
as_worm_tensor
is a function to generate a
WormTensor
object from distance matrices. A
WormTensor
object S4 class is used by
worm_membership
, worm_clustering
,
worm_evaluate
, and worm_visualize
.
<- as_worm_tensor(object$Ds) object
worm_membership
is a function to generate a membership
tensor from a WormTensor
object with distance matrices. Set
the assumed number of clusters to k(>=2).
<- worm_membership(object, k=6) object
worm_clustering
is a function to generate a clustering
result from a WormTensor
object with a membership
tensor.
<- worm_clustering(object) object
worm_evaluate
is a function to generate an evaluation
result from a WormTensor
object with a
worm_clustering
result.
<- worm_evaluate(object) object
worm_visualizeis a function to visualize
worm_clusteringand
worm_evaluate`
results.<- worm_visualize(object) object
The above functions can also be run by connecting them with R’s native pipe.
worm_download()$Ds |>
as_worm_tensor() |>
worm_membership(k=6) |>
worm_clustering() |>
worm_evaluate() |>
worm_visualize() -> object
If you have a label for the cells, you can use it for external evaluation.
# Sample Labels
worm_download()$Ds |>
as_worm_tensor() |>
worm_membership(k=6) |>
worm_clustering() -> object
<- list(
labels label1 = sample(3, length(object@clustering), replace=TRUE),
label2 = sample(4, length(object@clustering), replace=TRUE),
label3 = sample(5, length(object@clustering), replace=TRUE))
# WormTensor (with Labels)
worm_download()$Ds |>
as_worm_tensor() |>
worm_membership(k=6) |>
worm_clustering() |>
worm_evaluate(labels) |>
worm_visualize() -> object_labels