preset: Make reference genes the first parameter

This commit is contained in:
Elias Projahn 2022-01-17 19:52:51 +01:00
parent 8cda3e8e83
commit c8f1e522f9
2 changed files with 13 additions and 13 deletions

View file

@ -9,18 +9,18 @@
#' methods: [clustering()], [correlation()], [neural()], [adjacency()] and #' methods: [clustering()], [correlation()], [neural()], [adjacency()] and
#' [proximity()]. #' [proximity()].
#' #'
#' @param reference_gene_ids IDs of reference genes to compare to.
#' @param methods List of methods to apply. #' @param methods List of methods to apply.
#' @param species_ids IDs of species to include. #' @param species_ids IDs of species to include.
#' @param gene_ids IDs of genes to screen. #' @param gene_ids IDs of genes to screen.
#' @param reference_gene_ids IDs of reference genes to compare to.
#' #'
#' @return The preset to use with [analyze()]. #' @return The preset to use with [analyze()].
#' #'
#' @export #' @export
preset <- function(methods = all_methods(), preset <- function(reference_gene_ids,
methods = all_methods(),
species_ids = geposan::species$id, species_ids = geposan::species$id,
gene_ids = geposan::genes$id, gene_ids = geposan::genes$id) {
reference_gene_ids) {
# Count included species per gene. # Count included species per gene.
genes_n_species <- geposan::distances[ genes_n_species <- geposan::distances[
species %chin% species_ids, species %chin% species_ids,
@ -39,10 +39,10 @@ preset <- function(methods = all_methods(),
# for the object later. # for the object later.
structure( structure(
list( list(
reference_gene_ids = sort(reference_gene_ids),
methods = methods, methods = methods,
species_ids = sort(species_ids), species_ids = sort(species_ids),
gene_ids = sort(gene_ids_filtered), gene_ids = sort(gene_ids_filtered)
reference_gene_ids = sort(reference_gene_ids)
), ),
class = "geposan_preset" class = "geposan_preset"
) )
@ -60,16 +60,16 @@ print.geposan_preset <- function(x, ...) {
cat(sprintf( cat(sprintf(
paste0( paste0(
"geposan preset:", "geposan preset:",
"\n Reference genes: %i",
"\n Included methods: %s", "\n Included methods: %s",
"\n Number of species: %i", "\n Number of species: %i",
"\n Number of genes: %i", "\n Number of genes: %i",
"\n Reference genes: %i",
"\n" "\n"
), ),
length(x$reference_gene_ids),
paste(sapply(x$methods, function(m) m$id), collapse = ", "), paste(sapply(x$methods, function(m) m$id), collapse = ", "),
length(x$species_ids), length(x$species_ids),
length(x$gene_ids), length(x$gene_ids)
length(x$reference_gene_ids)
)) ))
invisible(x) invisible(x)

View file

@ -5,20 +5,20 @@
\title{Create a new preset.} \title{Create a new preset.}
\usage{ \usage{
preset( preset(
reference_gene_ids,
methods = all_methods(), methods = all_methods(),
species_ids = geposan::species$id, species_ids = geposan::species$id,
gene_ids = geposan::genes$id, gene_ids = geposan::genes$id
reference_gene_ids
) )
} }
\arguments{ \arguments{
\item{reference_gene_ids}{IDs of reference genes to compare to.}
\item{methods}{List of methods to apply.} \item{methods}{List of methods to apply.}
\item{species_ids}{IDs of species to include.} \item{species_ids}{IDs of species to include.}
\item{gene_ids}{IDs of genes to screen.} \item{gene_ids}{IDs of genes to screen.}
\item{reference_gene_ids}{IDs of reference genes to compare to.}
} }
\value{ \value{
The preset to use with \code{\link[=analyze]{analyze()}}. The preset to use with \code{\link[=analyze]{analyze()}}.