This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PREMISE | |
# these implementation of HPCL is highly experimental. | |
# Therefore the interface, function names, arguments names, types of input | |
# are subject to change and to be extended. | |
# At this stage, the input is a named list of Seurat objects. | |
# In another branch (soon to be integrated), we accept SCE, H5 SCE, and anndata | |
BiocManager::install("MangiolaLaboratory/HPCell@grammar-hpc", upgrade_dependencies=FALSE) | |
BiocManager::install("crew", upgrade_dependencies=FALSE) | |
BiocManager::install("crew.cluster", upgrade_dependencies=FALSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git remote set-url origin [email protected]:USERNAME/REPOSITORY.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_cell_type_color = function(cell_type_vector){ | |
cell_type_vector |> | |
enframe(value = "harmonised_cell_type") |> | |
left_join( | |
tribble( | |
~harmonised_cell_type, ~palette, | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Theme | |
friendly_cols <- dittoSeq::dittoColors() | |
# scale_fill_manual(values = friendly_cols) | |
# scale_color_manual(values = friendly_cols) | |
theme_multipanel = | |
theme_bw() + | |
theme( | |
panel.border = element_blank(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Convert array of quosure (e.g. c(col_a, col_b)) into character vector | |
#' | |
#' @keywords internal | |
#' | |
#' @importFrom rlang quo_name | |
#' @importFrom rlang quo_squash | |
#' @importFrom purrr when | |
#' @importFrom magrittr equals | |
#' | |
#' @param v A array of quosures (e.g. c(col_a, col_b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ToDataFrameTypeColFull = function(tree, ...){ | |
tree %>% | |
Clone() %>% | |
{ | |
t = (.) | |
foreach(l=1:(t %$% Get("level") %>% max), .combine = bind_rows) %do% { | |
data.tree::Clone(t) %>% | |
{ data.tree::Prune(., function(x) x$level <= l + 1); . } %>% | |
data.tree::ToDataFrameTypeCol(...) %>% | |
as_tibble |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_bimodality = function(fit) { | |
fit %>% | |
tidybayes::gather_draws(exposure_rate[S]) %>% summarise( | |
bimodal = diptest::dip.test(`.value`) %$% `p.value` | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################################################### | |
# From within R | |
#################################################################### | |
#################################################################### | |
# Initialisation of makefiles | |
#################################################################### | |
dotR <- file.path(Sys.getenv("HOME"), ".R") | |
if (!file.exists(dotR)) dir.create(dotR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generate_gamma_sum <- function(N, k, theta) { | |
n_means = length(k) | |
sums = numeric(N) | |
for(n in 1:N) sums[n] = sum(rgamma(n_means, shape = k, scale = theta)) | |
list(sums = sums, shape = k, scale = theta) | |
} | |
k=c(3,4,5) | |
theta=c(1, 2, 1) | |
generate_gamma_sum(10000, c(3,4,5), c(1, 2, 1)) %$% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
approximated_modified_bessel_second_kind_log = function(z, v, s = max(0,v-10)){ | |
# s = 0 not approximated | |
0.5 * ( log(pi) - log(2) ) + (-z - 0.5 * log(z)) + | |
foreach(j = s:floor(v-0.5), .combine = c) %do% { | |
lgamma(j + abs(v) - 0.5 + 1) - |
NewerOlder