Skip to content

Commit 7b974eb

Browse files
fix conflicts
1 parent 53076cd commit 7b974eb

File tree

1 file changed

+0
-158
lines changed

1 file changed

+0
-158
lines changed

assets/differentialabundance_report.qmd

Lines changed: 0 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -878,95 +878,6 @@ if (length(warnings_list) > 0) {
878878
for (warning in warnings_list) cat(warning)
879879
}
880880
881-
<<<<<<< HEAD:assets/differentialabundance_report.Rmd
882-
for (i in 1:nrow(contrasts)) {
883-
cat("\n#### ", contrast_descriptions[i], " {.tabset}\n\n")
884-
885-
## Volcano inputs
886-
full_de <- differential_results[[i]]
887-
# Filter rows with required numeric fields present
888-
needed <- c(params$differential_fc_column,
889-
params$differential_qval_column,
890-
params$differential_pval_column)
891-
present <- intersect(needed, colnames(full_de))
892-
if (length(present)) {
893-
full_de <- full_de[stats::complete.cases(full_de[, present, drop = FALSE]), ]
894-
}
895-
896-
# Labels: prefer feature name if present
897-
if (!is.null(params$features) &&
898-
!is.null(params$differential_feature_name_column) &&
899-
(params$differential_feature_name_column %in% colnames(full_de))) {
900-
label_col <- params$differential_feature_name_column
901-
} else {
902-
label_col <- params$differential_feature_id_column
903-
}
904-
905-
p_value_types <- list(
906-
Adjusted = params$differential_qval_column,
907-
Unadjusted = params$differential_pval_column
908-
)
909-
p_value_thresholds <- list(
910-
Adjusted = params$differential_max_qval,
911-
Unadjusted = params$differential_max_pval
912-
)
913-
914-
for (pvt in names(p_value_types)) {
915-
cat("\n##### ", pvt, " p values\n\n")
916-
pval_column <- p_value_types[[pvt]]
917-
918-
de_fc <- abs(full_de[[params$differential_fc_column]]) >= abs(log2(params$differential_min_fold_change))
919-
de_fc_label <- paste("abs(logFC) >=", log2(params$differential_min_fold_change))
920-
de_pval <- full_de[[pval_column]] <= p_value_thresholds[[pvt]]
921-
de_pval_label <- paste(pvt, "<=", p_value_thresholds[[pvt]])
922-
de_pval_fc_label <- paste(de_fc_label, "&", de_pval_label)
923-
924-
full_de$differential_status <- "Not significant"
925-
full_de$differential_status[de_fc] <- de_fc_label
926-
full_de$differential_status[de_pval] <- de_pval_label
927-
full_de$differential_status[de_fc & de_pval] <- de_pval_fc_label
928-
full_de$differential_status <- factor(
929-
full_de$differential_status,
930-
levels = c("Not significant", de_fc_label, de_pval_label, de_pval_fc_label),
931-
ordered = TRUE
932-
)
933-
934-
hline_thresholds <- list(
935-
setNames(-log10(p_value_thresholds[[pvt]]), paste(pval_column, "=", p_value_thresholds[[pvt]]))
936-
)
937-
vline_thresholds <- list(
938-
setNames(-log2(params$differential_min_fold_change), paste(params$differential_fc_column, "<=", log2(params$differential_min_fold_change))),
939-
setNames( log2(params$differential_min_fold_change), paste(params$differential_fc_column, ">=", log2(params$differential_min_fold_change)))
940-
)
941-
942-
palette_volcano <- append("#999999", makeColorScale(3, params$differential_palette_name))
943-
plot_args <- list(
944-
x = full_de[[params$differential_fc_column]],
945-
y = -log10(full_de[[pval_column]]),
946-
colorby = full_de$differential_status,
947-
ylab = paste("-log(10)", pval_column),
948-
xlab = paste("higher in", contrasts$reference[i], "<<", params$differential_fc_column, ">>", "higher in", contrasts$target[i]),
949-
labels = full_de[[label_col]],
950-
hline_thresholds = hline_thresholds,
951-
vline_thresholds = vline_thresholds,
952-
show_labels = FALSE,
953-
legend_title = "Differential status",
954-
palette = palette_volcano
955-
)
956-
957-
max_fc <- max(abs(full_de[[params$differential_fc_column]])) * 1.1
958-
959-
zero_p <- sum(full_de[[pval_column]] == 0, na.rm = TRUE)
960-
if (zero_p) {
961-
cat(sprintf("<i>%d feature%s not shown because of p value = 0; please refer to the results tables.</i><br><br>",
962-
zero_p, ifelse(zero_p > 1, "s are", " is")))
963-
}
964-
965-
p <- do.call(plotly_scatterplot, plot_args) %>%
966-
layout(xaxis = list(range = list(-max_fc, max_fc)))
967-
print(htmltools::tagList(p))
968-
parts <- list()
969-
=======
970881
for (i in 1:nrow(contrasts)){
971882
cat("\n#### ", contrast_descriptions[i], "\n")
972883
cat("::: {.panel-tabset}", "\n\n")
@@ -983,35 +894,13 @@ for (i in 1:nrow(contrasts)){
983894
# NAs in the fields we need.
984895
full_de <- differential_results[[i]]
985896
full_de <- subset(full_de, (! is.na(full_de[[params$meta$params$differential_fc_column]])) & (! is.na(full_de[[params$meta$params$differential_qval_colum]])) )
986-
>>>>>>> 942ab1534a52d1b4ce95f57b7f78a55d95696114:assets/differentialabundance_report.qmd
987897
988898
up_tbl <- sig_differential[[pvt]][[i]][["up"]]
989899
if (!is.null(up_tbl) && nrow(up_tbl) > 0) {
990900
up_tbl$Direction <- "Up"
991901
parts[["Up"]] <- up_tbl
992902
}
993903
994-
<<<<<<< HEAD:assets/differentialabundance_report.Rmd
995-
down_tbl <- sig_differential[[pvt]][[i]][["down"]]
996-
if (!is.null(down_tbl) && nrow(down_tbl) > 0) {
997-
down_tbl$Direction <- "Down"
998-
parts[["Down"]] <- down_tbl
999-
}
1000-
1001-
if (length(parts) > 0) {
1002-
# Bind rows even if columns differ slightly
1003-
combined <- do.call(rbind, parts)
1004-
1005-
# Round common numeric columns if present
1006-
cols_to_round <- c(
1007-
params$differential_fc_column,
1008-
params$differential_pval_column,
1009-
params$differential_qval_column
1010-
)
1011-
cols_present <- intersect(cols_to_round, colnames(combined))
1012-
if (length(cols_present)) {
1013-
combined[, cols_present] <- signif(combined[, cols_present, drop = FALSE], 8)
1014-
=======
1015904
p_value_types <- list(Adjusted = params$meta$params$differential_qval_column, Unadjusted = params$meta$params$differential_pval_column)
1016905
p_value_thresholds <- list(Adjusted = params$meta$params$differential_max_qval, Unadjusted = params$meta$params$differential_max_pval)
1017906
@@ -1062,7 +951,6 @@ for (i in 1:nrow(contrasts)){
1062951
zero_p <- length(which(full_de[[pval_column]]==0))
1063952
if (zero_p) {
1064953
cat(paste0("<i>", zero_p, " feature", ifelse(zero_p>1, "s are", " is"), " not shown because of p value = 0; please refer to the results tables.</i><br><br>"))
1065-
>>>>>>> 942ab1534a52d1b4ce95f57b7f78a55d95696114:assets/differentialabundance_report.qmd
1066954
}
1067955
1068956
# Put Direction first, prettify col names, then optional global rounding
@@ -1071,47 +959,6 @@ for (i in 1:nrow(contrasts)){
1071959
colnames(combined) <- prettifyVariablename(colnames(combined))
1072960
combined <- round_dataframe_columns(combined, digits = params$round_digits)
1073961
1074-
<<<<<<< HEAD:assets/differentialabundance_report.Rmd
1075-
# Show the single DT
1076-
print(htmltools::tagList(
1077-
datatable(
1078-
combined,
1079-
caption = paste(
1080-
"Differential genes (Up + Down) in",
1081-
contrast_descriptions[i],
1082-
"(check", differential_files[[i]], "for more detail)"
1083-
),
1084-
rownames = FALSE
1085-
)
1086-
))
1087-
1088-
# Optional biotype plot, now grouped by Direction
1089-
if ("Gene biotype" %in% colnames(combined)) {
1090-
# Count by biotype and direction without adding new deps
1091-
bt <- as.data.frame(table(
1092-
combined[["Gene biotype"]],
1093-
combined[["Direction"]]
1094-
))
1095-
colnames(bt) <- c("Gene biotype", "Direction", "count")
1096-
bt <- bt[bt$count > 0, , drop = FALSE]
1097-
1098-
biotype_plot <-
1099-
ggplot2::ggplot(bt, ggplot2::aes(
1100-
x = stats::reorder(`Gene biotype`, -count),
1101-
y = count,
1102-
fill = Direction
1103-
)) +
1104-
ggplot2::geom_bar(stat = "identity", position = ggplot2::position_dodge()) +
1105-
ggplot2::labs(
1106-
title = "Differentially Expressed Genes by Gene Biotype and Direction",
1107-
x = "Gene Biotype",
1108-
y = "Number of Differentially Expressed Genes"
1109-
) +
1110-
ggplot2::theme_minimal() +
1111-
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust = 1))
1112-
1113-
print(biotype_plot)
1114-
=======
1115962
print(htmltools::tagList(p))
1116963
cat("\n\n")
1117964
# ... then show tables of the up/ down genes
@@ -1145,19 +992,14 @@ for (i in 1:nrow(contrasts)){
1145992
theme(axis.text.x = element_text(angle = 45, hjust = 1))
1146993
1147994
print(gene_biotype_plot)
1148-
>>>>>>> 942ab1534a52d1b4ce95f57b7f78a55d95696114:assets/differentialabundance_report.qmd
1149995
cat("\n")
1150996
} else {
1151997
cat("Column 'Gene biotype' does not exist. Skipping plot.\n")
1152998
}
1153999
} else {
11541000
cat("No significantly differential genes in either direction.\n\n")
11551001
}
1156-
<<<<<<< HEAD:assets/differentialabundance_report.Rmd
1157-
}
1158-
=======
11591002
cat(":::")
1160-
>>>>>>> 942ab1534a52d1b4ce95f57b7f78a55d95696114:assets/differentialabundance_report.qmd
11611003
}
11621004
```
11631005

0 commit comments

Comments
 (0)