Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert metadata filtering in data_functions.R #176

Merged
merged 1 commit into from
Nov 28, 2023
Merged
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
11 changes: 8 additions & 3 deletions scripts/data_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ subset_metadata <- function(exp_metadata, design, contrasts, current_facet, curr
contrasts_subset <- contrasts_subset %>% dplyr::filter(V2 %in% contrasts_to_filter)
}
exp_metadata_subset <- exp_metadata %>%
dplyr::filter(!!sym(design) %in% (unlist(contrasts_subset) %>% unique()) ) %>%
dplyr::filter(!!sym(current_facet) %in% current_filter)
dplyr::filter(!!sym(design) %in% (unlist(contrasts_subset) %>% unique()) ) # %>%
# dplyr::filter(!!sym(current_facet) %in% current_filter)
# The line above was added to deal with an edge case where samples were not properly filtered because current_facet wasn't in the contrast names
# That edge case is uncommon and there are probably easier ways to deal with it
# Including the commented dplyr code above breaks the analysis if controls aren't matched by chemical name
# Ex. works for BPA_10 vs BPA_0 (as in test data), but not for BPA_10 vs DMSO

# relevel the design and interesting groups
exp_metadata_subset[[design]] <- factor(exp_metadata_subset[[design]],
levels = unique(unlist(contrasts_subset)),
Expand Down Expand Up @@ -166,4 +171,4 @@ subset_results <- function(res, exp_metadata){
res_subset <- res[,exp_metadata_sorted$original_names]
return(res_subset)

}
}
Loading