Add chromosomal positions plot

This commit is contained in:
Elias Projahn 2022-05-17 21:48:30 +02:00
parent 9590babb1a
commit 7e53015168
3 changed files with 63 additions and 1 deletions

View file

@ -21,6 +21,7 @@ export(plot_chromosomes)
export(plot_positions) export(plot_positions)
export(plot_rankings) export(plot_rankings)
export(plot_scores) export(plot_scores)
export(plot_scores_by_position)
export(preset) export(preset)
export(proximity) export(proximity)
export(ranking) export(ranking)

View file

@ -46,7 +46,8 @@ plot_positions <- function(species_ids, gene_sets) {
), ),
yaxis = list(title = "Distance to telomeres [Bp]"), yaxis = list(title = "Distance to telomeres [Bp]"),
bargap = 0.9 bargap = 0.9
) |> plotly::add_bars( ) |>
plotly::add_bars(
data = species_max_distance, data = species_max_distance,
x = ~species, x = ~species,
y = ~max_distance, y = ~max_distance,
@ -379,3 +380,41 @@ plot_chromosomes <- function(ranking) {
yaxis = list(title = "Mean score") yaxis = list(title = "Mean score")
) )
} }
#' Plot scores in relation to chromosomal position of genes.
#'
#' @param ranking The ranking to visualize.
#' @param chromosome_name The chromosome to visualize.
#'
#' @return A `plotly` figure.
#' @seealso ranking()
#'
#' @export
plot_scores_by_position <- function(ranking, chromosome_name) {
if (!requireNamespace("plotly", quietly = TRUE)) {
stop("Please install \"plotly\" to use this function.")
}
chromosome_name_ <- chromosome_name
data <- merge(
ranking,
geposan::distances[
species == "hsapiens" &
chromosome_name == chromosome_name_
],
by = "gene"
)
plotly::plot_ly() |>
plotly::add_markers(
data = data,
x = ~start_position,
y = ~score,
hoverinfo = "skip"
) |>
plotly::layout(
xaxis = list(title = "Position (Bp)"),
yaxis = list(title = "Score")
)
}

View file

@ -0,0 +1,22 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plots.R
\name{plot_scores_by_position}
\alias{plot_scores_by_position}
\title{Plot scores in relation to chromosomal position of genes.}
\usage{
plot_scores_by_position(ranking, chromosome_name)
}
\arguments{
\item{ranking}{The ranking to visualize.}
\item{chromosome_name}{The chromosome to visualize.}
}
\value{
A \code{plotly} figure.
}
\description{
Plot scores in relation to chromosomal position of genes.
}
\seealso{
ranking()
}