sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
69552386a8ca09d680aec77bf57834c07946c7d998a5fc8cbec26327adca4cb5
R
632
15
test_that( "add_qc_metrics returns modified spe", { if (!exists("spe")) spe <- fetch_data("spe") # run metrics spe spe_qc <- add_qc_metrics(spe, overwrite = TRUE) expect_equal(ncol(spe), ncol(spe_qc)) ## same number of spots expect_equal(ncol(colData(spe)) + 7, ncol(colD...
4113db4cb887b9d086b4e30e3c96c472a08d5505fb6604b4923f78e65a2cf594
R
634
23
sandwich.var.est.stderr<-function (x, y, betainit, Z) { n <- nrow(x) p <- ncol(x) if (!isTRUE(all.equal(rep(1, p), colSums(Z * x)/n, tolerance = 10^-8))) { rescale.out <- score.rescale(Z = Z, x = x) Z <- rescale.out$Z } if (length(betainit) > ncol(x)) { x <- cbind(rep(1, nrow(x)), x) } else {...
f9c76b53f0fd3918771fa60f6b00c86e897e02866c42daa6d431581fe76bf60f
R
636
21
test_that("Test GetCellsInside", { coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds", package = "SpNeigh" )) boundary_points <- GetBoundary( data = coords, one_cluster = 2, eps = 120, minPts = 10 ) boundary_points_sub <- subset(boundary_points, region_id == "2") ...
3a744f41cf9412bf632ca2e737e70e4ef53de3257b7e558f8d12cd5c95ba673f
R
657
21
#' #' #' @export #' #' require(tidyr) require(fuzzyjoin) require(data.table) ## add.correct.ends <- function(bam.lortia, correct.strings.5p='correct', correct.strings.3p='correct') { bam.lortia$correct_tes <- F bam.lortia$correct_tss <- F bam.lortia$correct_tss[grepl(paste(correct.strings.5p, collapse='|')...
7d60007c1c9c74137a73f5975bbbed3784c99b540bd18144cc00083eb30b83ed
R
658
18
#' #' #' @param #' #' @return #' #' @export nested_xgboost_cox_cv_model_matrix <- function(x, event_incident, event_agediff, ...) { dset <- x %>% dplyr::filter(!is.na(!!rlang::sym(event_incident))) %>% dplyr::mutate(event = ifelse(!!rlang::sym(event_incident) == 1, !!r...
e073d9ae2e6bd921a49762a7cc285830fdc9647e4755dc2b3589654557ee88ad
R
660
20
#!/usr/bin/env Rscript library(tidyverse) args <- commandArgs(trailingOnly = TRUE) dat <- read_tsv(args[1], col_names = F) names(dat) <- c("CHR", "Position", "Depth") p <- ggplot(dat, aes(Position, Depth)) + theme_minimal() + geom_vline(xintercept = seq(1, max(dat$Position), 5000), colour = "grey96") + g...
b7dee9881ee3e6704ea6ea69199152d2adf08608a999602882f375207362fe26
R
664
24
UminPd<-function (U, CovS) { if (is.null(dim(CovS))) { Tu <- sum(U^2/CovS) if (is.na(Tu) || is.infinite(Tu) || is.nan(Tu)) Tu <- 0 pTu <- as.numeric(1 - pchisq(Tu, 1)) } else { Tu <- as.vector(abs(U)/(sqrt(diag(CovS)) + 1e-20)) k <- length(U) V <...
62011f6f6a6741932b80be34113d7a7891e89e101fe65988a74213222232d71e
R
665
25
## Obtain the necessary data if (!exists("modeling_results")) { modeling_results <- fetch_data(type = "modeling_results") } ## query spatialDLPFC modeling results query_modeling_results <- fetch_data( type = "spatialDLPFC_Visium_modeling_results" ) ## Compute the correlations cor_stats_layer <- layer_stat_cor...
8e567f21bf61463627e0a28f127ec3e6c8b35feb71be1c50dce30da1ccfe96b2
R
667
26
# ----- # UMS IPSIT BIOINFO - Licence GPL-3 # https://github.com/fdumbioinfo/moal # ----- # # moal install source("https://raw.githubusercontent.com/fdumbioinfo/rtools/main/moal-demo/0-moal-install-r-universe.r") library(moal) # change working directory to data_analysis folder setwd(".") # input data "inputdata/DESeq20...
1508dd336e3c01f6385c967102e86f8f349a45fdcefc8b0fa8ee58519fad1928
R
670
27
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( "step6_check_results.Rmd", params = list(cell_type_name = cell_type_name, graph_weight=graph_weigh...
f3b6320cb4547187c7120a77db6fd718895cf20aef43ff6c585dd8edc14aed70
R
670
20
## create Rdata file used in tests and examples library(conos) library(dplyr) library(pagoda2) small_panel = readRDS("panel.rds") ## located in older versions of Conos ## simply subsetted panel.rds small_panel[[1]] = small_panel[[1]][c(1:1000), c(1:100)] small_panel[[2]] = small_panel[[2]][c(1:1000), c(1:100)] #...
85e7e7ca8e3e3c8736467fb4219815dda230da3dbafb901bd7e545f0cdada678
R
671
20
library(seqinr) var_muts = function(){ var_aligned = read.fasta("Datasets/var_aligned.fasta", seqtype = "AA", forceDNAtolower = F) #need to match variants up, the only length change is a pair of deletions, none have insertions var_aligned = lapply(var_aligned, function(x){x[1:201]}) refseq = var_aligned$Wu...
4f82a01f12ce76cba39df3a8be6bb8e7dbf89fdbcbd0e5c55746ddc0440151de
R
672
14
# function to convert distance data from 'dist' to 'dataframe' format. # from https://stackoverflow.com/questions/23474729/convert-object-of-class-dist-into-data-frame-in-r DistToDataframe <- function(inDist) { if (class(inDist) != "dist") stop("wrong input type") A <- attr(inDist, "Size") B <- if (is.null(attr...
59c0af6d0675211dcf3dd76729550ae52e8e1b5c1610dfb5d3f13d8a5a87f212
R
672
20
datos <- read.csv("/home/usuario/Documentos/Doc/matlab/resultados/onset/metadata.csv") require(ggplot2) require(GGally) library(dplyr) ggcorr(datos[,-1], palette = "RdBu", label = TRUE) data_filtrada <- datos %>% dplyr::select(-tipo_marca,-participante, -orden_preg, -Var1, -offset_samples, -outliers, -ti...
fbc5e7502ff13cd62df3d7b8c33924a54bed0d4afccb830beb727fcdbcdeb4b7
R
672
21
# Function to add a new column with the rightmost non-NA value add_rightmost_non_na <- function(dt, columns, new_col_name) { dt[, (new_col_name) := apply(.SD, 1, function(row) { rev_row <- rev(row) rightmost_non_na <- rev_row[which(!is.na(rev_row))[1]] return(rightmost_non_na) }), .SDcols = columns] } ...
19a88699911f2ba0006a13ff534c286e76a76b8aed88fed1a8afe121da238a53
R
673
21
test_that("Test PlotWeights", { coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds", package = "SpNeigh" )) cells_c2 <- subset(coords, cluster == 2)[, "cell"] weights_cen <- ComputeCentroidWeights(data = coords, cell_ids = cells_c2) expect_silent(PlotWeights(data = coords, wei...
75924cedd4f1f2f0844fbe1a041c983c5cf126b34d64009663dc5fbe30412fb6
R
673
23
library(ggridges) library(ggplot2) library(viridis) G_L <- paste(dir, "Group_wr_pa.csv", sep = "/") %>% read.csv() G_L$Age <- as.factor(G_L$Age) G_L$G_1 <- as.numeric(G_L$G_1) # Plot graph <- ggplot(G_L, aes(x = G_1, y = Age, fill = after_stat(x))) + geom_density_ridges_gradient(scale = 3, rel_min_height = 0.01) +...
28b42fa871881dec538eda2ad8c4bbef5a361334f69cc39286b14879f01e57c9
R
675
16
library(SOTK) library(testthat) context("Checking the initionalization function.") test_that("Invalid/exclusive arguments", { pvNmfObj <- readRDS("../inst/testdata/PV.RDS") dataL <- list(PV = pvNmfObj) rankL <- list(PV = c(2:6)) expect_error(SOSet(NMFobjL = pvNmfObj, NMFrankL = rankL,...
4689ed97f053976487d4925d4bea72897bd3344ff90ce7a071520fc56b04565c
R
677
25
### Split column into new columns based on a separator, if the number of new columns is unknown using data.table library(data.table) dt.splitcol <- function(DT, coltosplit, newcolpattern, sep) { # Ensure DT is a data.table setDT(DT) # Split the specified column by the separator split_results <- DT[, tstr...
70a00410de4bb6d8f167973176693ceb5518f009cd4edc2df2c2db1bbc26ca77
R
680
27
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( "step4_evaluate_gene_sets.Rmd", params = list(cell_type_name = cell_type_name, graph_weight=graph_...
3027d135474a84e2d6bd66d1937be198e7a7d32a7a14060aad575c18a6e1bd1d
R
688
23
#After quality control library(Seurat) data <- readRDS("/home/rstudio/shared_data/nodose/latest-integration-230403/nodose-integrated.RDS") DefaultAssay(data) <- 'integrated' data <- RunPCA(data, npcs = 100, verbose = F) DIMS<-c(30, 40, 50, 60) resolution.list<-seq(0.6, 2.0, 0.2) for (i in DIMS) { #data <- RunUMA...
c5952781aa148da623eb36ba53d04ea1ad57d4a62deb3c9092df31959c374ebd
R
688
21
#============================================================ # Function vecvel() -- Microsaccade Toolbox 0.9 # (R-language Version) # Authors: Ralf Engbert, Petra Sinn, Konstantin Mergenthaler, # and Hans Trukenbrod # Date: February 20th, 2014 #============================================================ vecvel <- fu...
c8a9080f220917c73138d2d6dad3efa2fc60a021957d98efff716f7ae232a881
R
688
18
#' Combine multiple continuous variables by proportion of positive values #' #' To summarize multiple features, the proportion of features with positive #' values for each spot is computed. #' #' @param cont_mat A \code{matrix()} with spots as rows and 2 or more continuous #' variables as columns. #' #' @return A \code...
907f5b9ca30bf28f784c8e6308e7e6c209a8f1ad37f2502f0bc93122c2959ff3
R
690
27
create_conda_env <- function(name, path, channels = list("defaults"), conda_deps = list(), pip_deps = list()) { conda_deps$pip <- pip_deps deps <- list( name = name, channels = channels, d...
a59ce0128ef196bb740c11dc8e6391f9de21748db9c9b0ee93c61e96375ff496
R
690
25
####################################################### # Add ssm2 coverage counts to db # Date: 2022.02.28 # Author: Kevin Johnson ####################################################### # Necessary packages: library(parallel) library(tidyverse) library(DBI) library(odbc) con <- DBI::dbConnect(odbc::odbc(), "Verhaak...
fb7dec10a27d01fbf043e43ad8f3b9059f535783e47bdfcd88aaf0e60ccb703b
R
690
25
library("DR.SC") library(Seurat) library(anndata) library("scater") ST <- read_h5ad("./ST.h5ad") ST$var_names_make_unique() count <- t(ST$X) meta_data <- data.frame(row=ST$obsm$spatial[,1], col=ST$obsm$spatial[,2]) row.names(meta_data) <- colnames(count) seu <- CreateSeuratObject(counts=count, meta.data = meta_data)...
922d6e54e88cc85eb596d9312c81ddceef005843165ea1597464fcaf30e2f642
R
692
25
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...
e4a3666b5600a7530f596336d0f48fe8fd71b080b491c53b97c34bede9b64417
R
694
21
#' @name GOmouse #' @title GOmouse #' #' @description List containing gene symbols for 10 GO function #' #' @docType data #' #' @format #' \describe{ #' \item{genesets}{List containing gene symbols for 10 GO function (GO:0016853 #' , GO:0005615, GO:0005768, GO:0007067, GO:0065003, GO:0042592, GO:0005929, ...
a1dca49b7c1b8c13ff0078168dd161ed3a8c51d1d2e31f40644a972423f240e7
R
697
23
test_that("Test plotWeights", { coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds", package = "SpNeigh" )) cells_c2 <- subset(coords, cluster == 2)[, "cell"] weights_cen <- computeCentroidWeights(data = coords, cell_ids = cells_c2) p <- plotWeights(data = coords, weights = we...
c3c7ae65d0b90cf742a891498a421a06108fe272c75cf883cb5413d61931c71d
R
698
21
--- title: "License" output: workflowr::wflow_html: toc: false editor_options: chunk_output_type: console --- What license are you using for your code? See [choosealicense.com][choose] for help deciding. It's a convention to save a file `LICENSE` in the root of your Git repo that contains the license text. Wh...
7e205db1cb408c1ffaef4dce44a383ca8ff76adc3152027703fd1e8861000b37
R
699
30
test_that("computeSpatialInteractionMatrix computes correct counts", { # Deterministic coordinates df <- data.frame( x = c(0, 1, 5, 6), y = c(0, 0, 0, 0), cell = c("A1", "A2", "B1", "B2"), cluster = c("A", "A", "B", "B") ) res <- computeSpatialInteractionMatrix(df, k = 1...
ba68613b1e286c0789081164d80d28e6a6ec8f2beaf6b58da09acbe66f0deede
R
701
22
# Suppress R CMD check NOTEs for data.table NSE variables utils::globalVariables(c( ".", ".N", ":=", "adjusted_influence", "adjusted_influence_minmax_by_seed", "adjusted_influence_minmax_by_target", "adjusted_influence_norm_by_sources_and_targets", "id", "influence_original", "influence_summed", "is_seed", ...
c8c4700b4d9917b0e5ff8dc2d60251b091a237bcad715a5d876c6a4c1c691342
R
702
27
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( "step5_evaluate_gene_sets_cell_types.Rmd", params = list(cell_type_name = cell_type_name, graph_we...
d8c63bf96287679201db558f3e158ba30117c1ba58d9bdc3955951b0cc62a781
R
702
17
# R / Bioconductor dependencies for the hemostasis pipeline (R 4.5.2) # Run: Rscript R_dependencies.R if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") # Bioconductor packages BiocManager::install(c( "clusterProfiler", # 4.18.4 — KEGG / GO enrichment "org.Hs.eg.db", # h...
c5f68068a88a16958480a9c173435018246a45ddfb99bb2545fd45fbc9d29e5b
R
705
33
library(dplyr) library(readxl) library(ggpubr) library(rstatix) RANKL_TEC <- read_excel("data/RANKL_TEC.xlsx") p <- ggplot(RANKL_TEC, aes(x = cTEC, y = gMFI)) + geom_point() + stat_cor(method = "pearson", label.x = 0.5) + geom_smooth(method = "lm", se = FALSE) + theme_pubr() + ylab("RANKL gMFI") ggsave( f...
7ca56499b0baa55d3dcdd1ab07f7d075172ab230ac53dd1b9f8c369e7c940306
R
708
16
test_that("flywire nuclei works", { token=try(chunkedgraph_token(), silent = TRUE) skip_if_not_installed('reticulate') skip_if(inherits(token, "try-error"), "Skipping live flywire tests") skip_if_not(reticulate::py_module_available("cloudvolume"), "Skipping live flywire tests requiring p...
fe4e840862d557c52532a3bfcde896c4d49c14dbe7b4f6bbe22147a8c0d383b5
R
711
16
suppressMessages(library(monocle3)) test_monocle3 <- function(X,genes,cells,UMAP,pr_graph_cell_proj_closest_vertex,F,B,n_jobs,...){ rownames(X)=cells colnames(X)=genes cds = new_cell_data_set(t(X)) cds@int_colData@listData$reducedDims@listData$UMAP = UMAP cds@principal_graph_aux[["UMAP"]]$pr_graph_...
c8587be7dc133c49fbe3e94d192d6cecf1a50bed9bd4fc43a15ffd6d52969ec6
R
715
21
#################################################### # Plotting the correlation matrix between factors # #################################################### library(MOFA2) library(ggplot2) library(dplyr) library(circlize) library(reshape2) # Retrieving MOFA load("C:/Users/User/Documents/Drive_PC/Lucas/GitH...
40b172a1846192912855e15f8ea5d6e1139f6b2e9c41e041f031def1c0cd51ac
R
716
23
test_that("Test getCellsInside", { coords <- readRDS(system.file("extdata", "MouseBrainCoords.rds", package = "SpNeigh" )) boundary_points <- getBoundary( data = coords, one_cluster = 2, eps = 120, minPts = 10 ) boundary_points_sub <- subset(boundary_points, region_id == "2") ...
0e37ccf2d926fa2e0b4767b9c5d417ee1f6a81df95936bbffbc22d55982ea76d
R
717
32
.openDev <- function(fileName, devType, ...) { if(devType=="pdf") pdf(paste0(fileName, ".pdf"), ...) if(devType=="png") png(paste0(fileName, ".png", type="cairo"), ...) if(devType=="cairo_pfd") # similar to Cairo::CairoPDF? grDevices::cairo_pdf(paste0(fileName, ".pdf"), ...) } .openDevHeatmap <...
a0036007ed0c7947fb696a42216921cf8d873aaa54204cc0f58b84a8fc1a2059
R
721
26
#!/usr/bin/env Rscript args = commandArgs(trailingOnly=TRUE) # test if there is at least one argument: if not, return an error if (length(args) < 1) { stop("Please provide an input", call.=FALSE)} matrix_path <- args[1] gct_out <- args[2] #Create gct file of gene expression matrix data <- read.delim(matrix_path) ...
e5e811d5dd0cdfc62722eef46344b8edd3458fc5af997d582b1db5a1408383c2
R
722
22
library(memes) genome <- BSgenome.Hsapiens.UCSC.hg38::BSgenome.Hsapiens.UCSC.hg38 PATHDB<- "/geschwindlabshares/RexachGroup/SharedData/motif_databases" motifdb <- file.path(PATHDB, "CIS-BP_2.00/Homo_sapiens.meme") memeBin <- "/home/xhan/apps/meme-5.4.1/bin" run_TFenrich <- function(gr, label){ seqs <- get_sequence(g...
9514748e77aeef4edf948c6384f0d18ded48dba64f180d0afc923ea6321c665b
R
723
26
#!/usr/bin/env Rscript ####################################################### library(tidyverse) library(odbc) library(DBI) ####################################################### #Establish connection con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB4") args = commandArgs(trailingOnly=TRUE) # test if there is at l...
f8f4e5feaf3f8323ae09e2760079955d5e7f90d0ba23ef152ec867afd0d7d321
R
724
25
test_that("Test PlotStats functions", { 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) ...
550e868763eb98bf92cdf3812f925c94f568b30d7e6d2c1d8a78b30e340a39bf
R
730
17
library(seqinr) mai_seq_align = function(){ var_seqs = read.csv("Datasets/variant_sequences.csv") var_seqs$sequence = trimws(var_seqs$sequence) short_seqs = strsplit(var_seqs$sequence, "") short_seqs = lapply(short_seqs, function(x){x[13:213]}) #Mai's sequences are R319-N577. Starr's are N331-T531 #note, ...
afeebaa5b79d4d4875206225b8991a3fa0f5854281c3fa4c0c5ccec22ee91654
R
730
29
#' banc-fix-major-cell-type-errors — Integrate external tracing decisions (ORN + others). #' #' Manual spot-fixer; not part of any automated run. #' #' @section Reads: #' - `banc_edgelist()`, SeaTable `banc_meta` #' #' @section Writes: #' - SeaTable `banc_meta` (per-block targeted columns) #' #' @section Notes: #' ...
570363e32dec017ef23e48757e0b326b403ed03582986e218bfa90869e3f22d8
R
732
14
RNGkind("L'Ecuyer-CMRG") set.seed(123) # Generate some prior predictives dat <- get_data(samples_LNR) pp <- predict(get_prior(samples_LNR), n_post = 25, data = dat) drt <- function(data) diff(tapply(data$rt,data[,c("S")],mean)) test_that("plot_fit", { vdiffr::expect_doppelganger("CDF_plot_fit", plot_cdf(dat, prior_p...
61444bbe89db3b2c45d254831235bbaaa2354905a485425da127bebb70ec4d65
R
732
28
ART.A <- function(P, k, L) { # "ART-A" wgt <- rep(1,k) z <- P z[1] <- ( 1 - P[1] )^L for(j in 2:L) z[j] <- ((1-P[j]) / (1-P[j-1]))^((L-(j-1))) p <- (1-z)[1:k] k = length(p) sumZ <- rep(0, k) y <- qnorm(p) z <- y gz <- z[1] * wgt[1] sumZ[1] <- gz for(i in 2:k) { gz...
71abe9dec90ea851c883b72d736e3938d693c447517d515192b7ff4608bbfd03
R
738
26
score.getZforlambda<-function (x, lambda, parallel = FALSE, ncores = 8, oldschool = FALSE) { n <- nrow(x) p <- ncol(x) Z <- matrix(numeric(n * p), n) if (oldschool) { message("doing getZforlambda oldschool") for (i in 1:p) { glmnetfit <- glmnet(x[, -i], x[, i]) prediction <- predict(glmnetf...
eef2a83e3b66937e3f476edeb9ad6cab1a1a9bef9f490ebe9a385a6b36e2e516
R
738
32
#' @rdname mlflow_save_model #' @export mlflow_save_model.crate <- function(model, path, model_spec=list(), ...) { if (dir.exists(path)) unlink(path, recursive = TRUE) dir.create(path) serialized <- serialize(model, NULL) saveRDS( serialized, file.path(path, "crate.bin") ) model_spec$flavors <- a...
b760b39a21cae4ce9bbf5ed2fee0eb8e5e8ab2595f3f3930e4186d3fde3e2d94
R
740
17
#' Looks up marker overlap between query cluster and database cell types #' #' This function calculates the number of markers from a specified query cluster that overlap with each cell type in the database. #' #' @param cluster The name of the query cluster. #' #' @param ann An object containing marker data in `ann1$q...
8cfa13d61042bc8aa19fb66e84e812ae37f98dec76a939eb8794cf83dbf0d0b4
R
741
31
# --------- Load libraries --------- # library(tidyverse) library(rjson) data_list <- readRDS('Behavioural Analysis/scr/data/data_list.rds') # -- Get Design Matrix Sanity Check -- # # This design matrix contains events # associated with the option selection. # We expect to see motor-related activity. test <- data_...
8cb587c8f78a9a8563b598054bff9433a3094e2567b3eb4612282cc2ea4a13a2
R
746
18
#' Looks up marker overlap between query cluster and database cell types #' #' This function calculates the number of markers from a specified query cluster #' that overlap with each cell type in the database. #' #' @param cluster The name of the query cluster. #' @param ann An object containing marker data in `ann1$qu...
916af291dddc0addf0d30bd4940462068181194b3b615b74951e15d7f66f7447
R
746
20
test_that("mirror_manc works", { skip_if(inherits(try(nat::cmtk.bindir(check = TRUE), silent = T), 'try-error')) hookr=cbind(33549, 45944, 50806)*c(8,8,8)/1000 hookl=cbind(8718, 40794, 52140)*c(8,8,8)/1000 hookrl=rbind(hookr, hookl) expect_is(hookrl.m <- mirror_manc(hookrl), 'matrix') ds=sqrt(rowSums((hookr...
1774e7939dbf04d78c3e52e8e3697c57278c0976676adec9050caee95c92b635
R
748
20
#' #' #' @param #' #' @return #' #' @export xgb_load <- function(x, group_column = "group") { load_model <- function(obj) { model_raw <- xgboost::xgb.load.raw(obj$model, as_booster = TRUE) feature_names <- obj$train_obj$matrix %>% colnames model_raw$feature_names <- feature_names model_raw } readR...
a9760ac9c63ce7abfa3413ed754dc8172a6369bec40053b565733cf46c625a2b
R
750
23
library(tidyverse) library(SingleCellExperiment) library(scran) library(data.table) library(readr) library(BiocParallel) library(optparse) option_list = list( make_option("--input", default=NA, type='character', help="File path to the input (logcounts saved as an RDS object)"), make_option("--output"...
1562ab174a5067fb117d1c8fe8df83dc2267859ded65ea45e9d94274e22aef79
R
752
29
foverlaps2 <- function(DTx, DTy, by=c('seqnames', 'strand', 'start', 'end'), by.x=by, by.y=by, type='any', minoverlap=20, maxgap=0 ) { setkeyv(DTx, by.x) setkeyv(DTy, by.y) ...
9a469ef46a774e8bcb4284c987bee2e2522852a2a72341af8e8ba037d11ded5e
R
754
21
#' See the list of probes needed for each Dunedin Pace of Aging Methylation Score Model #' #' \code{getRequiredProbes} returns a list containing the IDs of the probes needed for each Dunedin Pace of Aging Methylation Score Model. #' @param backgroundList (default: FALSE). If set to true, it will return the full set of...
fcb57dde198f8b0b2b5db6b9f4d9f19e1a516b6f8ebceea3923c2ec635569cf2
R
758
36
###################### ### Assign regions ### ###################### source("banc/banc-startup.R") ################################# ### Read synapses by neuropil ### ################################# # Get BANC synapses banc.syns.nps <- arrow::read_parquet( file.path(banc.connectivity.save.path, "banc_synapses.par...
1db7913522058241dc42b60a6d6b1b5e380671a17ceeb19e9dd2a3700121b4d1
R
759
25
example("registration_pseudobulk", package = "spatialLIBD") mod <- registration_model(sce_pseudo) test_that("Checking for model terms works", { expect_equal(sum(grepl( "^registration_variable", colnames(mod) )), ncol(mod)) expect_error(registration_model(sce_pseudo, "absent"), "Formula term") ...
d850960c10fec0a02645d39e8e06e16a6a523651120f9ea7e86562ec529ecea6
R
760
22
library(EpiModel) g <- as.network(el, directed=FALSE) #generate network from synthetic edgelist data <- data[match(get.node.attr(g, "vertex.names"), data$record_id), ] #make sure node indices match participant IDs g %v% "venues" <- c(data$venues) g %v% "HIV" <- c(data$hiv) for (ii in 1:length(venues)){ g %v% venue...
4584de7684dac63792192e5715a82ace69a2b19e97a1311c5ed4a16aa6a6eab2
R
761
28
test_that("predict requires data for memory_saver fits", { dat <- subset(forstmann, subjects == levels(forstmann$subjects)[1]) dat <- dat[seq_len(100), , drop = FALSE] design_in <- design( data = dat, model = DDM, formula = list(v ~ 0 + S, a ~ E, t0 ~ 1, s ~ 1, Z ~ 1, sv ~ 1, SZ ~ 1), constants =...
a33bc5b6d8af5393d423917b56fe0bc9f7b6bb2b55080876d3c985e2d2d0df74
R
761
27
Sys.setenv(RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/MacOS/pandoc") render_report = function(cell_type_name, graph_weight) { file_tag = paste0(cell_type_name, "_BL_", graph_weight) rmarkdown::render( "s2b_check_results.Rmd", params = list(cell_type_name = cell_type_name, graph_weight=graph_we...
c3fa6be889d869405d366df15fb110416bcc86d43cffad2e12329a97b84020d7
R
761
24
# Simple normal likelihood, the first half of the parameters are the means, # the second half the variances. We exp them to ensure positive variances custom_ll <- function(pars, dadm, ...){ idx <- dadm$S == "left" ll_left <- dnorm(dadm$rt[idx], pars[1], exp(pars[3])) ll_right <- dnorm(dadm$rt[!idx], pars[2], exp(...
1dc0ad9e94ee1fb2f9a7501bc0083cdfa321ee56e17a29c5c4a7ef5d3dc62f1d
R
762
26
#' Add random number columns in data frame with specific seed to validate machine learning algorightms #' #' @param #' #' @return #' #' @export #' shapviz_avg <- function(model, train_obj, n = 5) { sv <- shapviz::shapviz(object = model, X_pred = train_obj$matrix) groups <- generage_pca_grouping(train_obj$df, n) ...
a26ddeaf125cb88939b5a72fa2931dd6e3d4831177772910e4d7ad00e335bb0b
R
765
17
test_that("fanc4to3 works", { # https://radagast.hms.harvard.edu/catmaidvnc/?pid=13&zp=117630&yp=470101.3&xp=194569.2&tool=tracingtool&active_skeleton_id=1377198&active_node_id=18180879&sid0=10&s0=-2 # nb xyzmatrix sets column names fanc3=xyzmatrix(cbind(194569.2, 470101.3, 117630)) fanc4=cbind(45224, 109317...
5adaa8e0931627d2d571aa4c7598999409043e2d907ff6f6190adb22aec66c0d
R
769
25
# `trivial` is a dummy MLflow flavor that exists only for unit testing purposes mlflow_save_model.trivial <- function(model, path, model_spec = list(), ...) { if (dir.exists(path)) unlink(path, recursive = TRUE) dir.create(path, recursive = TRUE) path <- normalizePath(path) trivial_conf = list( trivial = ...
e95406554a5e4e2213bd530b56b227da0ef5f5514ca571d99972438c74e982dc
R
780
32
library(dplyr) library(ggpubr) library(rstatix) data <- readxl::read_excel("data/sjTREC_150kcells_21112024.xlsx") %>% mutate(log10age = log10(Age)) # Fig 4c data %>% ggplot(aes(x = SNP, y = sjTREC)) + geom_boxplot(outlier.shape = NA) + geom_jitter(alpha = 0.5) + theme_pubr() + ylab("log10 TREC...
f237a1304c0784fef7d24f3696dbcf9fc44fcff4033d9c9bb7123148ecb7e44c
R
780
28
Sys.setenv(RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/MacOS/pandoc") render_report = function(cell_type_name, graph_weight) { file_tag = paste0(cell_type_name, "_BL_", graph_weight) rmarkdown::render( "s1_evaluate_gene_sets_goseq.Rmd", params = list(cell_type_name = cell_type_name, graph_weight=...
675c21a79d68f7ef15e9df61f1b83ef2d00c47699ebdc5ba78ce2c74c7da5db1
R
781
20
matchfun <- function(d)d$S==d$lR # design an "average and difference" contrast matrix ADmat <- matrix(c(-1/2,1/2),ncol=1,dimnames=list(NULL,"diff")) # specify design design_LBABE <- design(data = forstmann,model=LBA, formula=list(v~1,sv~1,B~E+lR,A~1,t0~1), constants=c(sv=log(1))) pmean...
207ebdac472a71188d076df416e427e047d7a70fc1643aaa34f5b9bed3ac4570
R
782
33
setwd(Sys.getenv("HOME")) source("R_func/mutate_load.R") library(tibble) library(GenomicRanges) # Load peak ages peak.ages <- fread( "project/multiomics/PeakAnlys/PeakAnnot/AgePeak.csv" ) meta.features <- fread( "project/multiomics/PeakAnlys/meta.features.csv" ) all.peaks <- meta.features[, 1, ] %>% unlist %...
aec89271459de068d042fecd0f8fc75acb916f4295ab8e32505ae88973dacb80
R
788
20
# Kirjastot library("plyr") library("XML") library("purrr") # Listaa luettavat tiedostot, 5MIN kestää setwd("/finngen/library-red/EA3_HEART_FAILURE_1.0/data/ecg") files <- list.files(full.names = TRUE,recursive = T) # Poimii halutut tiedot, tässä noden <RestingECGMeasurements> alla parse_xml <- function(FileName){ ...
7dd34d486bc0f04c40d69c95d2bc2ecbc30819808f04741125da935b1abc232d
R
794
28
Sys.setenv(RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/MacOS/pandoc") render_report = function(cell_type_name, graph_weight) { file_tag = paste0(cell_type_name, "_BL_", graph_weight) rmarkdown::render( "s1b_evaluate_gene_sets_cell_types.Rmd", params = list(cell_type_name = cell_type_name, graph...
b8aa35cb042fdbe3e63c9dea55725c5ee741f992b4b3d2e56b06e12e2672a746
R
795
30
test_that("Test PlotStats functions", { 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) ...
4ef63b998f34aa110ef7bc2e1f964ac657158b82611db15ba15701000ece2a95
R
800
28
suppressWarnings({ library(afvaper) library(vcfR) library(data.table) library(ggplot2) library(cowplot) library(tibble) library(stringr) library(tidyr) }) args <- commandArgs(trailingOnly=TRUE) out_full <- args[1] k_val <- args[2] out_subset < paste0(out_full, "_LD50kb") run_t...
fce389719a028349e4f477961f0063a734484450936708a5e3e58dc110484abc
R
800
45
setwd("./BayesCafe-main") source("R/BayesCafe.R") library(anndata) library(scater) set.seed(101) ST <- read_h5ad("./ST.h5ad") out.path <- "./output_BayesCafe.csv" ST$obs_names <- make.unique(ST$obs_names) ST$var_names <- make.unique(ST$var_names) count_ST <- (ST$X) x<- ST$obsm$spatial[,1] y<- ST$obsm$spatial[,2] po...
1e3a53f146c5e37b5a8067ac4add9396bef70f2eb96be4d312c827fe9ba7495a
R
802
25
library("spatialLIBD") library("markdown") ## due to a shinyapps.io bug ## spatialLIBD uses golem options("golem.app.prod" = TRUE) ## You need this to enable shinyapps to install Bioconductor packages options(repos = BiocManager::repositories()) ## Load the data (all paths are relative to this script's location) spe...
20ca339d774b0c0caeb1cc89e67ff2bfb584479b35e7d54715926e2a33dffe78
R
802
16
# This script randomizes the dataset 200 times. It creates a new dataset with the same species and alleles but with randomized phenotypes. dataset <- "Path/to/dataset_file.txt" # Path to the dataset # The dataset (output from script 14.2) contains three columns: 1) Species names, 2) Allele variant, 3) Phenotype state ...
f4e96079b6e3f4f6e014a52194ce1a9238f881aa5847f189e2ebafb59fa42c55
R
803
29
####################################################### # Add ssm2 coverage counts to db # Date: 2023.03.22 # Author: Kevin Johnson ####################################################### # Necessary packages: library(parallel) library(tidyverse) library(DBI) library(odbc) con <- DBI::dbConnect(odbc::odbc(), "Verhaak...
7250ddfd31885346abea814bcc52846c14e09f38a34f548ff6d8688efd0016a1
R
808
35
amos_ns <- 543893 bride_ns <- 543893 long_ns <- 543893 pat_ns <- 543893 quon_ns <- 543893 amos_i <- 20 bride_i <- 30 long_i <- 20 pat_i <- 19 quon_i <- 18 amos_het <- 0.14329768056384 bride_het <- 0.255855625571989 long_het <- 0.156552960008373 pat_het <- 0.187106414828695 quon_het <- 0.17847314076479 for ( lake in c...
6ea5182c11aefc57d736de8acdf9a3144715c7630a070fcfcca881a11305f6ed
R
811
23
RNGkind("L'Ecuyer-CMRG") set.seed(123) dat <- forstmann dat$covariate <- 1:nrow(forstmann) des <- design(data = dat, formula = list(v ~ covariate*E, B ~ E, t0 ~ S), model = LBA) test_that("mapped_pars", { expect_snapshot(mapped_pars(des)) expect_snapshot(mapped_pars(des, p_vector= rnorm(length(samp...
bd53cdd376dd629f209e248535071f946893eb2fe91a35532d485dac50c45d9f
R
816
25
# Function to process a string containing multiple comma-separated entries # and convert it into a cleaned character vector multiple_entries_to_vector <- function(x) { # Ensure input is in character format and handle NULL cases if (is.null(x) || length(x) == 0) { return(character(0)) # Return an empty charact...
3c0c53295e2419489a3c88be18a894a8aa13ea4cce09f461f7e802c7ed9ef49f
R
817
24
context("test-ng-raw-io.R") test_that("read_ng_raw works", { expect_is(chunks <- read_ng_raw('testdata/read_ng_dump/chunk00789.raw'), 'ng_raw_list') expect_is(chunksh <- read_ng_raw('testdata/read_ng_dump/chunk00789.raw', read_data = FALSE), 'ng_raw_list') expect_equal(chunks[[1]]$h, chu...
585414fdf172423ba5cbe0d54a1503cd8a10e0dfee50e8f1099c5290586fbeb3
R
818
21
### Calculate the mol% of each individual lipid setwd(rstudioapi::getActiveProject()) rm(list=ls()) source("./Scripts/Function_scripts/Effect_size_functions.R") source("./Scripts/Function_scripts/Pre-processing_functions.R") library(tidyverse) ##########################################################################...
a8bbe3b04072d6e0ad22172d3e08f5ec0898fc3599a74cf9b04866ded240dfd4
R
820
30
#!/usr/bin/env Rscript ####################################################### library(tidyverse) library(odbc) library(DBI) ####################################################### #Establish connection con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB4") args = commandArgs(trailingOnly=TRUE) # test if there is at l...
a458deddf4a6ed053c01349fddb00df4a0eba1f554c3f441304a294049c21971
R
825
24
here::i_am("scripts/2.validations/2.3.binding_site_enrichment_and_divergence/2.3.8.create_blacklists.R") library(plyranges) library(tidyverse) library(here) input_dir <- here("data/validations/ATAC_seq_peaks_noBL/") output_dir <- here("data/validations/ATAC_seq_blacklists/") dir.create(output_dir) # create custom b...
a145c8e108ccea521bf30bb99da6fee0ca1a216658523812e6181952fe20800d
R
832
16
library(ggplot2) ##### Fig 5H dotplot for GSEA data <- read.csv("Fig 5H LG815_TDI_MG_C5_Reactome_curated.csv") ggplot() + geom_point(data=data, aes(x=as.numeric(p.value.of.overlap), y=reorder(Gene.Set.Name,-log(FDR.q.value)), colour=as.numeric(p.value.of.overlap),size=X..Genes.in.Overlap..k.), ...
9d42adc537808b551d39a426636029f1649b41a968b08ffedd1c1dfcd6f68720
R
833
20
test_that("multiplication works", { skip_if_not_installed('fastmap') v64 <- vcache64('rhubarb-test') expect_silent(vcache_mset(v64, '1', bit64::as.integer64(1L))) expect_error(vcache_mset(v64, '1', 1L), regexp = "class mismatch") expect_equal(vcache_mget(v64, '1'), bit64::as.integer64(1L)) expect_equal(vcac...
531e3c9abf55b420a0a122f3a46b865253982a5ee95cb0f198d89b92841eee22
R
835
27
SumSqU<-function (U, CovS) { if (is.null(dim(CovS))) { Tscore <- sum(U^2/CovS) if (is.na(Tscore) || is.infinite(Tscore) || is.nan(Tscore)) Tscore <- 0 pTg1 <- as.numeric(1 - pchisq(Tscore, 1)) } else { if (all(abs(U) < 1e-20)) pTg1 <- 1 else...
0200a93e3ac068d9dd9f02304d4d4e8ac47a890e17da1d69afc7bd19ddc18f71
R
836
22
### Calculate the mol% of each individual lipid setwd(rstudioapi::getActiveProject()) rm(list=ls()) source("./Scripts/Function_scripts/Effect_size_functions.R") source("./Scripts/Function_scripts/Pre-processing_functions.R") library(tidyverse) ##########################################################################...
9439a46370a844de9cb3da8620cccf00f2bc2a1dcdad65cd8b19fe662923e659
R
837
31
# CBIG_LBC_longComBat_FC_wrapper.R # get env variable LBC_rep_dir <- Sys.getenv("LBC_rep_dir") if (LBC_rep_dir == "") { stop("LBC_rep_dir environment variable not found. Did you source config.sh?") } # Get repo root from environment variable defined in config.sh CBIG_CODE_DIR <- Sys.getenv("CBIG_CODE_DIR") if (CB...
6ae6c7f71e9e950acebcfca6d2c826388221d30c4703d7149f899e35fa446dc1
R
843
31
start_parallel <- function(parallel, cores) { if (parallel && requireNamespace("doParallel", quietly = TRUE) && requireNamespace("parallel", quietly = TRUE)) { if (Sys.info()["sysname"] == "Windows"){ cluster <- parallel::makeCluster(cores) doParallel::registerDoParallel(cluster) } els...
4d0460cbe2e05b0bcb9c342c7777d8524086b6c685e739a3a4fc8e7615010494
R
845
31
# run_longComBat_cog.R # get env variable LBC_rep_dir <- Sys.getenv("LBC_rep_dir") if (LBC_rep_dir == "") { stop("LBC_rep_dir environment variable not found. Did you source config.sh?") } # Get repo root from environment variable defined in config.sh CBIG_CODE_DIR <- Sys.getenv("CBIG_CODE_DIR") if (CBIG_CODE_DIR ...
2b7ed4c16772de9d7a52b0001ded834eee33fd21cedf55c30716d7e7c72a5c7b
R
847
29
old_root="C:/Users/Jun/Documents/R/AA_behavior/" #you will need to change this new_root="C:/Users/Jun/Documents/R/" #you will need to change this next_experimentName= "PL_pPVT_opto" #you will need to change this ############################################################### newdir=paste(new_root,next_exper...
492a4628fbfd713d9bab521cb847e8a2b075dac48724534e1f935172bdfe3184
R
847
40
#' @importFrom utils browseURL mlflow_view_url <- function(url) { getOption("page_viewer", browseURL)(url) invisible(url) } #' Run MLflow User Interface #' #' Launches the MLflow user interface. #' #' @examples #' \dontrun{ #' library(mlflow) #' #' # launch mlflow ui locally #' mlflow_ui() #' #' # launch mlflow u...
a1085cc8167d06b2a6e511047d34a39a8ee4722126fe48a933f5be8c234c60a6
R
853
36
dup <- function (x) x[duplicated(x)] luniq <- function (x) length(unique(x)) is.0 <- function(x) x == 0 ## add prime 3s and prime 5s based on start, end and strand add.primes <- function(df) { df$prime5[df$strand == '+' & !is.na(df$strand)] <- df$start[df$strand == '+' & !is.na(df$strand) ] df$prime3[d...
a46acfb7d9671ef68db0dcbdf27ed88d93c2f38b477f6156515a1c88da7df1cf
R
858
22
## push blocklist to db library(tidyverse) library(DBI) library(odbc) con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB") tmp = read.delim("data/ref/block_review_allow_quality_lists_20181206.txt", as.is = TRUE) df <- tmp %>% select(aliquot_barcode, fingerprint_exclusion, coverage_exclusion = coverag...
7c34fb7e2ebcb6db7a42a2678108761e37795a1f51ec07f6311821ea82464427
R
860
32
library(SingleCellExperiment) library(ggplot2) library(BayesSpace) library(anndata) library(scran) options(matrixStats.useNames.NA ="deprecated" ) set.seed(101) ST <- read_h5ad("ST.h5ad") q <- length(unique(ST$obs$ground_truth)) x <- ST$obs$array_row y <- ST$obs$array_col location <- data.frame('row' = x , 'col' = y)...
919780604f920f315cefe507064f26f27dd3a950bdde25cecb3b7c3d6ae0c33f
R
860
24
## Calculate the Z-score for each measure setwd('/home/huyang/Projects/HuYang/HY_20250708') atlas_names <- c('Schaefer300', 'DK308') for (curr_atlas in atlas_names){ meas_names <- c('Morph_5F4S', 'Morph_5F1S', 'Morph_9F1S') for (curr_meas in meas_names){ ## Load raw data in_fname <- paste('./PROCDATA/STATS/...
1a5fdd3a75fa7e8c6e071e4088cf3e327d15758e10819c5fa4285a736e18e15e
R
861
28
library(tidyverse) library(DBI) #.libPaths("/home/barthf/R/x86_64-pc-linux-gnu-library/3.3") #dyn.load("/projects/verhaak-lab/verhaak_env/anaconda/v4.2.0/envs/rvenv2018/lib/libodbc.so") ## database connection con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB4") ## input/output parameters barcode <- snakemake@wildcards...