sillydist: Calculate a simplistic distance function of a point against...

View source: R/helpers_misc.R

sillydistR Documentation

Calculate a simplistic distance function of a point against two axes.

Description

Sillydist provides a distance of any point vs. the axes of a plot. This just takes the abs(distances) of each point to the axes, normalizes them against the largest point on the axes, multiplies the result, and normalizes against the max of all point.

Usage

sillydist(firstterm, secondterm, firstaxis = 0, secondaxis = 0)

Arguments

firstterm

X-values of the points.

secondterm

Y-values of the points.

firstaxis

X-value of the vertical axis.

secondaxis

Y-value of the second axis.

Value

Dataframe of the distances.

See Also

[ggplot2]

Examples

## Not run: 
 mydist <- sillydist(df[,1], df[,2], first_median, second_median)
 first_vs_second <- ggplot(df, aes(x = .data[["first"]], y = .data[["second"]]),
                                    environment = hpgl_env) +
   ggplot2::xlab(paste("Expression of", df_x_axis)) +
   ggplot2::ylab(paste("Expression of", df_y_axis)) +
   ggplot2::geom_vline(color = "grey", xintercept=(first_median - first_mad), size = line_size) +
   ggplot2::geom_vline(color = "grey", xintercept=(first_median + first_mad), size = line_size) +
   ggplot2::geom_vline(color = "darkgrey", xintercept = first_median, size = line_size) +
   ggplot2::geom_hline(color = "grey", yintercept=(second_median - second_mad), size = line_size) +
   ggplot2::geom_hline(color = "grey", yintercept=(second_median + second_mad), size = line_size) +
   ggplot2::geom_hline(color = "darkgrey", yintercept = second_median, size = line_size) +
   ggplot2::geom_point(colour = grDevices::hsv(mydist$dist, 1, mydist$dist),
                       alpha = 0.6, size = size) +
   ggplot2::theme(legend.position = "none")
 first_vs_second  ## dots get colored according to how far they are from the medians
 ## replace first_median, second_median with 0,0 for the axes

## End(Not run)

elsayed-lab/hpgltools documentation built on May 9, 2024, 5:02 a.m.