Skip to content

Commit

Permalink
Fix handling of index error for no degs at all (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednarsky authored Jan 23, 2025
1 parent 0d22c8c commit 441674f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion workflow/scripts/aggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ dea_filtered_stats_df <- as.data.frame.matrix(dea_filtered_stats)

# Handling the exception when no significant genes are found in either up or down categories
if (!all(c("up", "down") %in% colnames(dea_filtered_stats_df))) {
dea_filtered_stats_df[setdiff(c("up", "down"), colnames(dea_filtered_stats_df))] <- 0
missing_cols <- setdiff(c("up", "down"), colnames(dea_filtered_stats_df))
if (length(missing_cols) == 2) {
# just make a new dataframe, otherwise index fails completely
dea_filtered_stats_df <- data.frame(up=0, down=0)
} else {
dea_filtered_stats_df[missing_cols] <- 0
}
}

dea_filtered_stats_df$total <- rowSums(dea_filtered_stats_df)
Expand Down

0 comments on commit 441674f

Please sign in to comment.