mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 10:47:25 +01:00
adjacency: Use median as estimate
This commit is contained in:
parent
32776469bf
commit
23bb499d3a
4 changed files with 4 additions and 50 deletions
|
|
@ -12,7 +12,6 @@ export(analyze)
|
||||||
export(clustering)
|
export(clustering)
|
||||||
export(compare)
|
export(compare)
|
||||||
export(correlation)
|
export(correlation)
|
||||||
export(densest)
|
|
||||||
export(method)
|
export(method)
|
||||||
export(neural)
|
export(neural)
|
||||||
export(optimal_weights)
|
export(optimal_weights)
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,7 @@
|
||||||
#' Find the densest value in the data.
|
|
||||||
#'
|
|
||||||
#' This function assumes that data represents a continuous variable and finds
|
|
||||||
#' a single value with the highest estimated density. This can be used to
|
|
||||||
#' estimate the mode of the data. If there is only one value that value is
|
|
||||||
#' returned. If multiple density maxima with the same density exist, their mean
|
|
||||||
#' is returned.
|
|
||||||
#'
|
|
||||||
#' @param data The input data.
|
|
||||||
#'
|
|
||||||
#' @return The densest value of data.
|
|
||||||
#'
|
|
||||||
#' @export
|
|
||||||
densest <- function(data) {
|
|
||||||
as.numeric(if (length(data) <= 0) {
|
|
||||||
NULL
|
|
||||||
} else if (length(data) == 1) {
|
|
||||||
data
|
|
||||||
} else {
|
|
||||||
density <- stats::density(data)
|
|
||||||
mean(density$x[density$y == max(density$y)])
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#' Score genes based on their proximity to the reference genes.
|
#' Score genes based on their proximity to the reference genes.
|
||||||
#'
|
#'
|
||||||
#' @param estimate A function that will be used to summarize the distance
|
#' @param estimate A function that will be used to summarize the distance
|
||||||
#' values for each gene. See [densest()] for the default implementation.
|
#' values for each gene. By default, [median()] is used.
|
||||||
#' @param combination A function that will be used to combine the different
|
#' @param combination A function that will be used to combine the different
|
||||||
#' distances to the reference genes. By default [min()] is used. That means
|
#' distances to the reference genes. By default [min()] is used. That means
|
||||||
#' the distance to the nearest reference gene will be scored.
|
#' the distance to the nearest reference gene will be scored.
|
||||||
|
|
@ -33,7 +9,7 @@ densest <- function(data) {
|
||||||
#' @return An object of class `geposan_method`.
|
#' @return An object of class `geposan_method`.
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
adjacency <- function(estimate = densest, combination = min) {
|
adjacency <- function(estimate = stats::median, combination = min) {
|
||||||
method(
|
method(
|
||||||
id = "adjacency",
|
id = "adjacency",
|
||||||
name = "Adjacency",
|
name = "Adjacency",
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@
|
||||||
\alias{adjacency}
|
\alias{adjacency}
|
||||||
\title{Score genes based on their proximity to the reference genes.}
|
\title{Score genes based on their proximity to the reference genes.}
|
||||||
\usage{
|
\usage{
|
||||||
adjacency(estimate = densest, combination = min)
|
adjacency(estimate = stats::median, combination = min)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{estimate}{A function that will be used to summarize the distance
|
\item{estimate}{A function that will be used to summarize the distance
|
||||||
values for each gene. See \code{\link[=densest]{densest()}} for the default implementation.}
|
values for each gene. By default, \code{\link[=median]{median()}} is used.}
|
||||||
|
|
||||||
\item{combination}{A function that will be used to combine the different
|
\item{combination}{A function that will be used to combine the different
|
||||||
distances to the reference genes. By default \code{\link[=min]{min()}} is used. That means
|
distances to the reference genes. By default \code{\link[=min]{min()}} is used. That means
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
% Generated by roxygen2: do not edit by hand
|
|
||||||
% Please edit documentation in R/adjacency.R
|
|
||||||
\name{densest}
|
|
||||||
\alias{densest}
|
|
||||||
\title{Find the densest value in the data.}
|
|
||||||
\usage{
|
|
||||||
densest(data)
|
|
||||||
}
|
|
||||||
\arguments{
|
|
||||||
\item{data}{The input data.}
|
|
||||||
}
|
|
||||||
\value{
|
|
||||||
The densest value of data.
|
|
||||||
}
|
|
||||||
\description{
|
|
||||||
This function assumes that data represents a continuous variable and finds
|
|
||||||
a single value with the highest estimated density. This can be used to
|
|
||||||
estimate the mode of the data. If there is only one value that value is
|
|
||||||
returned. If multiple density maxima with the same density exist, their mean
|
|
||||||
is returned.
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue