Skip to content

Commit

Permalink
Merge revamp-tests (#31)
Browse files Browse the repository at this point in the history
Update tests to testthat 3rd edition, amongst many 
other small changes.
  • Loading branch information
csdaw authored Oct 5, 2021
2 parents 35446d5 + 69a3a5e commit d241032
Show file tree
Hide file tree
Showing 112 changed files with 17,638 additions and 4,696 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ jobs:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, r: '4.0', bioc: '3.12', cont: "bioconductor/bioconductor_docker:RELEASE_3_12", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: macOS-latest, r: '4.0', bioc: '3.12'}
- { os: windows-latest, r: '4.0', bioc: '3.12'}
- { os: ubuntu-latest, r: '4.1', bioc: '3.13', cont: "bioconductor/bioconductor_docker:RELEASE_3_13", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: macOS-latest, r: '4.1', bioc: '3.13'}
- { os: windows-latest, r: '4.1', bioc: '3.13'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
Expand Down Expand Up @@ -106,16 +106,16 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_13-r-4.1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_13-r-4.1-

- name: Cache R packages on Linux
if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' "
uses: actions/cache@v2
with:
path: /home/runner/work/_temp/Library
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_13-r-4.1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_13-r-4.1-

- name: Install Linux system dependencies
if: runner.os == 'Linux'
Expand Down Expand Up @@ -182,11 +182,12 @@ jobs:
run: |
## Pass #2 at installing dependencies
message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****'))
remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE)
remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE, force = TRUE)
## For running the checks
message(paste('****', Sys.time(), 'installing rcmdcheck ****'))
message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****'))
remotes::install_cran("rcmdcheck")
## BiocManager::install("BiocCheck")
shell: Rscript {0}

- name: Install BiocGenerics
Expand Down Expand Up @@ -264,7 +265,7 @@ jobs:
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-results
name: ${{ runner.os }}-biocversion-RELEASE_3_13-r-4.1-results
path: check

- uses: docker/build-push-action@v1
Expand Down
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
VignetteBuilder: knitr
Remotes: moodymudskipper/cutr
biocViews:
Expand All @@ -39,4 +39,7 @@ Imports:
Suggests:
knitr,
rmarkdown,
testthat
testthat (>= 3.0.0),
vdiffr (>= 1.0.0),
withr
Config/testthat/edition: 3
27 changes: 27 additions & 0 deletions R/download_ccp_crap.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
#' Get the UniProt sequences in CCP cRAP
#'
#' @description This function take no inputs and simply outputs a vector of the
#' UniProt accessions for the sequences in the CCP cRAP FASTA.
#'
#' @return Returns a `character vector` of UniProt accessions.
#' @export
get_ccp_crap <- function() {
# load ccp crap and extract accessions
input <- Biostrings::readAAStringSet(
filepath = system.file("extdata", "cRAP_20190401.fasta.gz", package = "camprotR")
) %>%
names()

accessions <- regmatches(
input,
gregexpr("(?<=\\|)[A-Z,0-9]{6}(?=\\|)", input, perl = TRUE)
) %>%
unlist()

accessions[!accessions %in% "000000"]

# deal with alpha amylase proteins specifically
accessions[4:6] <- c("P0DUB6", "P0DTE7", "P0DTE8")
accessions
}

#' Download CCP cRAP FASTA file
#'
#' @description This function is used to download the Cambridge Centre for
Expand Down
61 changes: 29 additions & 32 deletions R/make_fasta.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,3 @@
#' Get the UniProt sequences in CCP cRAP
#'
#' @description This function take no inputs and simply outputs a vector of the
#' UniProt accessions for the sequences in the CCP cRAP FASTA.
#'
#' @return Returns a `character vector` of UniProt accessions.
#' @export
get_ccp_crap <- function() {
# load ccp crap and extract accessions
input <- Biostrings::readAAStringSet(
filepath = system.file("extdata", "cRAP_20190401.fasta", package = "camprotR")
) %>%
names()

accessions <- regmatches(
input,
gregexpr("(?<=\\|)[A-Z,0-9]{6}(?=\\|)", input, perl = TRUE)
) %>%
unlist()

accessions[!accessions %in% "000000"]

# deal with alpha amylase proteins specifically
accessions[4:6] <- c("P0DUB6", "P0DTE7", "P0DTE8")
accessions
}

#' Make a FASTA using UniProt accessions
#'
#' @description Given a vector of UniProt accessions, this function will:
Expand Down Expand Up @@ -63,10 +36,21 @@ make_fasta <- function(accessions, file, is_crap = FALSE, overwrite = FALSE, ver
)

# query uniprot and save FASTA to disk
response <- httr::GET(
url = "https://www.uniprot.org/uploadlists/",
query = payload,
config = httr::write_disk(path = file, overwrite = overwrite)
# security level fix for Ubuntu 20.04
# see https://msmith.de/2020/10/02/httr-curl-ubuntu-20-04.html
httr_config <- switch(
Sys.info()["sysname"],
"Linux" = httr::config(ssl_cipher_list = "DEFAULT@SECLEVEL=1"),
httr::config()
)

response <- httr::with_config(
config = httr_config,
httr::GET(
url = "https://www.uniprot.org/uploadlists/",
query = payload,
config = httr::write_disk(path = file, overwrite = overwrite)
)
)

# basic http error handling
Expand Down Expand Up @@ -146,7 +130,20 @@ sub_crap <- function(x, start = 1, width = 3) {
#' @export
check_uniprot_release <- function() {
# query H. sapiens actin
response <- httr::GET(url = "https://www.uniprot.org/uniprot/P60709")
# security level fix for Ubuntu 20.04
# see https://msmith.de/2020/10/02/httr-curl-ubuntu-20-04.html
httr_config <- switch(
Sys.info()["sysname"],
"Linux" = httr::config(ssl_cipher_list = "DEFAULT@SECLEVEL=1"),
httr::config()
)

response <- httr::with_config(
config = httr_config,
httr::GET(
url = "https://www.uniprot.org/uniprot/P60709"
)
)

# basic http error handling
httr::stop_for_status(response, "query UniProt")
Expand Down
12 changes: 12 additions & 0 deletions R/pep_silac_p0.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#' PeptideGroups PD output for SILAC labelled MOLM-13 cells
#'
#' @description Passage 0, 100% light (R0K0).
#'
#' \describe{
#' \item{column name}{`class`. Description.}
#' }
#'
#' @references Insert reference here when published.
#'
#' @keywords datasets
"pep_silac_p0"
12 changes: 12 additions & 0 deletions R/pep_silac_p4.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#' PeptideGroups PD output for SILAC labelled MOLM-13 cells
#'
#' @description Passage 4, 1:1 light:heavy mixture (R0K0:R10K8).
#'
#' \describe{
#' \item{column name}{`class`. Description.}
#' }
#'
#' @references Insert reference here when published.
#'
#' @keywords datasets
"pep_silac_p4"
12 changes: 12 additions & 0 deletions R/psm_silac_p4.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#' PSMs PD output for SILAC labelled MOLM-13 cells
#'
#' @description Passage 4, 1:1 light:heavy mixture (R0K0:R10K8).
#'
#' \describe{
#' \item{column name}{`class`. Description.}
#' }
#'
#' @references Insert reference here when published.
#'
#' @keywords datasets
"psm_silac_p4"
10 changes: 6 additions & 4 deletions R/ptm.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ parse_PTM_scores <- function(obj,
#' to add 'filtered_pos' column
#'
#' @param obj `data.frame` with PD output at PSM/peptide level
#' @param proteome_fasta `character` Filepath for proteome fasta
#' @param master_protein_col `character` Column name for master protein
#' @param proteome_fasta `string` Filepath for proteome fasta
#' @param master_protein_col `string` Name of column containing master protein IDs
#' @param sequence_col `string`. Name of column containing peptide sequences
#'
#' @return `data.frame`
#' @export
add_PTM_positions <- function(obj, proteome_fasta, master_protein_col = "Master.Protein.Accessions") {
add_PTM_positions <- function(obj, proteome_fasta, master_protein_col = "Master.Protein.Accessions",
sequence_col = "Sequence") {
proteome <- Biostrings::readAAStringSet(proteome_fasta)
names(proteome) <- sapply(base::strsplit(names(proteome), split = "\\|"), "[[", 2)

Expand Down Expand Up @@ -182,7 +184,7 @@ add_PTM_positions <- function(obj, proteome_fasta, master_protein_col = "Master.
obj$ptm_position <- apply(
obj,
MARGIN = 1, function(x) combine_peptide_ptm_positions(
proteome, x[[master_protein_col]], x[["Sequence"]], x[["filtered_pos"]]
proteome, x[[master_protein_col]], x[[sequence_col]], x[["filtered_pos"]]
)
)

Expand Down
20 changes: 20 additions & 0 deletions data-raw/pep_silac_p0.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
library(dplyr)

# Read in SILAC passage 0 peptide data
# 100% light cells (R0K0)
pepg <- read.delim(
here::here("data-raw/Molm_13_P0_PeptideGroups.txt")
)

# Remove extraneous periods from colnames
colnames(pepg) <- remove_dots(colnames(pepg))

# Set seed for reproducible sampling
set.seed(2021)

# Get all peptides for a random sample of 100 Master proteins
pep_silac_p0 <- pepg %>%
filter(Master.Protein.Accessions %in% sample(unique(Master.Protein.Accessions), 100))

# Output .rda file
usethis::use_data(pep_silac_p0, overwrite = TRUE)
20 changes: 20 additions & 0 deletions data-raw/pep_silac_p4.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
library(dplyr)

# Read in SILAC passage 4 peptide data
# 50:50 mix of light:heavy cells (R0K0:R10K8)
pepg <- read.delim(
here::here("data-raw/Molm_13_P4_PeptideGroups.txt")
)

# Remove extraneous periods from colnames
colnames(pepg) <- remove_dots(colnames(pepg))

# Set seed for reproducible sampling
set.seed(2021)

# Get all peptides for a random sample of 100 Master proteins
pep_silac_p4 <- pepg %>%
filter(Master.Protein.Accessions %in% sample(unique(Master.Protein.Accessions), 100))

# Output .rda file
usethis::use_data(pep_silac_p4, overwrite = TRUE)
17 changes: 17 additions & 0 deletions data-raw/psm_silac_p4.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
library(dplyr)

# Read in SILAC passage 4 peptide data
# 50:50 mix of light:heavy cells (R0K0:R10K8)
silac_p4 <- read.delim(
here::here("data-raw/Molm_13_P4_PSMs.txt")
)

# Set seed for reproducible sampling
set.seed(2021)

# Get all PSMs for a random sample of 100 Master proteins
psm_silac_p4 <- silac_p4 %>%
filter(Master.Protein.Accessions %in% sample(unique(Master.Protein.Accessions), 100))

# Output .rda file
usethis::use_data(psm_silac_p4, overwrite = TRUE)
26 changes: 0 additions & 26 deletions data-raw/small_pep_silac.R

This file was deleted.

26 changes: 0 additions & 26 deletions data-raw/small_pep_silac2.R

This file was deleted.

23 changes: 0 additions & 23 deletions data-raw/small_psm_silac.R

This file was deleted.

Loading

0 comments on commit d241032

Please sign in to comment.