method: Add context help

This commit is contained in:
Elias Projahn 2024-01-31 12:14:55 +01:00
parent a3cc6a8796
commit 50e2fb260f
7 changed files with 28 additions and 2 deletions

View file

@ -3,6 +3,7 @@
#' @param id Unique identifier for the method.
#' @param name Human readable name.
#' @param description Slightly longer description.
#' @param help Context help for user interfaces.
#' @param func Function to apply the method. The function should accept two
#' parameters: an object of class `geposan_preset` as input and a function to
#' report progress information to as a numeric value. The return value should
@ -11,10 +12,11 @@
#' @return An object of class `geposan_method`.
#'
#' @export
method <- function(id, name, description, func) {
method <- function(id, name, description, help, func) {
stopifnot(is.character(id) & length(id) == 1)
stopifnot(is.character(name) & length(name) == 1)
stopifnot(is.character(description) & length(description) == 1)
stopifnot(is.character(help) & length(help) == 1)
stopifnot(is.function(func))
structure(
@ -22,6 +24,7 @@ method <- function(id, name, description, func) {
id = glue::glue("geposan_method_{id}"),
name = name,
description = description,
help = help,
func = func
),
class = "geposan_method"

View file

@ -22,6 +22,11 @@ adjacency <- function(id = "adjacency",
id = id,
name = name,
description = description,
help = paste0(
"Adjacency to the reference genes across species. This method penalizes ",
"genes that do not occur in the region typical for the reference genes, ",
"without artificially defining a fixed boundary."
),
function(preset, progress) {
species_ids <- preset$species_ids
gene_ids <- preset$gene_ids

View file

@ -73,6 +73,10 @@ clustering <- function(id = "clustering",
id = id,
name = name,
description = description,
help = paste0(
"Proportion of orthologs that have similar telomeric distances across ",
"species. This favors genes whose position is evolutionarily conserved."
),
function(preset, progress) {
species_ids <- preset$species_ids
gene_ids <- preset$gene_ids

View file

@ -18,6 +18,12 @@ correlation <- function(id = "correlation",
id = id,
name = name,
description = description,
help = paste0(
"Spearman's rank correlation of the telomeric distances of the gene in ",
"comparison with the reference gene set. This helps to assess if the ",
"gene is as close or distant to telomeres as the reference genes within ",
"each species."
),
function(preset, progress) {
species_ids <- preset$species_ids
gene_ids <- preset$gene_ids

View file

@ -21,6 +21,7 @@ distance <- function(id = "distance",
id = id,
name = name,
description = description,
help = "Median distance to the telomeres across species.",
function(preset, progress) {
species_ids <- preset$species_ids
gene_ids <- preset$gene_ids

View file

@ -28,6 +28,11 @@ random_forest <- function(id = "rforest",
id = id,
name = name,
description = description,
help = paste0(
"Assessment of a random forest model trained on reference gene ",
"distances. It may derive patterns in positional data that have not ",
"been covered by other methods."
),
function(preset, progress) {
species_ids <- preset$species_ids
gene_ids <- preset$gene_ids

View file

@ -4,7 +4,7 @@
\alias{method}
\title{Describe a new method for analyzing gene position data.}
\usage{
method(id, name, description, func)
method(id, name, description, help, func)
}
\arguments{
\item{id}{Unique identifier for the method.}
@ -13,6 +13,8 @@ method(id, name, description, func)
\item{description}{Slightly longer description.}
\item{help}{Context help for user interfaces.}
\item{func}{Function to apply the method. The function should accept two
parameters: an object of class \code{geposan_preset} as input and a function to
report progress information to as a numeric value. The return value should