Skip to content

Commit

Permalink
Merge pull request #20 from mdozmorov/description_fix
Browse files Browse the repository at this point in the history
Strip technical info from the description field of gene annotations
  • Loading branch information
stephenturner authored Jan 8, 2022
2 parents 323e1ef + 304740e commit 4ece934
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions data-raw/build.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ get_data <- function(recipe) {
getBM(attr, mart = mart)
}
tidy_data <- function(df, recipe) {
df %>%
tidy_data <- function(df, recipe, tx = FALSE) {
df <- df %>%
as_tibble %>%
distinct %>%
rename(!!!syms(recipe$attributes)) %>%
arrange(!!sym("ensgene"))
if (!tx) {
df <- df %>% mutate(description = sub("\ \\[.+\\]", "", description, perl = TRUE))
}
return(df)
}
save_data <- function(..., name) {
Expand All @@ -53,7 +57,7 @@ recipes <- lapply(recipe.files, yaml.load_file)
genetables <- lapply(recipes, get_data)
# tidy gene tables
genetables <- Map(tidy_data, genetables, recipes)
genetables <- Map(tidy_data, genetables, recipes, FALSE)
# export data
Map(save_data, genetables, name = names(genetables))
Expand All @@ -76,7 +80,7 @@ recipes <- lapply(recipes, function(x) {
tx2gene <- lapply(recipes, get_data)
# tidy tx2gene
tx2gene <- Map(tidy_data, tx2gene, recipes)
tx2gene <- Map(tidy_data, tx2gene, recipes, TRUE)
# export data
Map(save_data, tx2gene, name = names(tx2gene))
Expand Down

0 comments on commit 4ece934

Please sign in to comment.