Skip to content

Commit

Permalink
fix molecular features
Browse files Browse the repository at this point in the history
  • Loading branch information
pcastellanoescuder committed Apr 15, 2024
1 parent b9eb969 commit 0dfd0bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ddh
Type: Package
Title: Utility Functions and Data Sets for Data-driven Hypothesis
Version: 0.3.38
Version: 0.3.39
Authors@R: c(
person(given = "Matthew",
family = "Hirschey",
Expand Down
28 changes: 18 additions & 10 deletions R/tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -832,23 +832,31 @@ make_molecular_features_segments_table <- function(input = list(),
#' \dontrun{
#' make_molecular_features_table(input = list(type = 'gene', content = 'ROCK1'))
#' }
make_molecular_features_table <- function(input = list(),
...) {
make_molecular_features_table <- function(input = list()) {
make_molecular_features_table_raw <- function() {
gene_summaries <- ddh::get_content("universal_gene_summary", dataset = TRUE)[,1:2]
gene_molecular_features_hits <-

gene_molecular_features_hits_raw <-
ddh::get_data_object(object_names = input$content,
dataset_name = "gene_molecular_features",
pivotwider = TRUE) %>%
dplyr::mutate(dplyr::across(dplyr::contains(c("logFC", "pval", "adjPval")), as.numeric)) %>%
dplyr::mutate_if(is.numeric, ~ signif(., digits = 3)) %>%
dplyr::select(-data_set) %>%
dplyr::left_join(gene_summaries, by = c("feature" = "approved_symbol")) %>%
dplyr::select(Query = id, Feature = feature, Description = approved_name, logFC, `P-value` = pval, FDR = adjPval) %>%
dplyr::mutate(Description = dplyr::case_when(grepl("TSS_", Feature) ~ paste0("DNA methylation (promoter 1kb upstream TSS) of ", gsub("TSS_", "", Feature)),
is.na(Description) ~ Feature,
TRUE ~ Description))
return(gene_molecular_features_hits)
dplyr::select(-data_set)

if (nrow(gene_molecular_features_hits_raw) > 0) {
gene_molecular_features_hits <-
gene_molecular_features_hits_raw %>%
dplyr::left_join(gene_summaries, by = c("feature" = "approved_symbol")) %>%
dplyr::select(Query = id, Feature = feature, Description = approved_name, logFC, `P-value` = pval, FDR = adjPval) %>%
dplyr::mutate(Description = dplyr::case_when(grepl("TSS_", Feature) ~ paste0("DNA methylation (promoter 1kb upstream TSS) of ", gsub("TSS_", "", Feature)),
is.na(Description) ~ Feature,
TRUE ~ Description))

return(gene_molecular_features_hits)
} else {
return(dplyr::tibble())
}
}
#error handling
tryCatch(make_molecular_features_table_raw(),
Expand Down
2 changes: 1 addition & 1 deletion man/make_molecular_features_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0dfd0bb

Please sign in to comment.