mirror of
https://github.com/johrpan/ubigen.git
synced 2025-10-26 19:57:24 +01:00
Use newly computed metrics
This commit is contained in:
parent
76f81ab6a7
commit
3829154c1e
9 changed files with 64 additions and 57 deletions
|
|
@ -15,7 +15,7 @@ Description: This package contains precomputed data including comparisons in
|
|||
License: AGPL (>= 3)
|
||||
Encoding: UTF-8
|
||||
Roxygen: list(markdown = TRUE)
|
||||
RoxygenNote: 7.2.0
|
||||
RoxygenNote: 7.2.1
|
||||
Depends:
|
||||
R (>= 2.10)
|
||||
LazyData: true
|
||||
|
|
|
|||
|
|
@ -71,14 +71,17 @@ genes_table_server <- function(id, data) {
|
|||
"target=\"_blank\">{hgnc_name}</a>"
|
||||
),
|
||||
"Rank" = rank,
|
||||
"Percentile" = percentile,
|
||||
"%" = percentile,
|
||||
"Score" = score,
|
||||
"Median" = median_expression,
|
||||
"IQR" = iqr_expression,
|
||||
"QCV" = qcv_expression,
|
||||
"Mean" = mean_expression,
|
||||
"Standard deviation" = sd_expression,
|
||||
"Expressed" = above_zero,
|
||||
"Above median" = above_median,
|
||||
"Above 95%" = above_95
|
||||
"SD" = sd_expression,
|
||||
"CV" = cv_expression,
|
||||
"> 0" = above_zero,
|
||||
"> median" = above_median,
|
||||
"> 95%" = above_95
|
||||
)],
|
||||
options = list(
|
||||
dom = "frtip",
|
||||
|
|
@ -90,18 +93,21 @@ genes_table_server <- function(id, data) {
|
|||
) |>
|
||||
DT::formatPercentage(
|
||||
c(
|
||||
"Percentile",
|
||||
"Score",
|
||||
"Expressed",
|
||||
"Above median",
|
||||
"Above 95%"
|
||||
"%",
|
||||
"> 0",
|
||||
"> median",
|
||||
"> 95%"
|
||||
),
|
||||
digits = 2,
|
||||
) |>
|
||||
DT::formatRound(c(
|
||||
"Score",
|
||||
"Median",
|
||||
"IQR",
|
||||
"QCV",
|
||||
"Mean",
|
||||
"Standard deviation"
|
||||
"SD",
|
||||
"CV"
|
||||
))
|
||||
})
|
||||
})
|
||||
|
|
|
|||
24
R/ranking.R
24
R/ranking.R
|
|
@ -3,34 +3,26 @@
|
|||
#' This function will compute a weighted average across multiple metrics that
|
||||
#' define how ubiquitous a gene is based on its expression across samples.
|
||||
#'
|
||||
#' @param cross_sample_metric Metric to use for calculating the number of
|
||||
#' samples a gene is expressed in. One of `above_95`, `above_median` or
|
||||
#' `above_zero`.
|
||||
#' @param cross_sample_weight Weighting of the cross sample metric within the
|
||||
#' final score.
|
||||
#' @param mean_expression_weight Weighting of the gene's mean expression within
|
||||
#' the final score.
|
||||
#' @param sd_expression_weight Weighting of the standard deviation of the
|
||||
#' gene's expression within the final score.
|
||||
#'
|
||||
#' @return A `data.table` with gene data as well as the scores, ranks and
|
||||
#' percentiles for each gene.
|
||||
#'
|
||||
#' @export
|
||||
rank_genes <- function(cross_sample_metric = "above_95",
|
||||
cross_sample_weight = 0.5,
|
||||
mean_expression_weight = 0.25,
|
||||
sd_expression_weight = -0.25) {
|
||||
level_metric = "median_expression_normalized",
|
||||
level_weight = 0.25,
|
||||
variation_metric = "qcv_expression_normalized",
|
||||
variation_weight = -0.25) {
|
||||
total_weight <- abs(cross_sample_weight) +
|
||||
abs(mean_expression_weight) +
|
||||
abs(sd_expression_weight)
|
||||
abs(level_weight) +
|
||||
abs(variation_weight)
|
||||
|
||||
data <- copy(ubigen::genes)
|
||||
|
||||
data[, score :=
|
||||
(cross_sample_weight * get(cross_sample_metric) +
|
||||
mean_expression_weight * mean_expression_normalized +
|
||||
sd_expression_weight * sd_expression_normalized) /
|
||||
level_weight * get(level_metric) +
|
||||
variation_weight * get(variation_metric)) /
|
||||
total_weight]
|
||||
|
||||
# Normalize scores to be between 0.0 and 1.0.
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ server <- function(input, output, session) {
|
|||
rank_genes(
|
||||
cross_sample_metric = input$cross_sample_metric,
|
||||
cross_sample_weight = input$cross_sample_weight,
|
||||
mean_expression_weight = input$mean_expression,
|
||||
sd_expression_weight = input$sd_expression
|
||||
level_metric = input$level_metric,
|
||||
level_weight = input$level_weight,
|
||||
variation_metric = input$variation_metric,
|
||||
variation_weight = input$variation_weight
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
|||
BIN
R/sysdata.rda
BIN
R/sysdata.rda
Binary file not shown.
35
R/ui.R
35
R/ui.R
|
|
@ -43,26 +43,45 @@ ui <- function() {
|
|||
step = 0.01,
|
||||
value = 0.5
|
||||
),
|
||||
sliderInput(
|
||||
"mean_expression",
|
||||
selectInput(
|
||||
"level_metric",
|
||||
verticalLayout(
|
||||
strong("Mean Expression"),
|
||||
"Mean expression of the gene across all samples."
|
||||
strong("Expression level"),
|
||||
"Typical expression level of the gene across all samples."
|
||||
),
|
||||
list(
|
||||
"Median expression" = "median_expression_normalized",
|
||||
"Mean expression" = "mean_expression_normalized"
|
||||
)
|
||||
),
|
||||
sliderInput(
|
||||
"level_weight",
|
||||
label = NULL,
|
||||
min = -1.0,
|
||||
max = 1.0,
|
||||
step = 0.01,
|
||||
value = 0.25
|
||||
),
|
||||
sliderInput(
|
||||
"sd_expression",
|
||||
selectInput(
|
||||
"variation_metric",
|
||||
verticalLayout(
|
||||
strong("Standard deviation"),
|
||||
strong("Expression variation"),
|
||||
paste0(
|
||||
"Standard deviation of the gene's expression across all ",
|
||||
"Measure of the variation of the gene's expression between ",
|
||||
"samples."
|
||||
)
|
||||
),
|
||||
list(
|
||||
"Quantile based coefficient of variation" =
|
||||
"qcv_expression_normalized",
|
||||
"Interquartile range" = "iqr_expression_normalized",
|
||||
"Coefficient of variation" = "cv_expression_normalized",
|
||||
"Standard deviation" = "sd_expression_normalized"
|
||||
)
|
||||
),
|
||||
sliderInput(
|
||||
"variation_weight",
|
||||
label = NULL,
|
||||
min = -1.0,
|
||||
max = 1.0,
|
||||
step = 0.01,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
\alias{genes}
|
||||
\title{A \code{data.table} containig data on genes and their expression behavior.}
|
||||
\format{
|
||||
An object of class \code{data.table} (inherits from \code{data.frame}) with 56156 rows and 14 columns.
|
||||
An object of class \code{data.table} (inherits from \code{data.frame}) with 56156 rows and 20 columns.
|
||||
}
|
||||
\usage{
|
||||
genes
|
||||
|
|
|
|||
|
|
@ -7,24 +7,12 @@
|
|||
rank_genes(
|
||||
cross_sample_metric = "above_95",
|
||||
cross_sample_weight = 0.5,
|
||||
mean_expression_weight = 0.25,
|
||||
sd_expression_weight = -0.25
|
||||
level_metric = "median_expression_normalized",
|
||||
level_weight = 0.25,
|
||||
variation_metric = "qcv_expression_normalized",
|
||||
variation_weight = -0.25
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{cross_sample_metric}{Metric to use for calculating the number of
|
||||
samples a gene is expressed in. One of \code{above_95}, \code{above_median} or
|
||||
\code{above_zero}.}
|
||||
|
||||
\item{cross_sample_weight}{Weighting of the cross sample metric within the
|
||||
final score.}
|
||||
|
||||
\item{mean_expression_weight}{Weighting of the gene's mean expression within
|
||||
the final score.}
|
||||
|
||||
\item{sd_expression_weight}{Weighting of the standard deviation of the
|
||||
gene's expression within the final score.}
|
||||
}
|
||||
\value{
|
||||
A \code{data.table} with gene data as well as the scores, ranks and
|
||||
percentiles for each gene.
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ fig <- plotly::plot_ly(data) |>
|
|||
color = ~source
|
||||
) |>
|
||||
plotly::add_lines(
|
||||
x = ~bucket_smoothed,
|
||||
y = ~total_smoothed,
|
||||
x = bucket_smoothed,
|
||||
y = total_smoothed,
|
||||
name = "All (smoothed)"
|
||||
) |>
|
||||
plotly::layout(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue