Skip to content

Commit

Permalink
Fix ref download issue. Add template checker
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Oct 2, 2024
1 parent 7b779c1 commit 4519395
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ assignees: ''

---

:warning: :warning: :warning:
PLEASE NOTE, YOUR ISSUE WILL BE AUTOMATICALLY CLOSED IF IT DOES NOT USE AND COMPLETE THE TEMPLATE.
These templates are designed to give us the basic information necessary to help debug your issues.
:warning: :warning: :warning:

## 1. Bug description

(A clear and concise description of what the bug is.)
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/auto-close-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
issues:
types: [opened, edited]

jobs:
auto_close_issues:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Automatically close issues that don't follow the issue template
uses: lucasbento/auto-close-issues@v1.0.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
issue-close-message: "@${issue.user.login}: hello! :wave:\n\nThis issue is being automatically closed because it does not follow the issue template." # optional property
closed-issues-label: "🙁 Not following issue template" # optional property
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: MAGMA.Celltyping
Type: Package
Title: Find Causal Cell-Types Underlying Complex Trait Genetics
Version: 2.0.12
Version: 2.0.13
Authors@R:
c(person(given = "Brian",
family = "Schilder",
Expand Down Expand Up @@ -73,6 +73,6 @@ Suggests:
SystemRequirements: A system installation of
[MAGMA](https://ctg.cncr.nl/software/magma) is required
but can be installed automatically by this package.
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Encoding: UTF-8
Config/testthat/edition: 3
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# MAGMA.Celltyping 2.0.13

## New features

* Fully remove deprecated function `format.sumstats.for.magma`
* Add auto-close-template: https://github.com/marketplace/actions/auto-close-issues

## Bug fixes

* Update URLs for getting MAGMA reference genome files (#154).
* *test-magma_links.R*: `package_version` comparisons now only work with strings instead of numbers.

# MAGMA.Celltyping 2.0.12

## Bug fixes
Expand Down
5 changes: 1 addition & 4 deletions R/format_sumstats_for_magma.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,4 @@ format_sumstats_for_magma <- function(path) {
mungesumstats_deprecation_msg()
}


format.sumstats.for.magma <- function(path){
format_sumstats_for_magma(path)
}

2 changes: 1 addition & 1 deletion R/get_example_gwas_raw.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#'
#' Write example GWAS summary statistics to disk.
#'
#' @param save_path Path to save sum stats.
#' @param timeout How many seconds to wait before timeout.
#' @param verbose Print messages.
#' @inheritParams get_data
#'
#' @return Path to sumstats
#'
Expand Down
20 changes: 9 additions & 11 deletions R/get_genome_ref.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,21 @@
#'
#' @examples
#' \dontrun{
#' genome_ref_path <- MAGMA.Celltyping::get_genome_ref()
#' genome_ref_path <- get_genome_ref()
#' }
get_genome_ref <- function(genome_ref_path = NULL,
storage_dir = tools::R_user_dir(
"MAGMA.Celltyping",
which="cache"),
method = c("magma","piggback"),
method = c("magma"),
population = c("eur", "afr", "amr", "eas", "sas"),
timeout = 60 * 5,
verbose = TRUE) {
#### population ####
dir.create(storage_dir,showWarnings = FALSE, recursive = TRUE)
population <- tolower(population[1])
population <- match.arg(population)
method <- tolower(method[1])
pop_opts <- c("eur", "afr", "amr", "eas", "sas")
if (!population %in% pop_opts) {
stop_msg <- paste0(
"population must be one of:\n",
paste0(" - ", pop_opts, collapse = "\n")
)
stop(stop_msg)
}
#### Set up paths ####
if (is.null(genome_ref_path)) {
genome_ref_dir <- file.path(storage_dir,
Expand Down Expand Up @@ -83,7 +76,12 @@ get_genome_ref <- function(genome_ref_path = NULL,
verbose = verbose
)
}

### Reference file is too large to be stored in GitHub Releases now
#else if(method == "piggyback"){
# get_genome_ref_piggyback(
# genome_ref_dir = genome_ref_dir,
# verbose = verbose
# )
}
#### Return the folder + the file prefix ####
return(genome_ref_path)
Expand Down
16 changes: 10 additions & 6 deletions R/get_genome_ref_magma.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
#'
#' @param genome_ref_dir Folder to download reference to.
#' @param verbose Print messages.
#' @source \href{https://ctg.cncr.nl/software/MAGMA/ref_data/}{MAGMA archives}
#' @source \href{https://cncr.nl/research/magma/}{MAGMA site}
#'
#' @keywords internal
get_genome_ref_magma <- function(genome_ref_dir,
population = "eur",
timeout = 60 * 5,
verbose = TRUE) {
#### Get link ####
input_url <- paste(
"https://ctg.cncr.nl/software/MAGMA",
"ref_data",paste0(basename(genome_ref_dir),".zip"),
sep="/"
)
link_dict <- list(
"g1000_eur"="https://vu.data.surfsara.nl/index.php/s/VZNByNwpD8qqINe/download",
"g1000_afr"="https://vu.data.surfsara.nl/index.php/s/ePXET6IWVTwTes4/download",
"g1000_eas"="https://vu.data.surfsara.nl/index.php/s/dz6PYdKOi3xVqHn/download",
"g1000_sas"="https://vu.data.surfsara.nl/index.php/s/C6UkTV5nuFo8cJC/download",
"g1000_amr"="https://vu.data.surfsara.nl/index.php/s/TXDEm70eEO7AgOb/download"
)
input_url <- link_dict[[paste0("g1000_",tolower(population))]]
##### Link to 1000 genomes reference data. ####
zipfile <- sprintf("%s.zip", genome_ref_dir)
#### Download file ####
Expand Down
9 changes: 6 additions & 3 deletions R/get_genome_ref_piggyback.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@
#'
#' @param genome_ref_dir Folder to download reference to.
#' @param verbose Print messages.
#' @inheritDotParams get_data
#' @source
#' \code{
#' genome_ref_path <- MAGMA.Celltyping::get_genome_ref(method = "magma")
#' genome_ref_path <- get_genome_ref(method = "magma")
#'
#' piggyback::pb_upload(file = genome_ref_path,
#' repo = "neurogenomics/MAGMA_Celltyping",
#' overwrite = TRUE)
#' }
#' @keywords internal
get_genome_ref_piggyback <- function(genome_ref_dir,
verbose = TRUE) {
verbose = TRUE,
...) {
##### Link to 1000 genomes reference data. ####
zipfile <- sprintf("%s.zip", genome_ref_dir)
#### Download file ####
options(timeout = 60 * 5)
get_data(paste0(basename(genome_ref_dir),".zip"),
repo = "neurogenomics/MAGMA_Celltyping",
storage_dir = genome_ref_dir)
storage_dir = genome_ref_dir,
...)
#### Unzip file ####
messager("Unzipping file.", v = verbose)
utils::unzip(
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<img src='https://github.com/neurogenomics/MAGMA_Celltyping/raw/master/inst/hex/hex.png' title='Hex sticker for MAGMA.Celltyping' height='300'><br>
[![License:
GPL-3](https://img.shields.io/badge/license-GPL--3-blue.svg)](https://cran.r-project.org/web/licenses/GPL-3)
[![](https://img.shields.io/badge/devel%20version-2.0.9-black.svg)](https://github.com/neurogenomics/MAGMA_Celltyping)
[![](https://img.shields.io/badge/devel%20version-2.0.13-black.svg)](https://github.com/neurogenomics/MAGMA_Celltyping)
[![](https://img.shields.io/github/languages/code-size/neurogenomics/MAGMA_Celltyping.svg)](https://github.com/neurogenomics/MAGMA_Celltyping)
[![](https://img.shields.io/github/last-commit/neurogenomics/MAGMA_Celltyping.svg)](https://github.com/neurogenomics/MAGMA_Celltyping/commits/master)
<br> [![R build
status](https://github.com/neurogenomics/MAGMA_Celltyping/workflows/rworkflows/badge.svg)](https://github.com/neurogenomics/MAGMA_Celltyping/actions)
[![](https://codecov.io/gh/neurogenomics/MAGMA_Celltyping/branch/master/graph/badge.svg)](https://codecov.io/gh/neurogenomics/MAGMA_Celltyping)
[![](https://codecov.io/gh/neurogenomics/MAGMA_Celltyping/branch/master/graph/badge.svg)](https://app.codecov.io/gh/neurogenomics/MAGMA_Celltyping)
<br>
<a href='https://app.codecov.io/gh/neurogenomics/MAGMA_Celltyping/tree/master' target='_blank'><img src='https://codecov.io/gh/neurogenomics/MAGMA_Celltyping/branch/master/graphs/icicle.svg' title='Codecov icicle graph' width='200' height='50' style='vertical-align: top;'></a>
<h4>
Authors: <i>Brian Schilder, Alan Murphy, Julien Bryois, Nathan
Skene</i>
</h4>
<h4>
README updated: <i>Apr-12-2023</i>
README updated: <i>Oct-02-2024</i>
</h4>

## Introduction
Expand Down
2 changes: 0 additions & 2 deletions man/get_example_gwas_raw.Rd

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

4 changes: 2 additions & 2 deletions man/get_genome_ref.Rd

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

9 changes: 7 additions & 2 deletions man/get_genome_ref_magma.Rd

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

14 changes: 12 additions & 2 deletions man/get_genome_ref_piggyback.Rd

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

6 changes: 3 additions & 3 deletions tests/testthat/test-magma_links.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ test_that("magma_links works", {
magma_mac <-MAGMA.Celltyping:::magma_links(latest_only = TRUE,
os = "Mac",
verbose = FALSE)
testthat::expect_true(to_version(magma_mac)>=1.1)
testthat::expect_true(to_version(magma_mac)>="1.1")

#### Windows ####
magma_win <- MAGMA.Celltyping:::magma_links(latest_only = TRUE,
os = "Windows")
testthat::expect_true(to_version(magma_win)>=1.1)
testthat::expect_true(to_version(magma_win)>="1.1")

#### Linux ####
magma_linux <- MAGMA.Celltyping:::magma_links(latest_only = TRUE,
os = "Linux")
testthat::expect_true(to_version(magma_linux)>=1.1)
testthat::expect_true(to_version(magma_linux)>="1.1")

#### All ####
meta <- MAGMA.Celltyping:::magma_links(latest_only = FALSE,
Expand Down

0 comments on commit 4519395

Please sign in to comment.