sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
17a02dbe6672a9790f92101c545e47dc5899a20350596b4742337af585aa2ef2
R
308
12
library(testthat) library(fafbseg) if(nzchar(Sys.getenv("FLYWIRE_PRINCIPLES"))) download_flywire_release_data() if(nzchar(Sys.getenv('CI')) && !identical(Sys.info()[["sysname"]], "Darwin")) dr_fafbseg() op <- options('fafbseg.cachedir'=tempfile('fafbseg-tempcache')) test_check("fafbseg") options(op)
65b1485c84231f4e1d21813518aa260c31914b3c1436a279f96ed6ba240d1a2c
R
311
12
nodewise.getlambdasequence<-function (x) { nlambda <- 100 p <- ncol(x) lambdas <- c() for (c in 1:p) { lambdas <- c(lambdas, glmnet(x[, -c], x[, c])$lambda) } lambdas <- quantile(lambdas, probs = seq(0, 1, length.out = nlambda)) lambdas <- sort(lambdas, decreasing = TRUE) return(lambdas) }
4a6cd2549098802157934180c4c82e557689114f7eb1c1ade6aaa576c358ec96
R
313
11
library(mlflow) # define parameters my_int <- mlflow_param("my_int", 1, "integer") my_num <- mlflow_param("my_num", 1.0, "numeric") my_str <- mlflow_param("my_str", "a", "string") # log parameters mlflow_log_param("param_int", my_int) mlflow_log_param("param_num", my_num) mlflow_log_param("param_str", my_str)
0ed5570ba94cfe8e30eadefb57684e83b68308308343ec26fe110e307e7c7546
R
323
12
#### Section: Utility Helpers #### anova_protect_vars <- function(vars) { if (is.null(vars) || length(vars) == 0) return(vars) vals <- vapply(vars, function(v) { if (is.null(v) || is.na(v) || !nzchar(v)) return("") if (grepl("^`.*`$", v)) v else paste0("`", v, "`") }, character(1)) vals[nzchar(vals)]...
af732fc6decf85944ef88ce4e2bdf43920226e28e09d29a460d6e6d58639d27b
R
331
12
# Set options here options(golem.app.prod = FALSE) # TRUE = production mode, FALSE = development mode # Detach all loaded packages and clean your environment golem::detach_all_attached() # rm(list=ls(all.names = TRUE)) # Document and reload your package golem::document_and_reload() # Run the application spatialLIBD:...
44f2ece0a218ed67a19b2f1d0faa2fe6fdc92ebadc503e77ec1e207dae51fbc6
R
336
14
shinyUI( navbarPage("premessa", header = list( tags$head(tags$script(src = "shinyoutputbindings.js")), singleton(tags$head(tags$link(rel = 'stylesheet', type = 'text/css', href = 'spinner.css'))) ), tabPanel("Debarcode data", uiOutput("debarcoderUI") ...
b4495769b76ed8a85932e8121a2a5c05cdaa60c5520d355706723304f17bb3f6
R
336
7
unlink("man", recursive = TRUE) roxygen2::roxygenise() # remove mlflow-package doc temporarily because no rst doc should be generated for it. file.remove("man/mlflow-package.Rd") source("document.R", echo = TRUE) # roxygenize again to make sure the previously removed mlflow-packge doc is available as R helpfile roxygen...
d7ba5b4f49a1e3990f5470e043e4f4fc9b2d279c0eede16ddb7521e88f630bf2
R
336
11
#' Add random number columns in data frame with specific seed to validate machine learning algorightms #' #' @param #' #' @return #' #' @export add_randomized_column <- function(df, n) { stringr::str_c("rnorm_", seq_len(n)) %>% purrr::reduce(~tibble::add_column(.x, '{.y}' := rnorm(n = nrow(df), mean = 0, sd = 1))...
1f1c9c19c6f5ec8fa4f5f4435c23ff341f43c85de36cfa22b14b2210bff68472
R
341
15
#' #' #' @param #' #' @return #' #' @export xgb_linear_scores <- function(model, matrix) { yhat <- predict(model, matrix) y <- xgboost::getinfo(matrix, "label") rmse <- sqrt(mean((y - yhat)^2)) mae <- mean(abs(y - yhat)) r2 <- 1 - sum((y - yhat)^2) / sum((y - mean(y))^2) tibble::tibble(RMSE = rmse, MA = mae...
111e0aeaec37b23fb12a8589aca6109e02d7cc646359b474ebc0ad469f368c36
R
344
11
## code to prepare `DATASET` dataset goes here library(nat) JRCFIBVNC2020MNP.surf <- read.hxsurf('data-raw/VNC_tbars_scale-5.resampled.500k.bin.surf') usethis::use_data(JRCFIBVNC2020MNP.surf, overwrite = TRUE) # alias - easiest way just to make a copy sadly MANC.surf <- JRCFIBVNC2020MNP.surf usethis::use_data(MANC....
88a94b19f967ebe39b4a893aa6377ffd9bfaab6b21201f9259952b7aca81889b
R
348
11
ucsc_gene_track<-read.table("ucsc_gene_track.txt",header=T,sep="\t") exomes<-ucsc_gene_track[,c("chrom", "txStart","txEnd")] dup<-paste(exomes$chrom,exomes$txStart,sep="_") dup<-paste(dup,exomes$txEnd,sep="_") exomes<-exomes[!duplicated(dup),] #now write file exomes.txt write.table(exomes,"data/exomes.txt", row.name...
e7bf6a29b7e0888855b2add925cb1f035de5d54e8f856ea7764a4d1f92974520
R
349
16
library("spatialLIBD") ## Obtain the necessary data if (!exists("sce")) sce <- fetch_data("sce") pdf(here::here("data-raw", "logo.pdf"), useDingbats = FALSE) sce_image_clus( sce = sce, clustervar = "layer_guess_reordered", sampleid = "151673", colors = libd_layer_colors, ... = " LIBD Layers", ...
af3de9a4f3cb6f21cd08cca782ea3f1f2ba6467b29307234b82c683ad0726695
R
351
13
#' #' #' @param #' #' @return #' #' @export nested_xgboost_cox_cv_save <- function(x, saver = mysavefactory(), name = "nested_xgboost_cox_cv") { x %>% purrr::map(~purrr::list_modify(.x, matrix = purrr::zap())) %>% purrr::map(~purrr::list_modify(.x, model = xgboost::xgb.save.raw(.x$model, raw_format = "json"))...
249cc8246990f63c84edf67a04fead9a532fb7676a07e25be33a38bbe4784d2b
R
352
7
# =============================================================== # 🧮 Linear Model (LM) — fixed effects only # =============================================================== lm_ui <- function(id) regression_ui(id, "lm", allow_multi_response = TRUE) lm_server <- function(id, data) regression_server(id, data, "lm", a...
f64f9c90e2cf9f234b0424d5038c2dddbf5b7f794e2d28d0a3a24674d43c2584
R
353
10
install.packages("easypackages") library("easypackages") libraries("readr", "data.table", "dplyr", "tidyr", "gtsummary","openxlsx", "readxl", "MASS", "ggplot2", "forcats", "hrbthemes", "viridis") edges %>% pivot_longer(!Real_random, names_to = "type", values_to = "value") %>% ggplot( aes(x=Real_random, y=value,...
ab850d871c3cbd9179c27153746d516ed0f12344c1f2ce6b3650cbc13d32ebe0
R
355
11
ucsc_mirna_track<-read.table("hg_miRNA.txt",header=T,sep="\t") mirnas<-ucsc_mirna_track[,c("chrom", "chromStart","chromEnd")] dup<-paste(mirnas$chrom,mirnas$chromStart,sep="_") dup<-paste(dup,mirnas$chromEnd,sep="_") mirnas<-mirnas[!duplicated(dup),] #now write file exomes.txt write.table(mirnas,"data/mirnas.txt", r...
f89d5eff5e9669bd65f6d5f4de3fcdac37962de910ec05d5bd57cbeafbd986b4
R
357
11
op <- choose_malevnc_dataset('MANC') on.exit(options(op)) test_that("manc_leg_summary works", { expect_s3_class(mls <- manc_leg_summary(c(10126, 10118)), 'data.frame') expect_true(nrow(mls)==2) expect_true(ncol(mls)==13) expect_s3_class(mss <- manc_side_summary(c(10126, 10118)), 'data.frame') expect_equal(m...
88d2996ae8e2bc19759beee4c8a135542f3ba8331e7376ddbf6f80e4f9a392d3
R
360
16
prior <- get_prior(samples_LNR) design <- get_design(samples_LNR) RNGkind("L'Ecuyer-CMRG") set.seed(123) test_that("priorS3", { expect_snapshot(prior) expect_snapshot(summary(prior)) vdiffr::expect_doppelganger("prior_plot", plot(prior, map = FALSE, N = 1e2)) }) test_that("designS3", { expect_snapshot(design...
89312dab0a9aa8cbb38a1fae03334de2d27517ad8e888564aff63c5ff9048840
R
360
13
#' #' #' @param #' #' @return #' #' @export nested_xgboost_cox_cv_load <- function(x) { readRDS(x) %>% purrr::map(~purrr::list_modify(.x, matrix = nested_xgboost_cox_cv_model_matrix(.x$data, .x$event_incident, .x$event_agediff, .x$vars)$dmatrix)) %>% purrr::map(~purrr::list_modify(.x, model = xgboost::xgb.loa...
f30070b336a8ff4bb2483e7ec7ad472e317ec35f0be64a2159d714a3893107a6
R
362
18
context("UI") test_that("mlflow can launch the UI", { skip_on_travis() url <- mlflow_ui() response <- httr::GET(url) status <- httr::status_code(response) if (status != 200L) { ui_content <- httr::content(response) stop("Status ", status, " retrieved with contents: ", ui_content) } expect_e...
1c0a123de67ebabda71582b81032b26914c429775839eed04aae44b83b6b600a
R
365
8
check_package = function(package = "ggVennDiagram"){ if (!requireNamespace(package, quietly = TRUE)){ stop(paste("The", package, "package is not found in your library paths.", " It is required to show intersections interactively.", " Please run `install.packages('package')` and ret...
54ad1f463f59c75cc50927979bf580a79485f0a6f72ee5a48d11a50b51d2878f
R
366
16
#' #' #' @param #' #' @return #' #' @export xgb_model_matrix <- function(x, index, outcome) { dset <- x[index,] labels <- dset %>% dplyr::pull({{outcome}}) matrix <- dset %>% dplyr::select(-{{outcome}}) %>% data.matrix() dmatrix <- xgboost::xgb.DMatrix(matrix, label = labels) list(dmatrix = dmatrix, d...
ff73fd4cb89123e89a9979d79a458963c25182433787dd51493b9e1110153bf0
R
367
13
prepare.data<-function (x, y, standardize, family) { x <- scale(x, center = TRUE, scale = standardize) dataset <- switch(family, gaussian = { list(x = x, y = y) }, { switch.family(x = x, y = y, family = family) }) x <- scale(dataset$x, center = TRUE, scale = FALSE) y <- scale(dataset$y, scale = FAL...
836f9a1e8e34a38fd4f1edd5530f74dea0ba856bcb0a3e3c1b563d2a46fdf9a0
R
368
12
# This file is part of the standard setup for testthat. # It is recommended that you do not modify it. # # Where should you do additional test configuration? # Learn more about the roles of various files in: # * https://r-pkgs.org/tests.html # * https://testthat.r-lib.org/reference/test_package.html#special-files libr...
1b7e0060413b3c2a049adbec02f04972d840027a843b2c5241621a01e06205f9
R
380
22
test_that("Test FactorNaturalOrder", { x <- FactorNaturalOrder(10:1) expect_true(is.factor(x)) }) test_that("Test my_theme_ggplot", { p <- ggplot2::ggplot() + my_theme_ggplot() expect_silent(p) }) test_that("Test SafeColorPalette", { n1 <- length(SafeColorPalette(5)) expect_equal(...
7d0925ec4758e37ec83ee42b7dc94c8f9c33cfd5a1d73539c229fa864ce93579
R
382
17
#' Surface model of neuropils in the MANC dataset #' #' The \code{\link{MANC.surf}} model was generated in Amira by Kazunori Shinomiya and shared with Greg 1 October 2020. It should be regarded as provisional #' #' #' #' @name MANC.surf #' @aliases JRCFIBVNC2020MNP.surf #' @docType data #' @examples #' \dontrun{ #' # ...
562d6e8155ef57c516e95e1f94ae9db89d53f3403e2a7cf31e64a4c7c569cdd1
R
388
12
# This file is part of the standard setup for testthat. # It is recommended that you do not modify it. # # Where should you do additional test configuration? # Learn more about the roles of various files in: # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview # * https://testthat.r-lib.org/articles/spec...
dfc6bf1dadb5f811a68043ac9cba673bfebdcb75836c530c6d1226ddc240a718
R
390
19
library(purrr) load("./metadata.RData") tissues = c("dlpfc","hippo","caudate","amygdala","dACC","sACC") #tissues = c("sACC") #### run jobs purrr::walk(tissues,function(tt){ arrays = paste0("1-",length(metadata.PRS.sub)) #arrays = 1 print(paste0("running job for: ",tt)) cmd = paste0("sbatch -a...
3143a245e76c8677cba3409edc862bfe768dae6f0aa0fb0c072ccfa50aa1e724
R
391
13
#!/usr/bin/env Rscript args <- commandArgs(trailingOnly = TRUE); cvPATH <- args[1]; bedname <- args[2]; spec <- args[3]; x <- file('stdin'); cv2 <- read.table(x); #p-site cv2[,2] <- cv2[,2]+12; cv2$flen <- cv2[,3]-cv2[,2]+12; write.table(cv2,file=paste0(cvPATH,bedname,"sorf.tp.txt"),sep="\t", ...
ceb8bb43e182c495939eca9899c870557791809de65306cc2494388f285dbb8f
R
392
16
#' #' #' @param #' #' @return #' #' @export generage_pca_grouping <- function(df, size, seed = 2024) { set.seed(seed) n_centers <- nrow(df) %/% size pca_result <- df %>% dplyr::mutate(dplyr::across(dplyr::everything(), ~ ifelse(is.na(.), mean(., na.rm = TRUE), .))) %>% prcomp() pca_data <- as.data.frame...
493fc7f88e28ad442ab833cdf20d69755599b5579ecd7effe457c0516f27a37c
R
393
13
mlflow_clear_test_dir <- function(path) { purrr::safely(mlflow_end_run)() mlflow:::mlflow_set_active_experiment_id(NULL) if (dir.exists(path)) { unlink(path, recursive = TRUE) } deregister_local_servers() } deregister_local_servers <- function() { purrr::walk(as.list(mlflow:::.globals$url_mapping), ~ ....
5a15f3b4f3f416b7d9722ae1ae8dec95f934c47db8be5888c4398cecc4d9aeda
R
394
12
# This file is part of the standard setup for testthat. # It is recommended that you do not modify it. # # Where should you do additional test configuration? # Learn more about the roles of various files in: # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview # * https://testthat.r-lib.org/articles/spec...
9517b6e64fa283624833a3caa4dc4c4741148de56a4d661382f4e2a0edb8a462
R
398
16
### Inspect nodomap output library(Seurat) data_dir <- '/cephfs/scratch/bruening_scratch/gdowsett/data/nodomap/' data <-readRDS(paste0(data_dir, 'nodomap_cleaned_20251025.RDS')) data <- DietSeurat( data, assays = 'originalexp', dimreducs = 'umap', graphs = c('integrated_nn', 'integrated_snn'), misc = FALSE...
b60bf6269195755718b98ea5c820318395268fd659abfb062c73b21348699cef
R
398
17
test_that( "vis_clus", { if (!exists("spe")) spe <- fetch_data("spe") # Bad spatialCoords spe_temp <- spe colnames(spatialCoords(spe_temp)) <- c("a", "b") expect_error( { p <- vis_clus(spe_temp, clustervar = "sample_id") }, ...
e393c425f3c24d1afecbe235e38a30b07040d8aed027ddc88900afa1e60a8a6b
R
399
8
test_that("changelog works", { skip_if_offline() skip_if_not(fanc_token_available(), message="Unable to obtain a FANC access token") expect_s3_class(res <- fanc_change_log("648518346473954669"), "data.frame") expect_named(res, c("operation_id", "timestamp", "user_id", "before_root_ids", ...
d65a6d080ca9a8622f72f80cf4e8130d33f0998421baaf48d39f6f10533d5d8d
R
402
14
context("test SAMBAR result") test_that("SAMBAR function works", { suppressWarnings(load("./testDataset.RData")) data("exon.size") data("mut.ucec") data("genes") expect_equal(sambar(mutdata=mut.ucec, esize=exon.size, signatureset=system.file("extdata", "h.all.v6.1.symbols.gmt", package="netZooR", mustWork...
b09d17fcfdf961c46a007b19f84f42519c7a42be26e783256e95c883da0b92db
R
404
8
test_that("reading a file works", { skip_if_not_installed('git2r') expect_is(anns <- flywire_sirepo_file('supplemental_files/Supplemental_file1_annotations.tsv', read = TRUE, version=630), 'data.frame') expect_type( flywire_sirepo_file('https://github.com/flyconnectome/flywire_annotations/blob/staging/supplem...
3bffe6f695dfcc1a5b4c0ef33f53f260c275a10b4b24bdfd3e913476bfcd934a
R
409
14
calcM<-function (x, lambdas, parallel, ncores) { if (parallel) { M <- mcmapply(FUN = calcMforcolumn, x = list(x = x), j = 1:ncol(x), lambdas = list(lambdas = lambdas), mc.cores = ncores) } else { M <- mapply(FUN = calcMforcolumn, j = 1:ncol(x), x = list(x = x), ...
1bda52f4b8b50c04fa2f84c79d033aca3ec4f4f236867f2080fd99a90620f265
R
410
14
#' #' #' @param #' #' @return #' #' @export xgb_save <- function(x, name = "nested_xgboost", dir = "rds") { dir.create(dir, showWarnings = FALSE) x %>% purrr::map(~purrr::list_modify(.x, train_obj = purrr::zap(), test_obj = purrr::zap())) %>% purrr::map(~purrr::list_modify(.x, model = xgboost::xgb.save.raw(...
523911a6296972c4f12faa4d53f81fc8da1ac697ab010cfa8b06f56ca429b819
R
410
16
RNGkind("L'Ecuyer-CMRG") set.seed(123) test_that("compare", { expect_snapshot( compare(list(samples_LNR), cores_for_props = 1) ) }) test_that("savage-dickey", { expect_snapshot( round(hypothesis(samples_LNR, parameter = "m", do_plot = F, H0 = -1), 2)) expect_snapshot( round(hypothesis(samples_LNR,...
5570f834a9dd643a5a3e991ba436a340cfaca8469c60bfddf4a4a402f2de3632
R
413
13
op <- choose_malevnc_dataset('VNC') on.exit(options(op)) test_that("somapos works", { skip_if_offline() skip_if(inherits(try(clio_token(), silent = T), 'try-error'), message = "no clio token available") expect_silent(res <- manc_nearest_soma(cbind(20540, 18544, 1968), details = TRUE)) expect_equal(re...
8cf84aec25183ee9c5a6ba87f6cb97cdca1bb04d44546759ed88fb06b645f3e4
R
413
14
# To remove axes in UMAP plots umap_theme <- theme( axis.line=element_blank(), axis.text.x=element_blank(), axis.text.y=element_blank(), axis.ticks=element_blank(), axis.title.x=element_blank(), axis.title.y=element_blank(), panel.background=element_blank(), panel.border=element_blank(), panel.grid.ma...
d7fda0ae90fb9aeef239fce72e069a91d8ff5c30ff71f2a8a0d99b2d005f9fe2
R
413
12
# This file is part of the standard setup for testthat. # It is recommended that you do not modify it. # # Where should you do additional test configuration? # Learn more about the roles of various files in: # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview # * https://testthat.r-lib.org/reference/tes...
1557a83a38e7932129bf45b1d04d1e5d5ad631d01b4b0d78c904ba32663dea0c
R
415
17
library(openxlsx) library(DESeq2) library(tidyverse) options(device=pdf) setwd("Z:/charliew/da/gsea") rnkFile <- read.xlsx("huMPG_neu_rnkStock.xlsx", colNames=TRUE, rowNames=TRUE) names <- colnames(rnkFile) for (i in names){ d<-rnkFile %>% select(i) d$'#gene' <- row.names(d) d <- d[,c(2,1)] w...
94d35a35d48b9314111ecf37199e900184dcf5bff6d40172157eb81eeb112427
R
416
14
#' #' #' @param #' #' @return #' #' @export nested_xgboost_cox_cv <- function(data, index = 1, n_inner_folds = 5, n_outer_folds = 5, ...) { nested_xgboost_cox_cv_outer_loop(data = data, iteration = index, n_outer_folds = n_outer_folds, ...
dd4319eea6f9858ef0bb911bd3ce431f8f0ae0920f06e7d0b8d477f4847e8c9a
R
423
14
est.stderr.despars.lasso<-function (x, y, Z, betalasso, sigmahat, robust, robust.div.fixed = FALSE) { if (robust) { stderr <- sandwich.var.est.stderr(x = x, y = y, Z = Z, betainit = betalasso) n <- nrow(x) if (robust.div.fixed) stderr <- stderr * n/(n - sum(b...
660ae0fbdf7476080dbe36ed200d1c59985bff4b7daef53ab04ccc498ca92cdb
R
429
11
test_that("fafb14_to_flywire_ids works", { skip_if_not(spine_ok()) rid=flywire_rootid('79730879731420093') expect_equal( df <- fafb14_to_flywire_ids(5038796, conn = catmaid::vfbcatmaid()), data.frame(root_id = rid, hits = 57L, skid = "5038796")) expect_equal(fafb14_to_flywire_ids(5038796, conn = catmai...
856ab8ae6b3f7a68073a284536f1b91372c0abc2dc8e6a27828205cda61ca03a
R
430
9
test_that("memory usage for large list", { large_list <- list(Score = as.character(rnorm(130000, 80, 20)), Length = as.character(rnorm(6000, 200, 50)), Charge = as.character(rnorm(90000, 2000, 800)), Math = as.character(rnorm(100000,90,20)), ...
3a76b5f846db228d84c4896f28b5c2b22435707c21f2bd6bd0168d76027ecb53
R
432
13
.onLoad <- function(libname, pkgname) { # make FANC4<->FANC3 bridging registrations available register_fanc3to4() invisible() } .onAttach <- function(libname, pkgname) { packageStartupMessage( 'Do `choose_fanc()` to use many fafbseg::flywire_* functions!\n', 'Use dr_fanc() to get a report on your inst...
5e2d0fb8dda421f04b4f255d6645422761a4eaa7821b9d2a5616ba9388a4a83d
R
438
15
#### !!! IMPORTANT !!! RENAMING BAMFILES !!! ### rename.bamfiles <- F if(rename.bamfiles) { from <- list.files(bamdir, pattern, recursive = T, full.names = T) to <- gsub('PRV_MdBio_', '', from) to <- gsub('_virus_only_filtered', '', to) file.rename(from, to) bamfiles <- grep('.bai', ...
c20a59a19ba8dfdb4bd0137169aa91cb2b70f7e9e1b1d4bd64a5046b9b75ef80
R
438
17
# script for downloading data for reproducing figures of the mmcortex paper options(timeout = 100000) download.file("https://mmcortex.s3.eu-west-1.amazonaws.com/mmcortex.tar.gz", "mmcortex.tar.gz") system("tar -xvzf mmcortex.tar.gz") folder_names <- c('figs', 'output/paper_figs') for ...
026104f3f505783466e225dad2d6aeb20e9b384bc925bea597c0e894da3ed4fc
R
447
18
# Hello, world! # # This is an example function named 'hello' # which prints 'Hello, world!'. # # You can learn more about package authoring with RStudio at: # # http://r-pkgs.had.co.nz/ # # Some useful keyboard shortcuts for package authoring: # # Install Package: 'Cmd + Shift + B' # Check Package: ...
5606cae0b9f97d1051581493d971c57eb8cadcaedf993c21ad4b6e47e8a040cf
R
450
11
#' premessa: A package for normalization and debarcoding of CyTOF data. #' #' For the normalizer GUI refer to the documentation for the \code{normalizer_GUI} function #' by typing \code{help('normalizer_GUI')} in your R session. For the debarcoder GUI refer #' to the documentation for the \code{debarcoder_GUI} function...
50793b9fd6caaaccce22679377e8e72dccaa5d77ae8e4c3e5e7cfa0ed44f962b
R
452
16
#!/usr/bin/env Rscript library(tidyverse) library(odbc) library(DBI) ####################################################### rm(list=ls()) #Establish connection con <- DBI::dbConnect(odbc::odbc(), "GLASSv3") new_dat <- read.delim("/projects/verhaak-lab/GLASS-III/results/mutect2/consensusvcf/consensus.normalized.sor...
1898620401a181de6002a0a8fe6ce6a4c8a2ed863ada7ef4a49b0796446cb7c6
R
455
12
p.adjust.wy<-function (cov, pval, N = 10000) { # 检查 cov 和 pval 是否为标量 if (is.null(dim(cov)) || (length(cov) == 1 && length(pval) == 1)) { # 对于标量情况,直接返回 pval return(pval) } zz <- mvrnorm(N, rep(0, ncol(cov)), cov) zz2 <- scale(zz, center = FALSE, scale = sqrt(diag(cov))) Gz <- apply(2 * pnorm(abs(zz2),...
7a166e20803e8db865eca0651d8532fbd51dc555cbda289e5c0ff1edeca92222
R
456
21
Sys.setenv(RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/MacOS/pandoc") render_report = function(graph_weight) { rmarkdown::render( "step3_check_results.Rmd", params = list(graph_weight=graph_weight), output_file = paste0("step3_check_results_", graph_weight, ".html") ) } weights = c("0.0", "0...
da66b7b40432f1c7a656a7d3e4556bd1c9bdbcb6c679374454b9bd18e6532791
R
459
12
library(magrittr) options(repos = c(CRAN = "https://cloud.r-project.org")) list_packages <- c("xgboost", "pdp", "smoof", "mlrMBO", "lhs", "shapviz", "ggfittext", "gggenes", "BBmisc", "ParamHelpers", "DiceKriging") dir.create("cran/sources", showWarning = FALSE, recursive = TRUE) miniCRAN::pkgDep(list_packages) %>% ...
64ec39a107f6b4e7813cb31772ec570ad1f94fb9c8576d850369ebc5694226d1
R
461
21
###################################################Scoring helper functions######################### rmse = function(x){ return(sqrt(mean(x^2))) } rmsr = function(x, e){ return(sqrt(mean((x/e)^2))) } wmse = function(x, w){ #w = 1/e or 1/e^2 x = x[is.finite(w)] w = w[is.finite(w)] return(sqrt(sum(w*(x)^2)...
65aa0c0d3e20a954f605fb366b4ed3f5e3199001459906ee60dc4fccdb25e2cf
R
463
14
#' Add random number columns in data frame with specific seed to validate machine learning algorightms #' #' @param #' #' @return #' #' @export add_randomized_binom_column <- function(df, n, prob) { random_values <- function(n, prob = runif(1, min = 0, max = 1)) { factor(rbinom(n = nrow(df), size = 1, prob = prob...
0447d0bd0a02b52b343ca766f9f3b7ad55b78095c82b62e1340ddd532b60e85c
R
465
15
#' @importFrom utils capture.output skip_if_flywire_materialize_unavailable <- function( message = "Skipping live FlyWire tests: materialize service unavailable") { cave_versions <- try({ capture.output( capture.output( invisible(flywire_cave_client()$materialize$get_versions(expired = TRUE)), ...
8069104c76b23ff7561fd5c2233c77b28bf1959a7c85231447e3438d12393dc8
R
468
23
#' @title Mouse Human gene symbol lookup table #' #' @description A 2-column tibble of mouse and human gene symbols #' @name mm_hs #' @format A 2-column tibble NULL #' @title Hallmark genes #' #' @description Human gene symbol lists for hallmarks #' @name pathways.hallmark #' @format A list of 50 vectors NULL #' @...
a6554aa3db523cc5f11c77116a984b2661ef24f83ebec6cd38d32b977a17836c
R
469
15
#' A small example Seurat object for testing #' #' A subsetted version of a 10X Genomics PBMC dataset, containing 80 cells #' and 230 genes. This is the same dataset as SeuratObject::pbmc_small. #' #' @format A Seurat object with: #' \describe{ #' \item{assays}{RNA assay with counts and data layers} #' \item{meta.d...
c33f3417ef77312e0bc57a9602d123d37e35dd12a08ea557d215ffe9f869b1eb
R
470
9
options(Ncpus = 8) install.packages(c("devtools", "arrow", "randomForest", "jsonlite", "htmlwidgets", "ggplot2", "plotly", "BiocManager")) BiocManager::install("preprocessCore", configure.args = c(preprocessCore = "--disable-threading"), force=TRUE, update=TRUE, type = "source") BiocManager::install(c("minfi", "Rsamt...
02a9bc2d9fb6c6a24b426de8168dbf968257e9fcd1e7df25c977ad57c79e883c
R
473
12
test_that("manc_mutations", { skip("Skipping due to a regression in the MANC DVID setup.") withr::local_options(choose_malevnc_dataset('VNC', set = F)) expect_s3_class(muts <- manc_mutations('956250c3062245f9b63a000dfe05289c'), 'data.frame') expect_equal(manc_size(10000, node = '19fdf756b8c947...
b14d58385d165e6e0eaba5f8eb8d94ec53b766acba67116c9eb9a519ff011905
R
473
13
mancsomapos.orig=read.csv('data-raw/dd51_sphere_annotations_21-02-12.csv') mancsomapos=mancsomapos.orig[c("X", "kind", "from", "to", "comment")] colnames(mancsomapos)[1]="n" mancsomapos[,c("X","Y","Z")] <- xyzmatrix(mancsomapos.orig$mid_point) mancsomapos=mancsomapos[c("n", "X",'Y', 'Z', "kind", "from", "to", "commen...
d44978236a43d9df6579850dbc52e74123238c346eba67504a31517506e2638d
R
479
19
install.packages("easypackages") library("easypackages") libraries("readr", "data.table", "dplyr", "gtsummary","openxlsx", "readxl", "MASS", "ggplot2") ggplot(as.data.frame(mfa), aes(x=avg_Rcount, y=Pred/avg_Rcount)) + geom_point() + geom_hline(yintercept = 1) ggplot(as.data.frame(mfa), aes(x=Pred, y=Pred/avg...
ea21dc9bc7a6ebb68968d775306e9e869289b40694dc655cf7c61a2140d33966
R
487
17
test_that("Test StatsCellsInside", { coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds", package = "SpNeigh" )) boundary_points <- GetBoundary( data = coords, one_cluster = 2, eps = 120, minPts = 10 ) boundary_polys <- BuildBoundaryPoly(boundary_points) cells_insi...
1fb6fe5a78ee16f14631835b3798ecacd877fb165da85312b5c3db61d2e84794
R
493
10
# read whole file txt <- readLines("/data/share/lab/lab specific overview and lists/Plasmid Sequences/p216_pAAVS1-TetOn-zKRAB-dCas9-P2A-mCherry/pAAVS1-TetOn-zKRAB-dCas9-P2A-mCherry.gbk") # extract only the sequence portion (between ORIGIN and //) seq_lines <- txt[grep("^ORIGIN", txt):length(txt)] seq_lines <- seq_li...
ecd4d37ff97a3ae6359eb623edf19af1ca3b23de799707924b2647abfe539c18
R
497
18
#' Custom Color Palette #' #' A character vector containing 15 colors. #' #' @docType data #' @name my_colors_15 #' @usage my_colors_15 #' @format A character vector of length 15. #' @examples #' plot(1:15, 1:15, pch = 16, col = my_colors_15) #' barplot(rep(1, 15), col = my_colors_15) #' #' @export my_colors_15 <- c( ...
bf9b25cbfa6e35ab5686a77cf4e42ba950cc64e19a7daf7d7677a0493d985dc5
R
499
12
library(ggplot2) library(dplyr) library(reshape2) # params thresh = 543 # dPixel>thresh -> "1" (moved) ## Example value; calibrate for each dataset if acquisition conditions differ bout.thresh = 12 # in frame ## Example value; calibrate for each dataset if acquisition conditions differ nframe = 56517 nhour = 1...
db8d915891c9cf16d8d6eb94e149d2acd48af29dc7d1f3b9cc24ce4756031421
R
501
20
#' #' #' @param #' #' @return #' #' @export detect_factors <- function(df, max_distinct = 10, debug = FALSE) { c_factors <- df %>% dplyr::select(-ends_with("_YEAR"), -ends_with("_NEVT")) %>% dplyr::summarise_all(dplyr::n_distinct) %>% tidyr::gather(column, n_distinct) %>% dplyr::filter(n_distinct <= m...
7b778646dfd2f8fd239efcf11174c2b32a36fb7200bd29a42a02c08860ed2024
R
507
18
#' Custom Color Palette #' #' A character vector containing 15 colors. #' #' @docType data #' @name colors15_cheng #' @usage colors15_cheng #' @format A character vector of length 15. #' @examples #' plot(1:15, 1:15, pch = 16, col = colors15_cheng) #' barplot(rep(1, 15), col = colors15_cheng) #' #' @export colors15_che...
78f2baa888b2ef44c422d6e92b2fb6ea1ef13b85aa1408460d5f2675bd6e5310
R
528
12
# Install all the things if (!require("devtools")) {install.packages("devtools")} library(devtools) if (!require("tidyverse")) {install.packages("tidyverse")} if (!require("data.table")) {install.packages("data.table")} if (!require("Matrix")) {install.packages("Matrix")} if (!require("irlba")) {install.packages("irlba...
cd1dfdbf26ca096e6b8013f333bb9f7c3359ec05a6e6c78905ae5f98f71f8bba
R
535
14
test_that("flywire_user_info works", { # requires admin privileges since middle_auth v2.29.0 (April 2025) res <- tryCatch( flywire_user_info(60, datastack_name = "flywire_fafb_public"), error = function(e) e ) skip_if(inherits(res, "error") && grepl("403|admin", conditionMessage(res)), "Requir...
cdcabe5b976f9a2a7d6caf2ca0050ffc3e27538408eeffea26e9933a7641142c
R
535
17
library("DESeq2") pheno <- read.csv('data/pheno.csv') edata <- read.csv('data/count_tb.csv', row.names=1) edata <- edata[, as.vector(pheno$id)] table(names(edata) == pheno$id) # run DESeq dds <- DESeqDataSetFromMatrix(countData = edata, colData = pheno, design= ~ group) dds <- DESeq(dds) re <- results(dds, contrast=c...
60ed2bb681bd6eb44be4d2bd9ffb0d2153739be47decd196dcd5c5acfa2041f7
R
537
24
get_sampling_trials_idx <- function(ls_json_i) ls_json_i$trial_type=="rdk-sampling" sampling_idx <- lapply(ls_json, get_sampling_trials_idx) %>% unlist() %>% which() ls_json[sampling_idx+0][[1]]$start_time + ls_json[sampling_idx+0][[1]]$rt + 800 + # Start duel ls_json[sampling_idx+2][[1]]$rt ls_json[sampl...
b6420e829b6811e4e4a8e62750824de83e7df615e6834aab8a2146c8376db4bc
R
537
20
#Bar plot of left and right cells from Buchanan and inhouse library(ggplot2) df <- data.frame(table(data@meta.data$Position)) df$Var1 <- c("Left","Right") pdf("figure_leftright_barplot.pdf", width = 3, height = 3) ggplot(df, aes(x = Var1, y = Freq)) + geom_bar(stat = "identity", fill = c("yellowgreen","plum3"), wid...
0fc28c814cbb928c6c972a4a191d8cd818361adb13d8891df80fa38d6d0eb141
R
543
17
#Bar plot of fed and fasted cells from inhouse ##Already subset inhouse library(ggplot2) df <- data.frame(table(data@meta.data$Nutr.cond)) df$Var1 <- c("Adlib", "Fast") pdf("Figure_fedfasted_barplot.pdf", height = 3, width = 3) ggplot(df, aes(x = Var1, y = Freq)) + geom_bar(stat="identity", fill = c('#117733', '#AA...
5a49061b377251cf4d8a9feab0a2e86cc9aa891b2d555ac37cd3c9fb26cfe7e3
R
544
17
test_that("Test PlotCellsInside", { coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds", package = "SpNeigh" )) boundary_points <- GetBoundary(data = coords, one_cluster = 2) boundary_polys <- BuildBoundaryPoly(boundary_points) cells_inside <- GetCellsInside(data = coords, bou...
5d4c6f8b7eac5f6afa9245afb668e07c7802b922482f4cd1e2955590b20ae2be
R
552
14
cv.nodewise.totalerr<-function (c, K, dataselects, x, lambdas) { totalerr <- matrix(nrow = length(lambdas), ncol = K) for (i in 1:K) { whichj <- dataselects == i glmnetfit <- glmnet(x = x[!whichj, -c, drop = FALSE], y = x[!whichj, c, drop = FALSE], lambda = lambdas) predictions...
90599c0380b8841e3d46444f002c19baae698dbc060a4eb12bb37da3361ba570
R
554
29
#' Alignment IDX statistics from a list of .BAM files. #' #' @export idxstats.bams <- function (bamfiles, bamnames=NULL) { require(Rsamtools) #require(plyr) nbam <- length(bamfiles) if (is.null(bamnames) ) { pattern <- '.bam' bamnames <- gsub('.*\\/', '', bamfiles) bamnames <- gsub(pattern, ...
f249ec1a3ca540e35b7f7fd2237926f7baf4d214610074597e6c71e45de396b9
R
566
15
cv.nodewise.err.unitfunction<-function (c, K, dataselects, x, lambdas, verbose, p) { if (verbose) { interesting.points <- round(c(1/4, 2/4, 3/4, 4/4) * p) names(interesting.points) <- c("25%", "50%", "75%", "100%") if (c %in% interesting.points) { message("The ex...
8e50f1c2704954803a8d9b40c68b73f1c020f79c2d58ece5224ff82535a67d7e
R
570
19
library(purrr) library(dplyr) # Set working directory - adjust path as needed # setwd("path/to/STEP7.Training_INGENE/") dataset = "your_training_dataset_name" regions = c("dlpfc") walk(regions, function(region){ files = list.files(sprintf("%s/output/summary/%s", getwd(), dataset,region)) extra = bin...
a019a2505fa6c3a5d4063330b88810e3b01d0c3fb4d163e79806d44091fff9aa
R
582
21
# base URLdecode gets very slow for long URLs urldecode <- function(x) { curl::curl_unescape(x) } # unfortunately curl::curl_escape escapes slashes in URLs! # and urltools::url_encode munges the #! that neuroglancer needs # if you give it a whole URL urlencode <- function(x) { pu=httr::parse_url(x) if(is.null(pu...
ff54d4dbf6e5c5b91ae94fd8f40be5ad6a1949f07106beb226794d12d8570a54
R
582
22
test_that("Test statsCellsInside", { coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds", package = "SpNeigh" )) boundary_points <- getBoundary( data = coords, one_cluster = 2, eps = 120, minPts = 10 ) boundary_polys <- buildBoundaryPoly(boundary_points) cells_insi...
2405741557c288c69de119b6e6ec9fc163f4122fa66c6afa9ed976436420c87f
R
586
23
#' @keywords internal "_PACKAGE" ## usethis namespace: start #' @importFrom data.table := #' @importFrom data.table .BY #' @importFrom data.table .EACHI #' @importFrom data.table .GRP #' @importFrom data.table .I #' @importFrom data.table .N #' @importFrom data.table .NGRP #' @importFrom data.table .SD #' @importFrom ...
34c3d858c54619c02d56f42f741653dafb7000f2500be58af1e3ea8120d673c6
R
586
14
test_that("upset plot works", { list = list(A = LETTERS[1:10], B = LETTERS[8:15], C = LETTERS[10:13]) venn = Venn(list) data = process_upset_data(venn, order.intersect.by = "size", order.set.by = "name") expect_equal(data$top_da...
a9aed64fb401c60f5456ef7c92b2d182d066a524cd7b62a159c28ec0c5ac1988
R
587
28
library(reticulate) names = list( "data/pancreas/pancreas_multi_celseq2_expression_matrix_table.txt", "data/pancreas/pancreas_multi_celseq_expression_matrix_table.txt" ) datasets <- list() genes_list <- list() for (i in 1:length(names)) { datasets[[i]] <- t(as.matrix( read.table(names[[i]], sep="\...
0e77880d37104e9018c916720da597870a75d98681443f7171d3414b87111567
R
592
17
test_that("nginfo works", { df=data.frame(id=c(10000,10002), type=c("DNp01"), side=c("L", "R")) tf=tempfile(pattern = 'mancinfo.json') on.exit(unlink(tf)) expect_silent(write_nginfo(df, f = tf)) bl = list(`@type` = "neuroglancer_segment_properties", inline = list( ids = c("10000", "1...
cd710151299286daf78ccb510408f6074472cfa10d1d369e7440c9d05ec404a0
R
595
17
# ----------------------------------------------------------------- # Zip data files that are to large for GitHub # ----------------------------------------------------------------- library(zip) all.data.files <- list.files("../data/processed_data", recursive = T, full.names = T) file.sizes <- file.size(all.data.file...
25baaa5d25d062094a3d3447272f819db64322142979fd042abc23f7851d4327
R
614
14
connections_princeton_no_threshold <- memoise::memoise(function() { fcd=fafbseg:::flywire_connectome_dir(version = 783) cpn=file.path(fcd, 'connections_princeton_no_threshold_v783-zstd19.feather') if(!file.exists(cpn)) { message("downloading princeton synapses!") ud='https://flyem.mrc-lmb.cam.ac.uk/flycon...
2653b0a4440c820db563bf538d6f3ea818345a972c85a482fddc3ae9c69e4d6c
R
614
19
library(sceasy) library(Seurat) library(reticulate) use_python("/home/zoo/ball6395/software/miniconda3/envs/scpy39/bin/python3.9") loompy <- reticulate::import('loompy') parser = argparse::ArgumentParser(description="Test paralog importance on cell marker genes") parser$add_argument('-I','--input', help='input h5ad')...
51f7c28b657827a707b017688ba523cadd1b2abc001ba01bd9e0ccc7c60b43ad
R
614
19
#' @name GOhuman #' @title GOhuman #' #' @description List containing gene symbols for 71 GO function #' #' @docType data #' #' @format #' \describe{ #' \item{genesets}{List containing gene symbols for 71 GO function (GO slim terms containing between 50 and 1,000 genes) downloaded from the Gene Ontology #' ...
20922af1ae2124519275e5edb1c6fa9c0758bba7acd6e38dc045b78e9a314be1
R
615
20
#' banc-updateids — Refresh root_ids in SeaTable via bancr::banctable_updateids. #' #' Thin wrapper around `bancr:::banctable_updateids()` that resolves stale #' root_ids in `banc_meta` and pushes the refresh back to SeaTable. #' #' @section Reads: #' - SeaTable `banc_meta` #' - CAVE (root_id resolution) #' #' @sec...
ba0e62a9ad770a9aecdca3c7b17722e4d57ca05693a91c9d685b46e2410ffb27
R
622
16
test_that("fanc_scene works", { expect_type(sc <- fanc_scene("648518346498932033"), 'character') }) test_that("switching between banc and fanc works", { op=choose_fanc() on.exit(options(op)) expect_match(fanc_cloudvolume_url(), "mar2021_prod") expect_match(with_banc(fanc_cloudvolume_url()), "wclee_fly_cns_00...
220e4aa0746257c7b73815324a4d99875fb54cfb277101df15b31368bd126b24
R
623
26
example("registration_block_cor", package = "spatialLIBD") results_enrichment <- registration_stats_enrichment(sce_pseudo, block_cor, "age", gene_ensembl = "ensembl", gene_name = "gene_name" ) results_enrichment_nan <- registration_stats_enrichment( sce_pseudo, block_cor = NaN, "age", g...
3505c0e0d66365f6e6968f7506243add0a7d0da34b601cd506e0693729542f5a
R
624
16
# Simple joint test # Take the first entry of the design list # emc stores a design list (with length 1 for non-joint models) # or for joint models length x where x is the number of joint components design_in <- get_design(samples_LNR)[[1]] prior_in <- get_prior(samples_LNR) data_in <- get_data(samples_LNR) prior_join...
982fe93e27bc4bcd00f0281736736640622dd444d84cc1a449475f030978052f
R
624
22
--- title: "Home" site: workflowr::wflow_site output: workflowr::wflow_html: toc: false editor_options: chunk_output_type: console --- Table of content: - Pre-processing - [Raw data filtering](./prep_filtration.html) - [Alignment of the datasets](./prep_alignment.html) - Analyses - [Overview of the dat...
d26187a342b5400d6b11ec84638ddb60f2556ca4567b6714e508fe7994065651
R
625
26
Sys.setenv(RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/MacOS/pandoc") render_report = function(cell_type_name, graph_weight) { file_tag = paste0(cell_type_name, "_", graph_weight) rmarkdown::render( "step2_evaluate_gene_sets_goseq.Rmd", params = list(graph_weight=graph_weight), output_file = ...
02980a3ff4074ef9ff15cac1ebe41c1a0943918be6c80700804d2998c6482bfc
R
629
15
# sccoda 数据准备========================= Epilepsy19_cell_counts <- as.data.frame(table(Epilepsy19@meta.data$idents, Epilepsy19@meta.data$Anno_Idents)) library(dplyr) library(tidyr) #pandas.Dataframe:第一列为样本名,其余每列各代表一种细胞类型,值表示细胞数量 Epilepsy19_cell_counts <- Epilepsy19@meta.data %>% count(idents, Anno_Idents, name = "n") %...