mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 10:47:25 +01:00
clustering: Expose clusteriness parameters
This commit is contained in:
parent
c6ca93b009
commit
ab545a415c
2 changed files with 49 additions and 26 deletions
|
|
@ -68,7 +68,9 @@ clusteriness <- function(data,
|
||||||
#' Process genes clustering their distance to telomeres.
|
#' Process genes clustering their distance to telomeres.
|
||||||
#'
|
#'
|
||||||
#' The result will be cached and can be reused for different presets, because
|
#' The result will be cached and can be reused for different presets, because
|
||||||
#' it is independent of the reference genes in use.
|
#' it is independent of the reference genes in use. Most parameters are exposed
|
||||||
|
#' for the [clusteriness()] function. See its documentation for more
|
||||||
|
#' information.
|
||||||
#'
|
#'
|
||||||
#' @param id Unique ID for the method and its results.
|
#' @param id Unique ID for the method and its results.
|
||||||
#' @param name Human readable name for the method.
|
#' @param name Human readable name for the method.
|
||||||
|
|
@ -80,8 +82,12 @@ clusteriness <- function(data,
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
clustering <- function(id = "clustering",
|
clustering <- function(id = "clustering",
|
||||||
name = "Clustering",
|
name = "Clustering",
|
||||||
description = "Clustering of genes") {
|
description = "Clustering of genes",
|
||||||
|
span = 100000,
|
||||||
|
weight = 0.7,
|
||||||
|
n_clusters = NULL,
|
||||||
|
relation = NULL) {
|
||||||
method(
|
method(
|
||||||
id = id,
|
id = id,
|
||||||
name = name,
|
name = name,
|
||||||
|
|
@ -90,33 +96,44 @@ clustering <- function(id = "clustering",
|
||||||
species_ids <- preset$species_ids
|
species_ids <- preset$species_ids
|
||||||
gene_ids <- preset$gene_ids
|
gene_ids <- preset$gene_ids
|
||||||
|
|
||||||
cached("clustering", c(species_ids, gene_ids), {
|
cached(
|
||||||
scores <- data.table(gene = gene_ids)
|
"clustering",
|
||||||
|
c(species_ids, gene_ids, span, weight, n_clusters, relation),
|
||||||
|
{ # nolint
|
||||||
|
scores <- data.table(gene = gene_ids)
|
||||||
|
|
||||||
# Prefilter the input data by species.
|
# Prefilter the input data by species.
|
||||||
distances <- geposan::distances[species %chin% species_ids]
|
distances <- geposan::distances[species %chin% species_ids]
|
||||||
|
|
||||||
genes_done <- 0
|
genes_done <- 0
|
||||||
genes_total <- length(gene_ids)
|
genes_total <- length(gene_ids)
|
||||||
|
|
||||||
# Perform the cluster analysis for one gene.
|
# Perform the cluster analysis for one gene.
|
||||||
compute <- function(gene_id) {
|
compute <- function(gene_id) {
|
||||||
data <- distances[gene == gene_id, distance]
|
data <- distances[gene == gene_id, distance]
|
||||||
score <- clusteriness(data)
|
|
||||||
|
|
||||||
genes_done <<- genes_done + 1
|
score <- clusteriness(
|
||||||
progress(genes_done / genes_total)
|
data,
|
||||||
|
span = span,
|
||||||
|
weight = weight,
|
||||||
|
n_clusters = n_clusters,
|
||||||
|
relation = relation
|
||||||
|
)
|
||||||
|
|
||||||
score
|
genes_done <<- genes_done + 1
|
||||||
|
progress(genes_done / genes_total)
|
||||||
|
|
||||||
|
score
|
||||||
|
}
|
||||||
|
|
||||||
|
scores[, score := compute(gene), by = gene]
|
||||||
|
|
||||||
|
result(
|
||||||
|
method = "clustering",
|
||||||
|
scores = scores
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
scores[, score := compute(gene), by = gene]
|
|
||||||
|
|
||||||
result(
|
|
||||||
method = "clustering",
|
|
||||||
scores = scores
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@
|
||||||
clustering(
|
clustering(
|
||||||
id = "clustering",
|
id = "clustering",
|
||||||
name = "Clustering",
|
name = "Clustering",
|
||||||
description = "Clustering of genes"
|
description = "Clustering of genes",
|
||||||
|
span = 1e+05,
|
||||||
|
weight = 0.7,
|
||||||
|
n_clusters = NULL,
|
||||||
|
relation = NULL
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
|
|
@ -22,7 +26,9 @@ An object of class \code{geposan_method}.
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
The result will be cached and can be reused for different presets, because
|
The result will be cached and can be reused for different presets, because
|
||||||
it is independent of the reference genes in use.
|
it is independent of the reference genes in use. Most parameters are exposed
|
||||||
|
for the \code{\link[=clusteriness]{clusteriness()}} function. See its documentation for more
|
||||||
|
information.
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
\code{\link[=clusteriness]{clusteriness()}}
|
\code{\link[=clusteriness]{clusteriness()}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue