Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/upstream_fork'
Browse files Browse the repository at this point in the history
  • Loading branch information
yasharw committed Oct 11, 2023
2 parents 516a946 + 33341e5 commit 811bd85
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 299 deletions.
128 changes: 0 additions & 128 deletions .github/CODE_OF_CONDUCT.md

This file was deleted.

124 changes: 0 additions & 124 deletions .github/CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Bug report or feature request
about: Describe a bug you've seen or make a case for a new feature
---

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on <https://stackoverflow.com/> or <https://community.rstudio.com/>.
Please briefly describe your problem and what output you expect.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a [reprex](http://reprex.tidyverse.org/) before, start by reading <https://www.tidyverse.org/help/#reprex>.

Expand Down
35 changes: 0 additions & 35 deletions .github/SUPPORT.md

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
fail-fast: false
matrix:
config:
- { 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'}
- { os: ubuntu-latest, r: '4.1', bioc: '3.14', cont: "bioconductor/bioconductor_docker:RELEASE_3_14", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: macOS-latest, r: '4.1', bioc: '3.14'}
- { os: windows-latest, r: '4.1', bioc: '3.14'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
Expand Down
31 changes: 23 additions & 8 deletions R/statistic-enricher.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Enricher Python module used to predict the activity of regulatory proteins
#'
#' @description
#' Calculates regulatory activities using Enricher.
#' Calculates regulatory activities using Enricher
#'
#' @details
#' This function is a wrapper for the python method [enricher.enrich()].
Expand All @@ -14,6 +14,8 @@
#' @param thresh.filter Float, Prior to normalization remove features that have a standard deviation per feature less
#' than {thresh_filter}
#' @param scaler_type Character indicating whether to scale and by what method to scale dataset
#' @param enr_type Character indicating which enrichment slot to use
#' @param enr_weights Character indicating out file handle for enrichment regulon weights
#' @return A long format tibble of the enrichment scores for each source
#' across the samples. Resulting tibble contains the following columns:
#' 1. `statistic`: Indicates which method is associated with which score.
Expand All @@ -40,24 +42,37 @@ run_enrich <- function(mat,
network,
.source = .data$source,
.target = .data$target,
minsize = 0,
scaler_type = NULL,
.mor = .data$mor,
.likelihood = .data$likelihood,
minsize = 5,
scaler_type = NULL,
enr_type = 'total_enrichment',
enr_weights = 'weights.tsv',
...) {
# Check for NAs/Infs in mat
check_nas_infs(mat)
use_condaenv('base')
enr <- import('priori.priori')
use_condaenv('enrich_env')
enr <- import('enricher.enrich')

# Before to start ---------------------------------------------------------
network <- network %>%
convert_to_enricher({{ .source }}, {{ .target }})
rename_net({{ .source }}, {{ .target }}, {{ .mor }}, {{ .likelihood }})
network <- filt_minsize(rownames(mat), network, minsize)
network <- network %>% convert_f_defaults( UpGene = source, DownGene = target) %>% dplyr::mutate(Type = 'controls-expresssion-of') %>% select(UpGene,Type, DownGene)
pd_network <- enr$pd$DataFrame(network)
pd_mat <- enr$pd$DataFrame(mat, index=rownames(mat), columns=colnames(mat))

# Analysis ----------------------------------------------------------------
enr_scores <- enr$Priori(cohort='decoupler',expr=pd_mat,regulon=pd_network,regulon_size=minsize)
enr_scores <- enr$Enrichment(cohort='decoupler',expr=pd_mat,regulon=pd_network,regulon_size=minsize)
enr_scores$scale(scaler_type=scaler_type)
enr_scores$assign_weights()
enr_scores$calculate_enrichment()
t(enr_scores$enrichment) %>%
weights <- enr_scores[['regulon_weights']]
write.table(weights,file=enr_weights,sep='\t',quote=F)
scores <- enr_scores[[enr_type]]
if (enr_type %in% c('total_enrichment','local_enrichment','delta')){
scores <- t(scores)}
scores %>%
as.data.frame() %>%
rownames_to_column("source") %>%
pivot_longer(-.data$source, names_to = "condition", values_to = "score") %>%
Expand Down

0 comments on commit 811bd85

Please sign in to comment.