diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9e28085..873fda3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -43,10 +43,14 @@ body: If that's not possible, please at least include a screenshot of your data and other relevant details. See [here](https://www.r-bloggers.com/2020/10/how-to-make-a-reprex/) for an intro to making a reproducible example (i.e. reprex) and why they're important! + + Surrounding your code in triple backticks will render it nicely on GitHub. placeholder: | # For example: + ```R df <- data.frame(list(a=rep(2,3), b=rep(1,3))) df["bTYPO"] + ``` validations: required: true @@ -58,7 +62,9 @@ body: Copy and paste the R console output. placeholder: | # For example: + ```R Error in `[.data.frame`(df, "bTYPO") : undefined columns selected + ``` validations: required: true @@ -82,6 +88,7 @@ body: description: | Copy and paste the output of the `sessionInfo() R function. placeholder: | + ```R R version 4.4.1 (2024-06-14) Platform: aarch64-apple-darwin20 Running under: macOS 15.0 @@ -101,4 +108,5 @@ body: ... ... ... + ``` diff --git a/DESCRIPTION b/DESCRIPTION index 53c44ff..c067e7d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: MAGMA.Celltyping Type: Package Title: Find Causal Cell-Types Underlying Complex Trait Genetics -Version: 2.0.13 +Version: 2.0.14 Authors@R: c(person(given = "Brian", family = "Schilder", diff --git a/NEWS.md b/NEWS.md index 9d94541..47b724f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,14 @@ +# MAGMA.Celltyping 2.0.14 + +## New features + +* Make sure `get_example_gwas` caches data. + +## Bug fixes + +* `create_gene_covar_file`: Add check to drop duplicate cell types (after ignoring case) +* `load_magma_results_file`: Update message to include scenario where cell types dropped due to be duplicated. + # MAGMA.Celltyping 2.0.13 ## New features diff --git a/R/calculate_celltype_associations.r b/R/calculate_celltype_associations.r index fc9f05e..3a023df 100644 --- a/R/calculate_celltype_associations.r +++ b/R/calculate_celltype_associations.r @@ -104,7 +104,6 @@ calculate_celltype_associations <- function(ctd, path <- sprintf("%s.%s.gsa.out", sumstatsPrefix2, analysis_name) - path <- get_actual_path(path) #### Use existing results, or compute new ones #### if ((!file.exists(path)) || isTRUE(force_new)) { diff --git a/R/check_quantiles.R b/R/check_quantiles.R index 2d75dad..e306c2c 100644 --- a/R/check_quantiles.R +++ b/R/check_quantiles.R @@ -16,7 +16,8 @@ check_quantiles <- function(ctd, function(lvl, .matrix_name=matrix_name, .metric=metric[1]){ - messager("Checking CTD: level ",lvl,v=TRUE, parallel = TRUE) + messager("Checking CTD ",matrix_name," matrix: ", + "level ",lvl,v=TRUE, parallel = TRUE) ctd_1lvl <- ctd[[lvl]] if(.metric=="n"){ col_unique <- apply(ctd_1lvl[[.matrix_name]], 2, diff --git a/R/create_gene_covar_file.r b/R/create_gene_covar_file.r index 33303da..dd1de98 100644 --- a/R/create_gene_covar_file.r +++ b/R/create_gene_covar_file.r @@ -86,9 +86,21 @@ create_gene_covar_file <- function(genesOutFile, dup_genes <- duplicated(quantDat2$entrez) if(sum(dup_genes, na.rm = TRUE)>0){ messager("Removing", sum(dup_genes, na.rm = TRUE), - "genes with duplicate entrez IDs.",v=verbose) + "gene(s) with duplicate entrez IDs.",v=verbose) quantDat2 <- quantDat2[!dup_genes,] } + #### Ensure there are no duplicate cell types when ignoring case (which MAGMA does) #### + dup_ct <- duplicated(toupper(colnames(quantDat2))) + if(sum(dup_ct)>0){ + messager("Removing", sum(dup_ct, na.rm = TRUE), + "cell type(s) with duplicate cell types (when ignoring upper/lowercase):", + paste(shQuote(colnames(quantDat2)[dup_ct]), collapse = ","), + "Please consider regenerating your CTD object with", + "unique cell type names (when ignoring upper/lowercase)", + "for more accurate results.", + v=verbose) + quantDat2 <- quantDat2[,!dup_ct] + } #### Write genes covar file to disk #### geneCovarFile <- tempfile() utils::write.table( diff --git a/R/get_example_gwas.R b/R/get_example_gwas.R index e131cff..141cf4a 100644 --- a/R/get_example_gwas.R +++ b/R/get_example_gwas.R @@ -61,7 +61,8 @@ get_example_gwas <- function(trait = c( "prospective_memory" ), munged = TRUE, - storage_dir = tempdir(), + storage_dir = tools::R_user_dir("MAGMA.Celltyping", + which="cache"), timeout = 60 * 5, verbose = TRUE) { trait <- tolower(trait)[1] diff --git a/R/load_magma_results_file.r b/R/load_magma_results_file.r index c3c7975..7e26bb9 100644 --- a/R/load_magma_results_file.r +++ b/R/load_magma_results_file.r @@ -93,7 +93,8 @@ load_magma_results_file <- function(path, messager(numCTinCTD, "celltypes in ctd but",numCTinRes,"in results file.", "Some celltypes may have been dropped due if the variance", - "being too low (i.e. set contains only one gene used in analysis).") + "being too low (i.e. set contains only one gene used in analysis)", + "OR duplicate celltype names (after ignoring case).") messager( "<50% of celltypes missing.", "Attemping to fix by removing missing cell-types:\n", diff --git a/R/prepare_quantile_groups.r b/R/prepare_quantile_groups.r index f3d7f43..93f2b76 100644 --- a/R/prepare_quantile_groups.r +++ b/R/prepare_quantile_groups.r @@ -46,7 +46,7 @@ prepare_quantile_groups <- function(ctd, ctd <- lapply(ctd, EWCE::bin_specificity_into_quantiles, numberOfBins = numberOfBins, matrix_name = "specificity_quantiles") - } + } #### Compute specificity deciles #### ctd <- lapply(ctd, EWCE::bin_specificity_into_quantiles, numberOfBins = 10, diff --git a/man/get_example_gwas.Rd b/man/get_example_gwas.Rd index b5dd006..db322d1 100644 --- a/man/get_example_gwas.Rd +++ b/man/get_example_gwas.Rd @@ -40,7 +40,7 @@ piggyback::pb_upload(file = path_formatted, get_example_gwas( trait = c("educational_attainment", "fluid_intelligence", "prospective_memory"), munged = TRUE, - storage_dir = tempdir(), + storage_dir = tools::R_user_dir("MAGMA.Celltyping", which = "cache"), timeout = 60 * 5, verbose = TRUE )