Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
env:
GH_REGISTRY: ghcr.io
GH_REGISTRY_USER: alexslemonade
AWS_REGISTRY: 997241705947.dkr.ecr.us-east-1.amazonaws.com
AWS_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com
AWS_PREFIX: ghcr_io

jobs:
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
if: ${{ github.event_name == 'push' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::997241705947:role/gha-ecr-access-role
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/gha-ecr-access-role
role-session-name: githubActionSession
aws-region: us-east-1

Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
if: ${{ github.event_name == 'push' }}
with:
role-to-assume: arn:aws:iam::997241705947:role/gha-ecr-access-role
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/gha-ecr-access-role
role-session-name: githubActionSession-${{ matrix.image_name }}
aws-region: us-east-1

Expand Down
56 changes: 15 additions & 41 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,35 @@
# All available hooks: https://pre-commit.com/hooks.html
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/posit-dev/air-pre-commit
# Air version
rev: 0.9.0
hooks:
# Run the formatter
- id: air-format
- repo: https://github.com/crate-ci/typos
rev: v1.45.0
hooks:
- id: typos
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.3
rev: v0.4.3.9021
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I badly want to suggest this, but I won't actually for obvious reasons. But clearly this should be...

rev: v0.4.3.90210

hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
# codemeta must be above use-tidy-description when both are used
# - id: codemeta-description-updated
- id: use-tidy-description
- id: spell-check
exclude: >
(?x)^(
.*\.[rR]|
.*\.feather|
.*\.jpeg|
.*\.pdf|
.*\.png|
.*\.py|
.*\.RData|
.*\.rds|
.*\.Rds|
.*\.Rproj|
.*\.sh|
(.*/|)\.gitattributes|
(.*/|)\.gitignore|
(.*/|)\.gitlab-ci\.yml|
(.*/|)\.lintr|
(.*/|)\.pre-commit-.*|
(.*/|)\.Rbuildignore|
(.*/|)\.Renviron|
(.*/|)\.Rprofile|
(.*/|)\.travis\.yml|
(.*/|)appveyor\.yml|
(.*/|)DESCRIPTION|
(.*/|)NAMESPACE|
(.*/|)pixi\.toml|
(.*/|)pixi\.lock|
(.*/|)renv/settings\.dcf|
(.*/|)renv.*\.lock|
(.*/|)requirements.*\.in|
(.*/|)requirements.*\.txt|
(.*/|).*Dockerfile|
(.*/|)WORDLIST|
\.github/workflows/.*|
data/.*|
)$
- id: lintr
- id: parsable-R
- id: no-browser-statement
- id: no-debug-statement
- id: deps-in-desc
exclude: docker/.*|renv/.*
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=200"]
- id: end-of-file-fixer
exclude: '\.Rd'
ci:
autofix_prs: true # set to false if we don't want fixes automatically applied by ci
autoupdate_schedule: quarterly
3 changes: 1 addition & 2 deletions R/add_cell_mito_qc.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ add_cell_mito_qc <- function(sce, mito, miQC = FALSE, ...) {
stop("sce must be a SingleCellExperiment object")
}

# check that mito is not empty, otherwise resulting colData will be innacurate
# check that mito is not empty, otherwise resulting colData will be inaccurate
if (length(mito) == 0) {
stop("Mitochondrial gene list not used, cannot calculate mitochondrial metrics.")
}
Expand All @@ -50,7 +50,6 @@ add_cell_mito_qc <- function(sce, mito, miQC = FALSE, ...) {
...
)


if (miQC) {
sce <- add_miQC(sce)
}
Expand Down
8 changes: 2 additions & 6 deletions R/processing_pcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ filter_pcs <- function(pcs, batches, rename_pcs = TRUE) {

# Check dimensions after filtering
if (nrow(pcs) != length(batches)) {
stop("Incompatable PC and batch information dimensions after removing NAs.")
stop("Incompatible PC and batch information dimensions after removing NAs.")
}

# rename PCs to batches if specified
Expand All @@ -34,7 +34,6 @@ filter_pcs <- function(pcs, batches, rename_pcs = TRUE) {
}



#' Downsample PCs for use in integration metric calculations
#'
#' @param pcs The PCs to downsample, these PCs should contain batch labels as rownames
Expand All @@ -55,10 +54,7 @@ downsample_pcs <- function(pcs, frac_cells, min_cells = 50) {
}

# Determines rows to sample
downsampled_indices <- sample(1:num_cells,
frac_cells * num_cells,
replace = FALSE
)
downsampled_indices <- sample(1:num_cells, frac_cells * num_cells, replace = FALSE)

# Extract PCs for downsample
downsampled_pcs <- pcs[downsampled_indices, , drop = FALSE]
Expand Down
2 changes: 1 addition & 1 deletion R/sim_sce.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sim_sce <- function(n_genes = 200, n_cells = 100, n_empty = 1000, n_groups = 3)
stop("n_genes must be a positive number.")
}
if (n_cells < 1) {
stop("n_cells must be a postive number.")
stop("n_cells must be a positive number.")
}
# enforce some minimums
n_empty <- max(n_empty, 0)
Expand Down
6 changes: 6 additions & 0 deletions air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[format]
line-width = 100
indent-width = 2
indent-style = "space"
line-ending = "lf"
skip = ["stopifnot"]
2 changes: 1 addition & 1 deletion docker/make-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail
# This script is used to generate or update requirements/lock files for R and Python packages
# Requires that the `pip-tools` python package is installed.
# Before running, make sure that the renv.lock file and installed libaries are
# Before running, make sure that the renv.lock file and installed libraries are
# consistent with renv::snapshot() or renv::restore()

# To upgrade packages, set the `UPGRADE_PY` environment variable as follows:
Expand Down
15 changes: 4 additions & 11 deletions tests/testthat/test-add_sample_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,29 @@ sample_metadata_df <- data.frame(
)

test_that("`add_sample_metadata` works as expected", {
updated_sce <- add_sample_metadata(sce,
metadata_df = sample_metadata_df
)
updated_sce <- add_sample_metadata(sce, metadata_df = sample_metadata_df)

expect_equal(
metadata(updated_sce)$sample_metadata,
sample_metadata_df
)
})

test_that("`add_sample_metadata` fails as exepected", {
test_that("`add_sample_metadata` fails as expected", {
# missing sce
expect_error(add_sample_metadata(
sce = "not an sce",
metadata_df = sample_metadata_df
))

# incorrect format for metadata_df
expect_error(add_sample_metadata(sce,
metadata_df = "not a data frame"
))

expect_error(add_sample_metadata(sce, metadata_df = "not a data frame"))

# incorrect sample id column
incorrect_metadata <- data.frame(
not_sample_id = "sample_id"
)
expect_error(add_sample_metadata(sce,
metadata_df = incorrect_metadata
))
expect_error(add_sample_metadata(sce, metadata_df = incorrect_metadata))

# sample ids don't match
metadata(sce)$sample_id <- "not a sample id"
Expand Down
35 changes: 6 additions & 29 deletions tests/testthat/test-integrate_sces.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ rownames(colData(merged_sce)) <- new_rownames
# Add "sample" to colData
colData(merged_sce)$sample <- batches
# Add in a "covariate" column for testing
colData(merged_sce)$covariate <- sample(letters[1:4],
size = 300,
replace = TRUE
)
colData(merged_sce)$covariate <- sample(letters[1:4], size = 300, replace = TRUE)

# add a logcounts assay for testing (numbers don't matter)
logcounts(merged_sce) <- counts(merged_sce)
Expand All @@ -29,11 +26,9 @@ batch_column <- "sample"

################################################################################



test_that("`integrate_fastmnn` works as expected", {
suppressWarnings(
# warnings are supressed here b/c simulated data plays poorly enough with
# warnings are suppressed here b/c simulated data plays poorly enough with
# algorithms to trigger warnings like:
### Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth = TRUE, :
### You're computing too large a percentage of total singular values, use a standard svd instead.
Expand Down Expand Up @@ -75,7 +70,6 @@ test_that("`integrate_harmony` works as expected", {
})



test_that("`integrate_harmony` fails when PCs are missing", {
reducedDim(merged_sce, "PCA") <- NULL
expect_error(
Expand All @@ -85,10 +79,7 @@ test_that("`integrate_harmony` fails when PCs are missing", {

test_that("`integrate_harmony` fails when covariate columns are missing", {
expect_error(
integrate_harmony(merged_sce,
batch_column,
covariate_cols = "not_a_column"
)
integrate_harmony(merged_sce, batch_column, covariate_cols = "not_a_column")
)
})

Expand All @@ -108,7 +99,6 @@ test_that("`integrate_harmony` fails when covariates and covariate_lambda don't
################################################################################
################################################################################


test_that("`integrate_sces` fail as expected", {
# bad sce
expect_error(
Expand All @@ -122,10 +112,7 @@ test_that("`integrate_sces` fail as expected", {

# missing batch column
expect_error(
integrate_sces(merged_sce,
"fastMNN",
batch_column = "not_a_column"
)
integrate_sces(merged_sce, "fastMNN", batch_column = "not_a_column")
)

# insufficient batches
Expand Down Expand Up @@ -163,10 +150,7 @@ test_that("`integrate_sces` works as expected for return_corrected_expression=TR
# fastmnn:
suppressWarnings({
# simulated-data related numerical warnings
integrated_sce <- integrate_sces(merged_sce,
"fastMNN",
return_corrected_expression = TRUE
)
integrated_sce <- integrate_sces(merged_sce, "fastMNN", return_corrected_expression = TRUE)
})

expect_equal(
Expand All @@ -186,23 +170,16 @@ test_that("`integrate_sces` works as expected for return_corrected_expression=TR
})





test_that("`integrate_sces` works as expected with fastmnn extra arguments", {
expect_no_error(
suppressWarnings({
# simulated-data related numerical warnings
integrated_sce <- integrate_sces(merged_sce,
"fastMNN",
cos.norm = FALSE
)
integrated_sce <- integrate_sces(merged_sce, "fastMNN", cos.norm = FALSE)
})
)
})



test_that("`integrate_sces` works as expected for harmony defaults", {
integrated_sce <- integrate_sces(
merged_sce,
Expand Down
Loading
Loading