Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ License: Artistic-2.0
Encoding: UTF-8
Depends: R (>= 4.5.0)
LazyData: false
RoxygenNote: 7.3.3
Imports:
BiocParallel,
ggplot2,
Expand All @@ -54,3 +53,4 @@ Suggests:
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
biocViews: Proteomics, MassSpectrometry, StatisticalMethod, Software, Regression
Config/roxygen2/version: 8.0.0
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(MSstatsPrepareDoseResponseFit)
export(calculateConfidence)
export(calculatePeptideWeights)
export(calculateQCScore)
export(calculateTurnoverRatios)
export(classifyTurnoverProteins)
export(convertGroupToNumericDose)
export(doseResponseFit)
export(futureExperimentSimulation)
Expand All @@ -17,12 +20,18 @@ importFrom(BiocParallel,bpparam)
importFrom(data.table,rbindlist)
importFrom(dplyr,across)
importFrom(dplyr,all_of)
importFrom(dplyr,any_of)
importFrom(dplyr,arrange)
importFrom(dplyr,case_when)
importFrom(dplyr,coalesce)
importFrom(dplyr,dense_rank)
importFrom(dplyr,distinct)
importFrom(dplyr,filter)
importFrom(dplyr,group_by)
importFrom(dplyr,if_else)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,n_distinct)
importFrom(dplyr,pull)
importFrom(dplyr,rename)
importFrom(dplyr,select)
Expand Down Expand Up @@ -59,7 +68,9 @@ importFrom(plotly,ggplotly)
importFrom(plotly,layout)
importFrom(stats,approx)
importFrom(stats,cor)
importFrom(stats,median)
importFrom(stats,p.adjust)
importFrom(stats,pbinom)
importFrom(stats,pf)
importFrom(stats,quantile)
importFrom(stats,rlnorm)
Expand Down
3 changes: 1 addition & 2 deletions R/ExperimentalDesignSimulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,7 @@ simulateChemoProteinLevelNonParametric = function(N_proteins = 3000,
#' @param concentration_count Number of concentrations in simulation
#'
#' @return A list containing the plot and plot data
#' @importFrom ggplot2 ggplot aes geom_bar geom_text labs scale_fill_manual
#' scale_y_continuous theme_classic theme element_text
#' @importFrom ggplot2 ggplot aes geom_bar geom_text labs scale_fill_manual scale_y_continuous theme_classic theme element_text
#' @import dplyr
plotHitRateMSstatsResponse = function(results, rep_count, concentration_count) {

Expand Down
6 changes: 2 additions & 4 deletions R/TPR_Power_Curve.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ run_tpr_simulation <- function(rep_range, concentrations, dose_range,
#' @param show_legend Logical. Whether to display the legend.
#'
#' @return A ggplot object.
#' @importFrom ggplot2 ggplot aes geom_line geom_point scale_x_continuous
#' scale_y_continuous scale_color_manual labs theme_bw theme element_text
#' @importFrom ggplot2 ggplot aes geom_line geom_point scale_x_continuous scale_y_continuous scale_color_manual labs theme_bw theme element_text
#' @noRd
.make_tpr_panel <- function(data, k_grid, show_legend = FALSE) {
rep_levels <- sort(unique(data$N_rep))
Expand Down Expand Up @@ -288,8 +287,7 @@ run_tpr_simulation <- function(rep_range, concentrations, dose_range,
#' plot_tpr_power_curve(results)
#' }
#'
#' @importFrom ggplot2 ggplot aes geom_line geom_point scale_x_continuous
#' scale_y_continuous scale_color_manual labs theme_bw theme element_text
#' @importFrom ggplot2 ggplot aes geom_line geom_point scale_x_continuous scale_y_continuous scale_color_manual labs theme_bw theme element_text
#' @importFrom plotly ggplotly layout
#' @export
plot_tpr_power_curve <- function(simulation_results, static = FALSE) {
Expand Down
31 changes: 26 additions & 5 deletions R/protein_turnover_ratio_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,30 @@ parse_timepoint <- function(time_strings) {
return(hours)
}

#' Kendall monotonicity score, robust to sparse or all-missing data
#'
#' Computes `max(0, Kendall's tau)` between time and response, treating a group
#' with fewer than two finite (time, response) pairs as non-monotonic (score 0)
#' instead of letting `cor(use = "complete.obs")` error on zero complete pairs.
#' A zero-variance group (>= 2 points but constant) yields `NA` from `cor()`,
#' which is also mapped to 0.
#'
#' @param time Numeric vector of timepoints.
#' @param response Numeric vector of responses (same length as `time`).
#'
#' @return A single numeric monotonicity score in \[0, 1\].
#'
#' @keywords internal
#' @importFrom stats cor
kendall_monotonicity <- function(time, response) {
ok <- is.finite(time) & is.finite(response)
if (sum(ok) < 2) {
return(0)
}
score <- suppressWarnings(cor(time[ok], response[ok], method = "kendall"))
if (is.na(score)) 0 else max(0, score)
}


#' Calculate quality-based weights for peptide measurements
#'
Expand Down Expand Up @@ -297,11 +321,8 @@ calculatePeptideWeights <- function(
) %>%
group_by(across(all_of(c(protein_col, peptide_col)))) %>%
mutate(
monotonicity_score = pmax(0,
cor(.data[[time_col]], .data[[response_col]],
method = "kendall", use = "complete.obs")
),
monotonicity_score = if_else(is.na(monotonicity_score), 0, monotonicity_score)
monotonicity_score = kendall_monotonicity(.data[[time_col]],
.data[[response_col]])
) %>%
ungroup() %>%
mutate(
Expand Down
2 changes: 1 addition & 1 deletion man/DIA_MSstats_Normalized.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions man/calculateConfidence.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions man/calculatePeptideWeights.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions man/calculateQCScore.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading