Skip to content
Open
Changes from 1 commit
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
21 changes: 16 additions & 5 deletions R/plotBoxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -970,17 +970,24 @@ setMethod("plotBoxplot", signature = c(object = "SummarizedExperiment"),
temp <- attributes(pvals)[["args"]][["data"]]
temp <- temp[temp[["rownames"]] %in% features, , drop = FALSE]
attributes(pvals)[["args"]][["data"]] <- temp
} else {

} else if ("FeatureID" %in% colnames(pvals)) {
# Use 'FeatureID' for subsetting
pvals <- pvals[
pvals$group1 %in% features & pvals$group2 %in% features,
, drop = FALSE]
, drop = FALSE
]

temp <- attributes(pvals)[["args"]][["data"]]
temp <- temp[temp[["FeatureID"]] %in% features, , drop = FALSE]
attributes(pvals)[["args"]][["data"]] <- temp
Comment on lines +1012 to +1020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intention here?

features refer to taxa, but the pvals$group1 should include the sample grouping?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only in the case when user wants to plot given features. This is in .calculate_significance() to ensure only the relevant pval to be added to the plot moves forward.


} else {
# Third case: explicitly do nothing
# No filtering applied to pvals or its attributes
}
Comment thread
0xMuluh marked this conversation as resolved.
}


return(pvals)
}
Expand Down Expand Up @@ -1033,7 +1040,7 @@ setMethod("plotBoxplot", signature = c(object = "SummarizedExperiment"),
pvals <- dplyr::left_join(pvals, ypos, by = grouping_vars)
}

if (x == "rownames") {
if (x == "rownames" || !x %in% colnames(pvals) ) {
# When x is rownames (usually unique), dodge doesn't make sense.
# Create artificial x levels from the comparison groups
x_levels <- unique(c(pvals$group1, pvals$group2))
Expand Down Expand Up @@ -1213,12 +1220,16 @@ setMethod("plotBoxplot", signature = c(object = "SummarizedExperiment"),
x_point <- y_point <- NULL
pair_by_col <- attributes(df)[["pair.by"]]
diff_col <- attributes(df)[["difference"]]
facet_by_col <- attributes(df)[["facet.by"]]

grouping_vars <- unique(c(facet_by_col, pair_by_col))
grouping_vars <- grouping_vars[grouping_vars %in% colnames(df)]

if (!is.null(diff_col) && diff_col %in% colnames(df)) {
# Prepare segments for coloring by difference
seg_df <- df %>%
arrange(across(all_of(c(pair_by_col, "x_point")))) %>%
group_by(across(all_of(pair_by_col))) %>%
arrange(across(all_of(c(grouping_vars, "x_point")))) %>%
group_by(across(all_of(grouping_vars))) %>%
mutate(
xend = lead(x_point),
yend = lead(y_point),
Expand Down