Skip to content

Commit

Permalink
- applyFlowJoGate() can now match sample file with sample names in ws…
Browse files Browse the repository at this point in the history
…p file,

by using pattern matching, instead of full file name matching
- bumped version to 0.99.3
  • Loading branch information
phauchamps committed Feb 6, 2024
1 parent 457d7e3 commit cb74fe2
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 31 deletions.
78 changes: 49 additions & 29 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env:
run_covr: 'true'
run_pkgdown: 'true'
has_RUnit: 'false'
has_BiocCheck: 'false'
has_BiocCheck: 'true'
cache-version: 'cache-v1'

jobs:
Expand All @@ -52,9 +52,9 @@ jobs:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, r: '4.3', bioc: '3.18', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
# - { os: macOS-latest, r: '4.3', bioc: '3.18'}
# - { os: windows-latest, r: '4.3', bioc: '3.18'}
- { os: ubuntu-latest, r: '4.4', bioc: '3.19', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
# - { os: macOS-latest, r: '4.4', bioc: '3.19'}
# - { os: windows-latest, r: '4.4', bioc: '3.19'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
Expand All @@ -63,7 +63,7 @@ jobs:
VDIFFR_RUN_TESTS: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: 'f726ac0c-aee0-4b48-9ee0-a40acd0fac44'
CODECOV_TOKEN: 'bf6cfe55-b854-46d9-a5e7-a7874ae7c90e'

steps:

Expand Down Expand Up @@ -163,6 +163,12 @@ jobs:
message(paste('****', Sys.time(), 'installing BiocManager ****'))
remotes::install_cran("BiocManager")
shell: Rscript {0}

# - name: Manually install vdiffr in version 1.0.5 to avoid compil error
# run: |
# BiocManager::install("remotes")
# remotes::install_version("vdiffr", version = "1.0.5")
# shell: Rscript {0}

- name: Set BiocVersion
run: |
Expand All @@ -171,28 +177,38 @@ jobs:

- name: Install dependencies
run: |
## Try installing the package dependencies in steps. First the local
## dependencies, then any remaining dependencies to avoid the
## issues described at
## https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016675.html
## https://github.com/r-lib/remotes/issues/296
## Ideally, all dependencies should get installed in the first pass.
## Pass #1 at installing dependencies
message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****'))
local_deps <- remotes::local_package_deps(dependencies = TRUE)
deps <- remotes::dev_package_deps(dependencies = TRUE, repos = BiocManager::repositories())
BiocManager::install(local_deps[local_deps %in% deps$package[deps$diff != 0]])
## Pass #2 at installing dependencies
message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****'))
deps <- remotes::dev_package_deps(dependencies = TRUE, repos = BiocManager::repositories())
BiocManager::install(deps$package[deps$diff != 0])
## For running the checks
message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****'))
remotes::install_cran("rcmdcheck")
BiocManager::install("BiocCheck")
## work around a change in compiler setting, turning some warnings into
## errors => deactivate warnings to allow some dependency package to
## compile
withr::with_makevars(
c(CFLAGS = "-w",
CXXFLAGS = "-w",
CPPFLAGS = "-w"),
{
## Try installing the package dependencies in steps. First the local
## dependencies, then any remaining dependencies to avoid the
## issues described at
## https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016675.html
## https://github.com/r-lib/remotes/issues/296
## Ideally, all dependencies should get installed in the first pass.
## Pass #1 at installing dependencies
message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****'))
local_deps <- remotes::local_package_deps(dependencies = TRUE)
deps <- remotes::dev_package_deps(dependencies = TRUE, repos = BiocManager::repositories())
BiocManager::install(local_deps[local_deps %in% deps$package[deps$diff != 0]])
## Pass #2 at installing dependencies
message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****'))
deps <- remotes::dev_package_deps(dependencies = TRUE, repos = BiocManager::repositories())
BiocManager::install(deps$package[deps$diff != 0])
## For running the checks
message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****'))
remotes::install_cran("rcmdcheck")
BiocManager::install("BiocCheck")
},
assignment = "+=")
shell: Rscript {0}

## Fix error: The magick package is required to crop "...png" but not available.
Expand All @@ -218,7 +234,11 @@ jobs:
##if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
if: env.run_pkgdown == 'true' && runner.os == 'Linux'
run: |
remotes::install_github("r-lib/pkgdown")
withr::with_makevars(
c(CFLAGS = "-w",
CXXFLAGS = "-w"),
remotes::install_github("r-lib/pkgdown"),
assignment = "+=")
shell: Rscript {0}

- name: Session info
Expand Down Expand Up @@ -280,7 +300,7 @@ jobs:
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git config --global --add safe.directory /__w/CytoPipeline/CytoPipeline
git config --global --add safe.directory /__w/CytoPipelineUtils/CytoPipelineUtils
Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE)"
shell: bash {0}
## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CytoPipelineUtils
Title: Utils for use with CytoPipeline
Version: 0.99.2
Version: 0.99.3
Authors@R:
c(person(given = "Philippe",
family = "Hauchamps",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CytoPipelineUtils 0.99

## CytoPipelineUtils 0.99.3
- applyFlowJoGate() can now match sample file with sample names in wsp file,
by using pattern matching, instead of full file name matching

## CytoPipelineUtils 0.99.2
- added 2nd version of removeDebrisFlowClust()
- applyFlowJoGate() can now use different flowJo wsp files, depending on pData
Expand Down
17 changes: 16 additions & 1 deletion R/CytoProcessingStepImplementations.R
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,22 @@ applyFlowJoGate <- function(ff,
"=> not possible to identify sample in FlowJo workspace")
}

sampleID <- sampleDF[sampleDF$name == fcsName, "sampleID", drop = TRUE]
fcsNameNoExtension <- tools::file_path_sans_ext(fcsName)

sampleNameMatch <- vapply(sampleDF$name,
FUN = function(x, fileName){
xNoExtension <- tools::file_path_sans_ext(x)
test1 <- grepl(fileName,
xNoExtension,
ignore.case = TRUE)
test2 <- grepl(xNoExtension,
fileName,
ignore.case = TRUE)
test1 | test2},
FUN.VALUE = TRUE,
fileName = fcsNameNoExtension)

sampleID <- sampleDF[sampleNameMatch, "sampleID", drop = TRUE]

if (length(sampleID) == 0) {
stop("Could not find sampleID attached to sample name : [",
Expand Down
28 changes: 28 additions & 0 deletions tests/testthat/test-CytoProcessingStepImplementations.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,39 @@ test_that("applyFlowJoGate works", {

# saveRDS(ff_FJ_gated1, test_path("fixtures", "ff_FJ_gated_cells.rds"))

expect_equal(
flowCore::exprs(ff_FJ_gated1),
flowCore::exprs(ref_ff_FJ_gated1)
)

# test with fcs name variant 1 (find pattern)
myFF <- fs_c[[1]]
flowCore::keyword(myFF)[["$FIL"]] <- "Transformed_Donor1.fcs"

ff_FJ_gated1 <- applyFlowJoGate(
myFF,
wspFile = wspFile,
gateName = "Cells")

expect_equal(
flowCore::exprs(ff_FJ_gated1),
flowCore::exprs(ref_ff_FJ_gated1)
)

# test with fcs name variant 2 (find pattern)
myFF <- fs_c[[1]]
flowCore::keyword(myFF)[["$FIL"]] <- "The_Donor1_Transformed.fcs"

ff_FJ_gated1 <- applyFlowJoGate(
myFF,
wspFile = wspFile,
gateName = "Cells")

expect_equal(
flowCore::exprs(ff_FJ_gated1),
flowCore::exprs(ref_ff_FJ_gated1)
)

# ggplotFilterEvents(fs_c[[1]],
# ff_FJ_gated1,
# xChannel = "FSC-A",
Expand Down

0 comments on commit cb74fe2

Please sign in to comment.