Skip to content

Commit

Permalink
Merge branch 'dev' into circos_factorization
Browse files Browse the repository at this point in the history
  • Loading branch information
jmitchell81 committed Nov 21, 2024
2 parents 45855fe + 2b1a126 commit 3dba98d
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/copy_to_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Designate desired directories and files
SRC_FOLDER_PATHS=(data-raw man R tests vignettes)
SRC_FILE_PATHS=(DESCRIPTION LICENSE NAMESPACE NEWS.md README.md inst/CITATION)

# Get files from directories
FILES=$(find "${SRC_FOLDER_PATHS[@]}" -type f)

# Add indicated individual files
for F in "${SRC_FILE_PATHS[@]}"
do
FILES+=" ${F}"
done

echo "${FILES[@]}"

# Pass these to github:
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
# Fetch branches
git fetch
# Checkout target branch
git checkout $TARGET_BRANCH
# copy files from the branch the action is being run upon
SRC_BRANCH=$(git symbolic-ref --short HEAD)
git checkout $SRC_BRANCH -- $FILES
# Commit to the repository (ignore if no changes)
git add -A
git diff-index --quiet HEAD || git commit -am "update files"
# Push to remote branch
git push origin $TARGET_BRANCH
22 changes: 22 additions & 0 deletions .github/workflows/bioc_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Update Bioconductor package files

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

jobs:
copy:
name: Copy files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: copy
env:
TARGET_BRANCH: 'master'
run: .github/copy_to_branch.sh
shell: bash
43 changes: 43 additions & 0 deletions .github/workflows/document.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
paths: ["R/**"]
workflow_dispatch:

name: documentation-update

jobs:
document:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: roxygen2

- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: Commit and push changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add man/\* NAMESPACE DESCRIPTION
git commit -m "Update documentation" || echo "No changes to commit"
git pull --ff-only
git push origin
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown-update

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = TRUE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
18 changes: 18 additions & 0 deletions .github/workflows/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This is a code review template, it will be displayed after each pull request.
We do code reviews because we care about quality of our codebase and because we care about long-term development goals.
We do not do code reviews to blame the ones who contribute. There is no seniority in this process and there is no perfect code,
we just want to avoid storing code that is not OK.

## For the submitter

- [ ] `R CMD build` & `R CMD check` pass
- [ ] `BiocCheck` passes
- [ ] Needed tests exist and passing or not needed
- [ ] The change is sufficiently small

## For the reviewer

- [ ] OK, code does what it's intended for
- [ ] its' OK to do it that way
- [ ] it's OK to read and comprehend the code
- [ ] tests, documentation, style are OK
10 changes: 10 additions & 0 deletions .github/workflows/r-build-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: r-build-check
on:
pull_request:
branches: ['master', 'dev']
workflow_dispatch:

jobs:
build-check:
uses: FertigLab/actions/.github/workflows/r-build-check.yml@v1
secrets: inherit
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# dominoSignal v1.0.1

## Receptor Complex Bugfix

- Resolved issue where if create_domino was run with complexes=TRUE and no complexes were found to have active signaling, the full signaling matrix would be replaced by a NULL value.

## GitHub Actions

- Restoration of .github/workflows scripts for automatic build checks.

# dominoSignal v1.0.0

- Version number update to signify acceptance to bioconductor in release 3.20

# dominoSignal v0.99.4

## Vignettes
Expand Down
5 changes: 3 additions & 2 deletions R/processing_fxns.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@ build_domino <- function(
inc_ligs <- unlist(inc_ligs_list)
}
lig_genes <- intersect(inc_ligs, rownames(dom@z_scores))
if (length(lig_genes) %in% c(0, 1)) {
if (length(lig_genes) == 0) {
lig_genes <- numeric(0)
}
cl_sig_mat <- matrix(0, ncol = length(levels(dom@clusters)), nrow = length(lig_genes))
colnames(cl_sig_mat) <- colnames(signaling)
if (!identical(lig_genes, numeric(0))) {rownames(cl_sig_mat) <- lig_genes}
rownames(cl_sig_mat) <- lig_genes
for (c2 in levels(dom@clusters)) {
n_cell <- length(which(dom@clusters == c2))
Expand Down Expand Up @@ -173,7 +174,7 @@ build_domino <- function(
}
})
names(cl_sig_list) <- names(inc_ligs_list)
if (length(cl_sig_list) > 1) {
if (length(cl_sig_list) > 1 & !all(sapply(cl_sig_list, is.null))) {
cl_sig_mat <- do.call(rbind, cl_sig_list)
}
}
Expand Down
40 changes: 40 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,43 @@ mock_linkage_summary <- function() {
)
return(linkage_sum_tiny)
}

#' Convert between ligand names and gene names
#'
#' @param dom A domino object
#' @param genes A vector of genes on which to resolve ligand and gene names
#'
#' @return A vector of names where ligand names have been replaced with gene names if applicable
#' @keywords internal
resolve_names <- function(dom, genes) {
rl_map = dom@misc[["rl_map"]]
genes_resolved <- vapply(genes, FUN.VALUE = character(1), FUN = function(l){
int <- rl_map[rl_map$L.name == l, ][1,]
if((int$L.name != int$L.gene) & !grepl("\\,", int$L.gene)){
int$L.gene
} else {
int$L.name
}
})
return(genes_resolved)
}

#' Convert between complex names and gene names
#'
#' @param dom A domino object
#' @param genes A vector of genes, some of which may be complexes
#'
#' @return A list where any complexes are mapped to a vector of
#' component genes. The list names are set to the input gene names.
#' @keywords internal
resolve_complexes <- function(dom, genes) {
genes_list <- lapply(genes, function(l){
if(l %in% names(dom@linkages$complexes)){
return(dom@linkages$complexes[[l]])
} else {
return(l)
}
})
names(genes_list) <- genes
return(genes_list)
}
21 changes: 21 additions & 0 deletions man/resolve_complexes.Rd

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

20 changes: 20 additions & 0 deletions man/resolve_names.Rd

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

41 changes: 41 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,44 @@ test_that("check_arg works for class", {
expect_silent(check_arg(data.frame(a = c(1, 2), b = c(3, 4)),
allow_class = c("data.frame", "matrix")))
})

test_that("resolve_complexes maps complex names to their component genes, resolve_names maps ligand name to gene name", {
data(CellPhoneDB)
rl_map_tiny <- create_rl_map_cellphonedb(
genes = CellPhoneDB$genes_tiny,
proteins = CellPhoneDB$proteins_tiny,
interactions = CellPhoneDB$interactions_tiny,
complexes = CellPhoneDB$complexes_tiny)
entry_for_resolve_names <- c(int_pair = "12oxoLeukotrieneB4_byPTGR1 & LTB4R",
name_A = "12oxoLeukotrieneB4_byPTGR1", uniprot_A = "Q14914", gene_A = "PTGR1", type_A = "L",
name_B = "LTB4R", uniprot_B = "Q15722", gene_B = "LTB4R", type_B = "R",
annotation_strategy = "curated",
source = "HMRbase;uniprot;reactome",
database_name = "CellPhoneDB")
rl_map_tiny <- rbind(rl_map_tiny, entry_for_resolve_names)

data(SCENIC)
regulon_list_tiny <- create_regulon_list_scenic(
regulons = SCENIC$regulons_tiny)

data(PBMC)
pbmc_dom_tiny <- create_domino(
rl_map = rl_map_tiny, features = SCENIC$auc_tiny,
counts = PBMC$RNA_count_tiny, z_scores = PBMC$RNA_zscore_tiny,
clusters = PBMC$clusters_tiny, tf_targets = regulon_list_tiny,
use_clusters = TRUE, use_complexes = TRUE, remove_rec_dropout = FALSE)

# Test resolve_names
genes <- c("integrin_a6b4_complex", "TGFB3", "12oxoLeukotrieneB4_byPTGR1")
ligand_names_resolved <- c("integrin_a6b4_complex" = "integrin_a6b4_complex",
"TGFB3" = "TGFB3",
"12oxoLeukotrieneB4_byPTGR1" = "PTGR1")
expect_equal(resolve_names(pbmc_dom_tiny, genes), ligand_names_resolved)

# Test resolve_complexes
genes <- c("integrin_a6b4_complex", "IL7_receptor", "TGFBR3")
complexes_resolved <- list("integrin_a6b4_complex" = c("ITGB4", "ITGA6"),
"IL7_receptor" = c("IL7R", "IL2RG"),
"TGFBR3" = "TGFBR3")
expect_equal(resolve_complexes(pbmc_dom_tiny, genes), complexes_resolved)
})

0 comments on commit 3dba98d

Please sign in to comment.