Skip to content

Commit b1d4e31

Browse files
committed
avoid duplicate group in trend
plotting antibody trend uses combination of allele and bead
1 parent 614ebf9 commit b1d4e31

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

R/plotAntibodies.R

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
#' Plot Antibody Data with Optional Antigen-Level Table or Time-Series Trend
22
#'
3-
#' This function generates a bar plot of SAB (Single Antigen Beads) or PRA (Panel-Reactive Antibody) results
4-
#' from a provided data frame or a file path. It can also plot MFI values over time.
3+
#' This function generates a bar plot of SAB (Single Antigen Beads) or PRA
4+
#' (Panel-Reactive Antibody) results from a provided data frame or a file path.
5+
#' It can also plot MFI values over time.
56
#'
6-
#' @param result_file A data frame, a list of data frames (for trend plot), or a character string
7-
#' specifying the path to a file in CSV, XLS, or XLSX format.
8-
#' @param type Character. The type of assay, either "SAB" or "PRA". Defaults to "SAB".
9-
#' @param class Character. For PRA plots, the class of the assay, either "I" or "II". Defaults to "I".
10-
#' @param plot_trend Logical. If TRUE, a time-series plot is generated. Defaults to FALSE.
7+
#' @param result_file A data frame, a list of data frames (for trend plot), or
8+
#' a character string specifying the path to a file in CSV, XLS, or XLSX format.
9+
#' @param type Character. The type of assay, either "SAB" or "PRA". Defaults to
10+
#' "SAB".
11+
#' @param class Character. For PRA plots, the class of the assay, either "I" or
12+
#' "II". Defaults to "I".
13+
#' @param plot_trend Logical. If TRUE, a time-series plot is generated. Defaults
14+
#' to FALSE.
1115
#' @param bead_cutoffs Numeric vector. Cutoff values for categorizing MFI values.
12-
#' Defaults to `c(2000, 1000, 500, 250)` for SAB and `c(1500, 1000, 500, 250)` for PRA.
13-
#' @param highlight_threshold Numeric. MFI threshold for highlighting alleles in the trend plot. Defaults to 2000.
14-
#' @param vline_dates Vector of dates. Dates to draw vertical lines on the trend plot.
16+
#' Defaults to `c(2000, 1000, 500, 250)` for SAB and `c(1500, 1000, 500, 250)`
17+
#' for PRA.
18+
#' @param highlight_threshold Numeric. MFI threshold for highlighting alleles in
19+
#' the trend plot. Defaults to 2000.
20+
#' @param vline_dates Vector of dates. Dates to draw vertical lines on the trend
21+
#' plot.
1522
#' @param add_table Logical. Whether to add the antigen-level information as a
16-
#' table to the bottom of the bar plot. Defaults to TRUE.
17-
#' @param x_text_angle Numeric. Angle for the antigen/allele text in the table. Defaults to 90.
23+
#' table to the bottom of the bar plot. Defaults to TRUE.
24+
#' @param x_text_angle Numeric. Angle for the antigen/allele text in the table.
25+
#' Defaults to 90.
1826
#' @param palette Character. A color palette name. Defaults to "spectral".
1927
#' @param highlight_antigen Character vector. Optional antigen(s) to highlight.
2028
#' @param ... Additional arguments passed to the ggplot theme.
2129
#'
2230
#' @return A `ggplot` object.
2331
#'
24-
#' @importFrom ggplot2 ggplot aes geom_bar scale_fill_manual ylab guides theme element_blank geom_tile geom_text scale_y_discrete scale_color_manual scale_size labs geom_vline geom_line
32+
#' @importFrom ggplot2 ggplot aes geom_bar scale_fill_manual ylab guides theme
33+
#' element_blank geom_tile geom_text scale_y_discrete scale_color_manual
34+
#' scale_size labs geom_vline geom_line
2535
#' @importFrom patchwork plot_layout
2636
#' @export
2737
plotAntibodies <- function(result_file,
@@ -56,8 +66,9 @@ plotAntibodies <- function(result_file,
5666

5767
assay_long[, highlight := ifelse(allele %in% alleles_to_highlight, allele, "Other")]
5868
assay_long[, sample := factor(sample, levels = unique(sample))]
69+
assay_long[, uniqueID := paste(allele, BeadID)]
5970

60-
p <- ggplot(assay_long, aes(x = sample_date, y = NormalValue, group = allele, color = highlight)) +
71+
p <- ggplot(assay_long, aes(x = sample_date, y = NormalValue, group = uniqueID, color = highlight)) +
6172
geom_line(alpha = 0.7) +
6273
scale_color_manual(values = c("Other" = "gray", setNames(.colorizer(n = length(alleles_to_highlight)), alleles_to_highlight))) +
6374
.themeMatchR(...) +

R/quantifyMismatch.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ quantifyMismatch <- function(sequence1,
8484
stop("filter_polarity must be NULL, TRUE, or FALSE.")
8585
}
8686
if (!requireNamespace("Biostrings", quietly = TRUE)) {
87-
stop("Biostrings", " not installed, install or choose a different `method`.",
88-
call. = FALSE)
87+
stop("Biostrings is required for amino acid string alignment.")
8988
}
9089

9190
# --- AA property maps (physiologic pH) ---

0 commit comments

Comments
 (0)