| 
									
										
										
										
											2021-12-16 13:01:44 +01:00
										 |  |  | #' Describe a new method for analyzing gene position data. | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @param id Unique identifier for the method. | 
					
						
							|  |  |  | #' @param name Human readable name. | 
					
						
							|  |  |  | #' @param description Slightly longer description. | 
					
						
							|  |  |  | #' @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 | 
					
						
							|  |  |  | #'   be an object of class `geposan_result`. | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @return An object of class `geposan_method`. | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @export | 
					
						
							|  |  |  | method <- function(id, name, description, func) { | 
					
						
							| 
									
										
										
										
											2022-05-26 12:42:19 +02:00
										 |  |  |   stopifnot(is.character(id) & length(id) == 1) | 
					
						
							|  |  |  |   stopifnot(is.character(name) & length(name) == 1) | 
					
						
							|  |  |  |   stopifnot(is.character(description) & length(description) == 1) | 
					
						
							|  |  |  |   stopifnot(is.function(func)) | 
					
						
							| 
									
										
										
										
											2021-12-16 13:01:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 12:42:19 +02:00
										 |  |  |   structure( | 
					
						
							|  |  |  |     list( | 
					
						
							|  |  |  |       id = id, | 
					
						
							|  |  |  |       name = name, | 
					
						
							|  |  |  |       description = description, | 
					
						
							|  |  |  |       func = func | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |     class = "geposan_method" | 
					
						
							|  |  |  |   ) | 
					
						
							| 
									
										
										
										
											2021-12-16 13:01:44 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #' Get a list of all available methods. | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @export | 
					
						
							|  |  |  | all_methods <- function() { | 
					
						
							| 
									
										
										
										
											2022-05-26 12:42:19 +02:00
										 |  |  |   list( | 
					
						
							|  |  |  |     clustering(), | 
					
						
							|  |  |  |     correlation(), | 
					
						
							|  |  |  |     neural(), | 
					
						
							|  |  |  |     adjacency(), | 
					
						
							|  |  |  |     species_adjacency(), | 
					
						
							|  |  |  |     proximity() | 
					
						
							|  |  |  |   ) | 
					
						
							| 
									
										
										
										
											2021-12-16 13:01:44 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #' Print a method object. | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @param x The method to print. | 
					
						
							|  |  |  | #' @param ... Other parameters. | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @seealso [method()] | 
					
						
							|  |  |  | #' | 
					
						
							|  |  |  | #' @export | 
					
						
							|  |  |  | print.geposan_method <- function(x, ...) { | 
					
						
							| 
									
										
										
										
											2022-05-26 12:42:19 +02:00
										 |  |  |   cat(sprintf( | 
					
						
							|  |  |  |     paste0( | 
					
						
							|  |  |  |       "geposan method:", | 
					
						
							|  |  |  |       "\n  Method ID: %s", | 
					
						
							|  |  |  |       "\n  Name: %s", | 
					
						
							|  |  |  |       "\n  Description: %s", | 
					
						
							|  |  |  |       "\n" | 
					
						
							|  |  |  |     ), | 
					
						
							|  |  |  |     x$id, | 
					
						
							|  |  |  |     x$name, | 
					
						
							|  |  |  |     x$description | 
					
						
							|  |  |  |   )) | 
					
						
							| 
									
										
										
										
											2021-12-16 13:01:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 12:42:19 +02:00
										 |  |  |   invisible(x) | 
					
						
							| 
									
										
										
										
											2021-12-16 13:01:44 +01:00
										 |  |  | } |