sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
68e83ae529d7045dd55db180059f142b8741e5a5d9c66e21d371ba1eacd9453b
R
1,380
39
rm(list=ls(all=T)) library(mvnfast) source('simulations/mugent_ph/functions.R') ################################################################################ niter=1000 ms=c(50,100,150) ps=c(2,5,7) rhos=c(0.9,0.1) RES=array(dim=c(length(ms),length(ps),length(rhos))) par(mfrow=c(6,3),mar=rep(1.5,4)) for(i in 1:length...
8e40bce71109dc63264d98eb86bdedec9026eafdd8a354c1598ee2e431399acd
R
1,380
77
--- title: "Nebulosa MSL1" author: "AF" date: "`r Sys.Date()`" output: html_document --- ```{r} library(Signac) library(Seurat) library(tidyr) library(dplyr) library(ggplot2) library(rstudioapi) library(Nebulosa) set.seed(17) ``` Nebulosa Density plot for Msl1 expression. ```{r} seu_Embryo <- readRDS(file = "path...
ccc5087aafede690f4cbbc99e908afdfc321452386b99c922b3de2df543fc3b2
R
1,388
24
####################################### # # This function is used to obtain the # network identification of Schafer 400 ObtainNetID <- function(id_path, anno_path){ net_id <- readr::read_csv(id_path, col_names = 'network_ind') net_parcel <- readr::read_csv(anno_path, col_names = 'region') net_ana <- cbind(n...
c668e80a43c740bb34e1b337360a2bc735669169f88dec0389e1d49c8e969489
R
1,392
64
# load example HT data ---- data_ht_file <- system.file("tests", "testthat", "data", "example_HT_data.rds", package = "OlinkAnalyze", mustWork = TRUE) data_ht <- readRDS(data_ht_file) rm(data_ht_file) # keep a few of the rows from the dataset ---- ## select bri...
05923af420195800b332d8099f1041cbc81d4f25330f7d66e34070b54c874b4a
R
1,393
35
bd_tas <- replicate(3000, ape::rlineage(birth = 0.6, death = 0.1, Tmax = 10), simplify = FALSE) bd_tas_list <- list(tas = bd_tas) dists_bd <- list( list(distribution = "uniform", n = 1, min = 0.6, max = 0.6), list(distribution = "uniform", n = 1, min = 0.1, max = 0.1) ) ddd_list <- list() j <- 1 for (i in seq(from...
b965882fd5269d57d1d2ac1a4265ae740cde6221fd863c964b6095bccf565ae5
R
1,395
64
# load example 3k data ---- data_3k_file <- system.file("tests", "testthat", "data", "example_3k_data.rds", package = "OlinkAnalyze", mustWork = TRUE) data_3k <- readRDS(data_3k_file) rm(data_3k_file) # keep a few of the rows from the dataset ---- ## select bri...
85532b84ad62482613ca8477da35998f6637c92010cce5aaf9ea13ab4bbf95af
R
1,397
49
#' Generate example data #' #' @return a dataframe containing cell-level information for sample, group and #' clusters #' #' @export #' #' @examples #' #' speckle_example_data() #' speckle_example_data <- function(){ # Make up some data with two groups, two biological replicates in each # group and three cell t...
cb37d2a0e6c02fd2fca3f2cae2f627a8aa605f0868aeca942c9c4ea11f1c361c
R
1,397
38
################################################################################ # The position of a gene within the genome. # # When linking to the UCSC Genome Browser for a gene the position of the gene # must be passed in the URL including the chromosome, beginning location, and # ending location. # # The location i...
6cb0f27060fa6e5885ecaae220c2af2897bb4f90fb12136e96c20ef2700a0311
R
1,399
44
#' Functional wrapper to get the output of the wonderful iNext library in the format I use to pipe into ggplot2. #' @export get_asymptotic_alpha = function(species, verbose = TRUE){ if(any(colSums(species) < 1)){ if(verbose){print("reads seem to be relative abundance. This is not ideal. Applying transformation t...
8d881987c8c97a0a4ebf883bbbba104550d66896e1b69e49a95a57d9447b690c
R
1,401
41
args <- commandArgs(TRUE) name <- as.character(args[1]) data_path <- file.path(name, "EMP_DATA") export_path <- file.path(name, "EMP_DATA", "EXPORT") if (!dir.exists(data_path)) { stop("Empirical data path does not exist") } if (!dir.exists(export_path)) { dir.create(export_path, recursive = TRUE) } ### Condam...
771418470f0b8653922c8a10fbda3827c11168894039a83bc453e1ae2ce05523
R
1,405
65
test_that("Gamma regression reacts on 'weight'", { n <- 100L set.seed(87L) X <- matrix(runif(2L * n), ncol = 2L) y <- X[, 1L] + X[, 2L] + runif(n) X_pred <- X[1L:5L, ] params <- list(objective = "gamma", num_threads = .LGB_MAX_THREADS) # Unweighted dtrain <- lgb.Dataset(X, label = y) bst <- lgb.trai...
288fe87201fbd53293d2f1b2eb6a7db99291a085e81fd9509617c1d2643cb7bf
R
1,409
47
test_that("lgb.plot.importance() should run without error for well-formed inputs", { data(agaricus.train, package = "lightgbm") train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) params <- list( objective = "binary" , learning_rate = 0.01 , num_leaves ...
1332669c619d27b852f89ed63ed9548486251b5b57a32f348fb8292a67699de6
R
1,415
39
# In this script we will be gathering pathology diagnosis # and pathology free text diagnosis terms to select pineoblastoma (PB) # samples for following PB subtyping analysis and save # the json file in PB-subset folder library(tidyverse) ## Directories root_dir <- rprojroot::find_root(rprojroot::has_dir(".git")) ...
bdca09aae0dba033a10d0c736a070b039a0133a54058b9e83561c648cfda39e1
R
1,416
57
devtools::build_vignettes() devtools::document() devtools::test() devtools::check() devtools::build() devtools::install() devtools::load_all() # Minimal test run # devtools::load_all() # load necessary objects snps <- fread('./data/hd_1kG_hg19.snppos.filtered.test.gz') cnvs <- fread('./data/cnvs.txt') cnvs[, prob...
dd88920c09c57d04b16e31a5eb490ac98d20fd07e3a068b7b41c330a3f5459de
R
1,416
30
if (!require(BiocManager)) install.packages('BiocManager', repos='https://www.stats.bris.ac.uk/R/') if (!require(DirichletMultinomial)) BiocManager::install("DirichletMultinomial") if (!require(Biobase)) BiocManager::install("Biobase") if (!require(optparse)) install.packages('optparse', repos='https://www.stats.bri...
73a1b51986a7f5fd7d6770c29fae5df76b95d3cc8f4e991ce706eedca1f0033a
R
1,426
40
getTree <- function(rfobj, k=1, labelVar=FALSE) { if (is.null(rfobj$forest)) { stop("No forest component in ", deparse(substitute(rfobj))) } if (k > rfobj$ntree) { stop("There are fewer than ", k, "trees in the forest") } if (rfobj$type == "regression") { tree <- cbind(rfobj$forest$leftDaughter[...
15e582f09133f1c9edd86b0252bbb908aeeffc2392799cc91b8b13c111998ac1
R
1,436
30
options("scipen"=999) library(data.table) args <- commandArgs(trailingOnly=TRUE) INDIR = args[1] SET = args[2] FDR = args[3] RESOLUTION = as.numeric(args[4]) #peaks_raw = read.table(args[1], header=T) #peaks_raw = read.table('../results/mESC/MY_113.MY_115.5k.2.peaks',header=T, stringsAsFactors=F) inf = paste(INDIR,...
01561cdef47d801f10fba99f60c555a32dd30527607e9f4beacd6da6a8dc233b
R
1,438
54
##-------------------------------------## ##### SETUP OPTIONS ##### ##-------------------------------------## options(timeout = max(1000, getOption("timeout"))) options(download.file.method.GEOquery = "auto") options(warn = -1) set.seed(08071993) options(shiny.maxRequestSize=900000*1024^2) option...
9bb978f563bf7113f50b381b2a1711336d14f5d840abef5623772cd318c9da35
R
1,438
59
# Load necessary libraries library(dplyr) library(ggplot2) library(car) library(nlme) library(lme4) library(lmerTest) library(readxl) library(rstudioapi) library(reshape2) library(tidyverse) library(tidyr) library(sjPlot) #Set working directory to local directory setwd(dirname(getActiveDocumentContext...
0d9680133d8016402847738e07f1fafb6b9a19821df42485764e1974f8f19ceb
R
1,439
40
# Function to return points and geom_smooth PointAndSmooth <- function(data, mapping, method = "loess", ...){ p <- ggplot(data = data, mapping = mapping) + geom_point() + geom_smooth(method = method, ...) p } # Functions to aggregate mixed columns # https://stackoverflow.com/questions/...
f22a05befb1936ccf5b271fbe424121228ea104948f13f25644640d7be821d3a
R
1,440
38
#' Plot LRR/BAF for a given CNV #' #' This function is mostly needed for developing to check how CNVs looks like #' "normally" and compare with the PNG form. #' #' @param cnv see load_snps_tbx() documentation #' @param samp see load_snps_tbx() documentation #' @param snps see load_snps_tbx() documentation #' @param in_...
3f03bf7603619a6fba1143018cb9a59d8f6dbfdd2911ca202f7ce56cc9647e78
R
1,442
49
##-------------------------------------## ## BARPLOTS ## ##-------------------------------------## get_summary_barplot <- function(var1, var2, colors, label){ var1 <- str_sub(var1, 1, 15) var1_terms <- unique(var1) var2_terms <- unique(var2) var1_size <- length(var1_terms) va...
1069947d714d33ef9a8857e2453d33391b909029128bce8c8f72664c2d35dbec
R
1,447
38
library(ggplot2) library(data.table) library(cowplot) source("../Plot_theme.R") # Load color scheme colors <- fread("../Plotting/colors.csv", strip.white = F) color_v <- colors$Color names(color_v) <- toupper(names(color_v)) # Load TMS differential expression overlap data c <- read.csv("comp_TMS/diff_exp_loc=all.csv"...
68d8d1cd423455890d833d409440a385bd217de2280128c1fabad713dc162696
R
1,447
45
################################################################################ # Create an image of a splice junction usage plot. # # In order to stay inside the shinyapps.io memory limit this function reads the # data file, creates the plot as an image, and cleans everything up so that a # minimal amount of memory i...
3ab7bde55cf867a22032ddfb09a6798a987aeb2dff3fbc259928cee0319502ea
R
1,457
39
setwd("/media/user/disk21/completeAnalysis/figure3_2025/") obj = readRDS('../visium_15Sept/visiumObj_20Sept.rds') meta = read.csv("../visium_2Jun/meta_12Mar2025.csv", row.names = 1) identical(rownames(meta), rownames(obj@meta.data)) obj@active.ident = factor(meta$AF_ivy, levels = c('LE_GM', 'LE_WGM', 'LE_WM', 'CT_co...
5e72c3d3d245ff7f9fdaab5aac0b795cdcc95a7969e62b1d6fe77297082674a2
R
1,463
36
library(optparse) library(dplyr) option_list <- list( make_option(c("-d", "--datapath"), type='character', action='store', default='./', help="Path to where the CSV output files are stored"), make_option(c("-f", "--filename"), type='character', action='store', default='cell_filter_info.csv', ...
d1061b00ef107dee22514e48cd6cd8e20f6497557bc957442ae076b5fce7e4fd
R
1,463
39
Cross_Validation <- function(LabelsPath, col_Index = 1,OutputDir){ " Cross_Validation Function returns train and test indices for 5 folds stratified across unique cell populations, also filter out cell populations with less than 10 cells. It return a 'CV_folds.RData' file which then used as input to clas...
4a8ddb2f3e8728bae18cb4c2779373989d29735f33a93c70bd1822a6bc50abac
R
1,464
42
library(pROC) data(aSAH) context("ci.sp") # Only test whether ci.sp runs and returns without error. # Uses a very small number of iterations for speed # Doesn't test whether the results are correct. for (stratified in c(TRUE, FALSE)) { for (test.roc in list(r.s100b, smooth(r.s100b))) { test_that("ci.sp with de...
18f1333b3a010e7cf97d1813a10145c146fd8dfac14a70708e85fba678ba1f6d
R
1,465
60
context("Testing PCA checking") n <- 500 p <- 1000 ndim <- 50 nextra <- 100 tol <- 1e-3 data(hm3.chr1) bedf <- gsub("\\.bed", "", system.file("extdata", "data_chr1.bed", package="flashpcaR")) test_that("Testing PCA with stand='binom'", { S <- scale2(hm3.chr1$bed, type="1") f2 <- flashpca(S, ndim=ndim, sta...
97749a921394a864fda92f9d545508180266c1a874103788980b52b7aaa63776
R
1,465
43
library(pROC) data(aSAH) context("ci.se") # Only test whether ci.se runs and returns without error. # Uses a very small number of iterations for speed # Doesn't test whether the results are correct. for (stratified in c(TRUE, FALSE)) { for (test.roc in list(r.s100b, smooth(r.s100b))) { test_that("ci.se with d...
b2ad82473e877a15e65ee9aae205035429ee15ce56bff5201054b546a81b8ae9
R
1,478
38
library(tidyverse) library(optparse) library(Biostrings) arguments <- parse_args(OptionParser(), positional_arguments = 1) gencode_fasta_file<-arguments$args[1] # base_dir<-"/home/jbrenton/nextflow_test" # gencode_fasta_file<-file.path(base_dir, # "/output/reference_downloads/gencode.v38.transcripts.fa") # # gencode_...
50ff7d8744e383c9f5fa370ba66070d5a87bb9aea1ee819390a9e1a6fa3c1e76
R
1,479
32
#GenomicSEM #Munges sumstats munge(c("/path/to/MDD.txt", "/path/to/ADHD.txt", "/path/to/BPD.txt"),hm3 = "/path/to/w_hm3.snplist", trait.names = c("MDD", "ADHD", "BPD"), info.filter = 0.9, maf.filter = 0.01) #Running multivariate LDSC traits <- c("/path/to/MDD.sumstats.gz", "/path/to/ADHD.sumstats.gz", "/path/to/BPD...
d732b023fb11b8e2d1e95eca8da5c3a42263ad4d053846fd99fe4a0445acda69
R
1,481
40
# The working directory is the directory that contains this test R file, if this # file is executed by test_dir # # testthat package is loaded, if this file is executed by test_dir context("tests/test_collapse_rp_lists.R") # import_function is defined in tests/helper_import_function.R and tested in # annotator/tests/te...
d4e418596918e2c92854ebde13b3a4f35f2c67ddd742d0423a7c4f047ee651fc
R
1,482
42
test_that("get_plateform detects EPIC correctly", { # Create a matrix with EPIC number of probes mat_epic <- matrix(0, nrow = 866553, ncol = 5) result <- get_plateform(mat_epic) expect_equal(result, "IlluminaHumanMethylationEPIC") }) test_that("get_plateform detects 450k correctly", { # Create a matrix with ...
a4c31b4aa16abb029156fad2a6979f53a400316e719f226a976976ce4035e179
R
1,484
49
# Get the project directory project_dir <- getwd() lockfile_path <- file.path(project_dir, "renv.lock") cat("Checking for renv.lock in:", lockfile_path, "\n") # Check if renv.lock exists if (!file.exists(lockfile_path)) { stop("Error: renv.lock file not found. Please provide a valid renv.lock to proceed.\n") } # I...
3b84c57c720e818bc6ae69d1e2348a1786eaee594fb65beb61e22ab23751850a
R
1,486
51
#' Exposure #' #' Subset of the original dataset containing the estimated effect of SNPs on the exposure #' #' @format A data frame with 750,000 rows and 13 variables: #' \describe{ #' \item{chr}{chromosome} #' \item{rsid}{rsid of the SNP} #' \item{pos}{position} #' \item{ref}{reference allele for the SNP} #' ...
a04227ec15f0e12a6b8ae255eea506824656698da41d5a6e79b7b8503e1428d2
R
1,487
38
library(org.Hs.eg.db) library(AnnotationDbi) library(tidyverse) library(biomaRt) library(GO.db) setwd("/Users/melis/Documents/GitHub/MRIxST/code") dirs <- list.files(path = "../raw_data/keyword_search_amiGO/.", pattern = "\\.csv$") for (i in 1:6) { # Read in amiGO pathways based on searched keywords data = read.cs...
313d1bdefef06f41f070c79ede9cfdf563d284950a86dd8fdfff8f4a7c90d348
R
1,489
46
#' @title Get parcel disconnection measures/maps #' @description This is a wrapper function that calls a series of functions to create various parcel disconnection measures. #' It wraps the 'get_parcel_atlas', 'get_atlas_sspl', 'get_parcel_discon', and 'get_patient_sspl' functions. #' @param cfg a pre-made cfg structur...
42ae71b32f6a30c5243914e21aca772a398b149ce10a1ea198b6419b8965c95a
R
1,489
47
test_that("cpg_na_excl identifies probes with many NAs", { # Create a test matrix with some NAs betas <- matrix(runif(100), nrow = 20, ncol = 5) rownames(betas) <- paste0("cg", sprintf("%07d", 1:20)) # Add NAs to first row (30% NAs) betas[1, 1:2] <- NA # Add NAs to second row (40% NAs) betas[2, 1:2]...
3f0287b075941a1a00cab6d6a8af8c5e506b8c9a7af4eec2dcd2207ea48bb0c7
R
1,499
35
# desc.tab = function(groups, outcome.var, df) { # factors.dat = df %>% select(where(is.factor)) %>% names() # df %>% tidyr::drop_na(groups) # df %>% dplyr::mutate(across(paste0(factors.dat), ~paste(as.numeric(.), .))) %>% # tidyr::pivot_longer(groups, # names_to = "key", # ...
f997adf5e320888dae2a21b65b09d8e45b59e4d549acd3bf8ec2956df3c1dd1b
R
1,501
38
rm(list=ls(all=TRUE)) library(mvnfast) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ar1=function(n,rho) rho^toeplitz(0:(n-1)) atransform=function(Q,null_mean,null_variance) { # function to transform gene-based test statistics to an asymptotically normal distribution ...
fbec83ab7aadf6ec65f65fe344a724f5be52038cd8087bd23a164bef75fb317e
R
1,502
60
calculate_spot_dist <- function(n2, sigma_n, euc_dist2) { # calculate spot distance based on gaussian kernal regulated euclidean distance # n1, n2 is indicies, sigma_n is a vector of N and euc_distance is a matrix of N x N. # will return a vector of N, which is P_n_n2 tmp = -euc_dist2[,n2]/2/sigma_n[n2...
7bd482398426888e97bf584bc10d5a0bf0f1114b0044aff48552f92af976bd40
R
1,504
38
# [description] List of metrics known to LightGBM. The most up to date list can be found # at https://lightgbm.readthedocs.io/en/latest/Parameters.html#metric-parameters # # [return] A named logical vector, where each key is a metric name and each value is a boolean. # TRUE if higher values of th...
8c207479bdbd11a2acc6506262b32ebe78aadcaac7ea5aa8483d00909d6c5c39
R
1,508
43
# 2. Copathologies # Analysis of associations between clinical characteristics and co-pathologies # Project: Clinical features, genetics, and pathology in a large series of movement disorder cases: a retrospective multi-ancestry brain bank cohort study # Last updated in November 2025 # Syntax for generating PCs via P...
831610efc35082ac311dbabe094b0a6e6f12d71455dce768c772f6716eee0a13
R
1,509
44
##-------------------------------------## ## QC TAB ## ##-------------------------------------## tab_QC_BARPLOTS <- tabItem( tabName = "Quality Control", tabPanel("BARPLOTS", sidebarLayout( sidebarPanel(width = 2, selectInput(inputId = "summary_var", ...
0ac6686321b978e332839e57099dd31c23f68878c64319bcdf99a7451343fa09
R
1,510
33
# Theme for all plots theme_Publication <- function(base_size=15, base_family="Helvetica") { library(grid) library(ggthemes) (theme_foundation(base_size=base_size, base_family=base_family) + theme(plot.title = element_text(face = "bold", size = rel(1.2), hjust = 0.5), ...
cb94a6cfbc200e9e2f0155032796aec0009818e795057eb7c1c9b5681e1be0f6
R
1,515
50
#'--- #' title: Get MAE results #' author: vyepez, mumichae #' wb: #' log: #' - snakemake: '`sm str(tmp_dir / "MAE" / "deseq" / "{vcf}--{rna}.Rds")`' #' input: #' - mae_counts: '`sm cfg.getProcessedDataDir() + "/mae/allelic_counts/{vcf}--{rna}.csv.gz" `' #' output: #' - mae_res: '`sm cfg.getProcessedResultsDir...
d0d26b6d0ec0e35ee155e0ba2554bfcbe8606e58ad01ddf1aca24e4626316685
R
1,519
42
#!/usr/bin/env Rscript require(dplyr) require(data.table) args=commandArgs(trailingOnly = T) if (length(args)<2) { stop("Usage is: ./gtf_to_exons.R input.gtf.gz output.txt.gz") } cat("Reading in ",args[1],"\n") gtf=fread(cmd=paste("zcat <", args[1]), data.table = F, col.names=c("chr","source","feature","start","e...
b9858d47e4a26d6c9381c4b119030992b9df13433ccd197cd986b7ffac751ba1
R
1,528
45
# Test funcs. in reduction.R library(SummarizedExperiment) library(SingleCellExperiment) library(SpatialExperiment) data(rings) spe <- rings spe <- computeBanksy(spe, assay_name = "counts", compute_agf = TRUE) test_that("runBanksyPCA gives message when seeded", { expect_message(runBanksyPCA(spe, use_agf = TRUE, ...
1fd29e50fc1a663ed307f781cd79d12e088ee71bcf9e3948756cd94f7a3f559d
R
1,533
24
data(aSAH) r.wfns <- roc(aSAH$outcome, aSAH$wfns, quiet = TRUE) r.ndka <- roc(aSAH$outcome, aSAH$ndka, quiet = TRUE) r.s100b <- roc(aSAH$outcome, aSAH$s100b, quiet = TRUE) r.wfns.percent <- roc(aSAH$outcome, aSAH$wfns, percent = TRUE, quiet = TRUE) r.ndka.percent <- roc(aSAH$outcome, aSAH$ndka, percent = TRUE, quiet ...
b9e624560382dae53d7fbeb22acc2f336f58ac446a0519e65bb2180b3c916d38
R
1,536
36
#' @title Compute the structural shortest path length (SSPL) for the SC atlas #' @description This function uses the atlas SC matrix to compute an atlas SSPL matrix #' containing SSPLs between each pair of brain regions. It assumes that you have already #' run get_parcel_atlas to obtain the atlas SC matrix. #' @param c...
a7e75ab156d8d78a09025e933180edb38cec16b73f0d9e40f470be94c04c29e0
R
1,540
35
# R. Jin 2021 # Filter expression matrix containing all specimens to only normal specimens of specific type suppressPackageStartupMessages(library("optparse")) suppressPackageStartupMessages(library("tidyverse")) option_list <- list( make_option(c("-e","--expressionMatrix"),type="character", help="ex...
810716c24d548fa2d5ed82af2e67c1616e08fa84259cddce85666d14acc45f26
R
1,541
40
# The working directory is the directory that contains this test R file, if this # file is executed by test_dir # # testthat package is loaded, if this file is executed by test_dir context("tests/test_num_to_pct_chr.R") # import_function is defined in tests/helper_import_function.R and tested in # annotator/tests/test_...
aed5c4a9b7274ed88240ca2db270dcec2a4b86aa2a1c0742a2309b2198ba89f2
R
1,543
32
# Shared fixtures for the create_mofa / mofa2 tests. # testthat sources helper-*.R automatically before running the tests. # Build the miniACC-derived MultiAssayExperiment used by several tests. # Selects four experiments, makes feature names unique per experiment (so the # duplicated-feature renaming does not kick in...
41398770fc89e7d3cff5101a290bc4aa0a32ba18b45998a53d7f3c02a8a68b14
R
1,545
34
library(ComplexHeatmap) library(stringr) library(ggplot2) library(data.table) source("../Plot_theme.R") # Load color scheme colors <- fread("../Plotting/colors.csv", strip.white = F) color_v <- colors$Color names(color_v) <- colors$ID # Load DEG data dereg <- read.csv("results_LAR/deregulated_miRNA/degs_all_formated_...
2ca00700f366e168ada692c98337abb963d7ba48f2e849092f4095fff67472a1
R
1,546
47
margin <- function(x, ...) { UseMethod("margin") } margin.randomForest <- function(x, ...) { if (x$type == "regression") { stop("margin not defined for regression Random Forests") } if( is.null(x$votes) ) { stop("margin is only defined if votes are present") } margin(x$votes, x$...
c2ecf1654a075511f520c479e7c5ae99c45ea7894345a5969f431e65b19adaf9
R
1,546
42
args <- commandArgs(TRUE) Cross_Validation <- function(LabelsPath, col_Index = 1, OutputDir){ " Cross_Validation Function returns train and test indices for 5 folds stratified across unique cell populations, also filter out cell populations with less than 10 cells. It return a 'CV_folds.RData' file wh...
19d81730c0b9411b149bf6dbea27aa2c8f59571c5ccab2ddeb71fdef932c65e0
R
1,550
61
# Model prep: split, preprocessing, CV ------------------------------------ # Train / test split ------------------------------------------------------ set.seed(42) df_split <- initial_split( df_select, prop = 0.80, # matching age distributions across train and test set strata = "scan_age" ) df_train <- trai...
39426d34c5eda6aa9f011c7112aebde904f19c68972d910b0308579eee4557ff
R
1,550
76
#!/usr/bin/env Rscript # Number of CPUs processes # to use for parallelizing # the install of N packages use_ncpus <- max(parallel::detectCores() - 2, 2) # CRAN packages, # add any missing/required # CRAN packages to the list # directly below. This script # will install them if they # are not already installed. # Ins...
98fff2b530d412cdcc0c33cd0d0af9f7ac97abe2dd156017c106ce73584fb705
R
1,550
49
library(optparse) library(tidyverse) arguments <- parse_args(OptionParser(), positional_arguments = 3) count_file<-arguments$args[1] metadata_cols_path<-arguments$args[2] out_dir<-arguments$args[3] # leafcutter_dir<-"/home/jbrenton/nextflow_pd/output/leafcutter/intron_clustering" # sample_names <- data.table::frea...
f330d4e9bb8abe2620d1588809999298400173aa439d9447e040fafd82d0eedb
R
1,555
41
# Function to calculate CDF of the sum of two distributions at various indices calc_cdf_sum <- function(v_idx, d_time_1, d_time_2) { # Calculate predicted CDF at indices p_pred <- sapply(v_idx, function(t) { # Calculates sum of the two distributions integrate(function(u) query_distr("p", t - u, d_time...
0be38be7b89eb2bbc4127c37368e95b9aac9e0f753f140f06fe9b8e43ce9a338
R
1,559
47
#'--- #' title: Initialize Counting #' author: Luise Schuller #' wb: #' log: #' - snakemake: '`sm str(tmp_dir / "AS" / "{dataset}" / "01_0_init.Rds")`' #' params: #' - setup: '`sm cfg.AS.getWorkdir() + "/config.R"`' #' - workingDir: '`sm cfg.getProcessedDataDir() + "/aberrant_splicing/datasets/"`' #' input: #...
ff876d6e63e3c63bedec7da9888c013265c71c377cacd673f05119d5edbb23be
R
1,569
48
suppressPackageStartupMessages({ library(ggplot2) library(ggpubr) library(EDASeq) }) # create boxplot box_plots <- function(object, isLog = F, title = "", facet_var, color_var){ if(ncol(EDASeq::counts(object)) <= 1){ stop("At least two samples needed for the PCA plot.") } else { if(all(is.na(EDASeq:...
ddb27c11777acb0c19ef402a65b4d28810d2583d822e1634a6ee8d9ad24a60e0
R
1,570
50
test_that("format_sample_sheet handles basic input correctly", { # Create a simple sample sheet ss <- data.frame( SampleID = c("Sample1", "Sample2", "Sample3"), Barcode = c("203021070069_R03C01", "203021070069_R04C01", "203021070069_R05C01"), Group = c("Control", "Case", "Control"), stringsAsFactors...
5aecfe9d2893ada9e3c2aa22c7eb46825f7e0664a7fdfdcbefa3d2362c53a038
R
1,575
41
"print.randomForest" <- function(x, ...) { cat("\nCall:\n", deparse(x$call), "\n") cat(" Type of random forest: ", x$type, "\n", sep="") cat(" Number of trees: ", x$ntree, "\n",sep="") cat("No. of variables tried at each split: ", x$mtry, "\n\n", sep="") if(x$type == "classif...
cc569d0a0a6f520ae7c6f8bc9937abe4640c211a8cb8e0b666e3747d68fb5b77
R
1,581
32
#'Adjust p-values using resampling #'@description Wrapper around `p.adjust`, for simple use will do the same. #'@param p numeric vector of p-values #'@param method correction method, a character string. Can be abbreviated. see `p.adjust.methods` #'@param n.samples Integer. How many times should p-values be resampled #'...
36a4cac278c0a9cf4f4d8ccc5cc052b7d3f48ab3d29da4789214ac1ec130a159
R
1,582
56
# True cell type proportions for 4 samples p_s1 <- c(0.5,0.3,0.2) p_s2 <- c(0.6,0.3,0.1) p_s3 <- c(0.3,0.4,0.3) p_s4 <- c(0.4,0.3,0.3) p_s5 <- c(0.8,0.1,0.1) p_s6 <- c(0.75,0.2,0.05) # Total numbers of cells per sample numcells <- c(1000,1500,900,1200,1000,800) # Generate cell-level vector for sample info biorep <- r...
7d96f11168c3dce4519f7c30fa60f56ee164f6e28cbe37e527561a33aaca7a40
R
1,582
41
# File: `scripts/combine_moka_results.R` combine_skat_results <- function(genotype_prefix, weights_type, result_folder) { if (weights_type == "" || is.na(weights_type)) { output_file <- paste0(genotype_prefix, "_combined_association.tsv") file_pattern <- file.path(result_folder, paste0("*", genotype_prefix, "...
dd182135e6f11558bc6f6753d857660d28710c2d4b305a51528306e0f35641e1
R
1,582
43
geom_polygon_auc <- function(data, ...) { UseMethod("geom_polygon_auc") } geom_polygon_auc.auc <- function(data, legacy.axes = FALSE, ...) { # Get the roc data with coords roc <- attr(data, "roc") roc$auc <- data df <- get.coords.for.ggplot(roc, ignore.partial.auc = FALSE) # Add bottom-right point parti...
61a134f969d0e9c13b35390e8355b793da8ac760f9d1e1aa983c19eea139dba6
R
1,585
83
#' Help function checking if a variable is a vector of integers. #' #' @inherit .check_params params author return #' #' @keywords internal #' @noRd #' check_is_integer <- function(x, error = FALSE) { # check if input error is boolean vector of length 1 check_is_scalar_boolean(x = erro...
d8087150e0f653074bd8bee1b3de70662c3b32a0e33b2a1bdf9a767a82eb5ba1
R
1,586
63
#' @export top_percent<-function(inputDF, landmark_col, cols_to_cluster, cutoff){ if(missing(cutoff)){ cutoff=25 } inputDF<-NoNA.df(inputDF) invisible(utils::capture.output(inputDF[,landmark_col]<-as.character(inputDF[,landmark_col]))) a=2 b=1 output<-inputDF rownames(output)<-NULL output$...
fb9b246c0fe7bc08bde63a769ac710f6e49b6b0332269c0dc05cadef2b026278
R
1,587
44
importance <- function(x, ...) UseMethod("importance") importance.default <- function(x, ...) stop("No method implemented for this class of object") importance.randomForest <- function(x, type=NULL, class=NULL, scale=TRUE, ...) { if (!inherits(x, "randomForest")) s...
b188cf63f21f0d5637c96ec16dbb7c0cff3327299890f1a6d84ed3a77b7e2803
R
1,588
70
--- title: "UpSet Plot of MSLc Primed Genes" author: "AF" date: "`r Sys.Date()`" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r} library(UpSetR) library(dplyr) library(rstudioapi) ``` ```{r} MSLc_primed_Neuron <- as.data.frame(read.table("../processed_data/genes_...
9bf2c415829ffe0ec8233bb3292e50dd5fad811f213f57d2fcea7d6e5b9ac144
R
1,600
48
cohens.d <- function (vec1, vec0, na.rm = FALSE) { (mean(vec1, na.rm = na.rm) - mean(vec0, na.rm = na.rm)) / sqrt((var(vec1, na.rm = na.rm)+var(vec0, na.rm = na.rm))/2) } cohens.d.2 <- function (mean1, sd1, mean0, sd0) { (mean1 - mean0) / sqrt((sd1^2+sd0^2)/2) } softmax <- function (vec) { denom <- sum(exp(vec)...
b4b7a5c12e0982049ada6e115fed75bef40d439a08a307d5dbc45bba5dc78a6c
R
1,602
66
# Scripts to create MALAT1 ensembl ID gene list library(dplyr) library(AnnotationHub) Create_Ensembl_MALAT1_List <- function( ) { refreshHub(hubClass="AnnotationHub") species_list <- c("Mus musculus", "Homo sapiens") malat_symbol <- c("Malat1", "MALAT1") ah <- AnnotationHub() malat_list <- lapply(1:len...
cb93cf10c181df99352bb8a2e3ad04ae9241fba3c4881bbc4170a773b80a15fc
R
1,606
83
#' Help function checking if a variable is a vector of characters. #' #' @inherit .check_params params author return #' #' @keywords internal #' @noRd #' check_is_character <- function(x, error = FALSE) { # check if input error is boolean vector of length 1 check_is_scalar_boolean(x ...
98a1b2e639a54f441c04ebf06f23ba6709df7aeaa7b7f222502eb7f198ce2863
R
1,609
42
setwd("/media/user/disk21/completeAnalysis/visium_2Jun/Figure4/") auc = read.csv('AUC.csv') d1 = cbind.data.frame(auc$orig, auc$AF, auc$celltype, rep('original', nrow(auc))) colnames(d1) = c('value', 'AF', 'celltype', 'idea') d2 = cbind.data.frame(auc$shuffle, auc$AF, auc$celltype, rep('shuffle', nrow(auc))) colnam...
ca011e4fc40e5828a14c883fed331f84b2a5752365c311cae5f45261747439a4
R
1,611
44
# TODO: Add comment # # Author: fec ############################################################################### library(R6) TrackVariables <- R6Class("TrackVariables", public = list( initialize = function(pathToSave=NULL) { private$trackedVariables = list() if (!is.null(pathToSav...
3752dd2d869c767cac566a88690dc225697040b1a112111b729fdfb5e9fe5959
R
1,612
58
myData<-read_excel(path = "betaVal_clusterRoi_Tml_rightHemi.xlsx") View(myData) #checking assumptions # checking for normality # test of normality # H0: normal distribution; H1: not a normal distribution #to reject H0 and accept H1, we should have p<0.05 #to accept H0 and reject H1, we should have p>0.05 => it is norm...
2f4d437e21e3cc18daee171c4aae50ff5a05af592a15154e693c43a579d1d545
R
1,619
55
#' @title Modify the legend labels for categorical metadata #' @description Modify the legend labels for categorical metadata. #' @param scConf shinycell config data.table #' @param m metadata for which to modify the legend labels. Users #' can either use the actual metadata column names or display names. Please #'...
2ba0903ddf09062282410ae5cb2b7780af3b6dc673595e47362a246619b20245
R
1,623
45
# Master Validation Script for Analytical Pipeline (Scheme 3) # ============================================================================== # This script executes the modular unit tests for the core analytical pipeline. # It uses the downsampled example data to verify: # 1. Preprocessing & Integration # 2. Clusterin...
34da375a1c96319c6d71c186b1d86cab87839f663c35f88c9097b2c3f390ebcf
R
1,630
45
library(Seurat) library(SeuratData) library(SeuratDisk) library(patchwork) # See "save_anndata_rds.R" for how to convert AnnData to Seurat RDS ba9 = LoadSeuratRds("adata_ba9_visium_rawcounts.rds") # 1. Split dataset by array; log-transform & select HVGs separately split.by = "visarray" # use all arrays from one indi...
beb96df3593b2c264811fcf8182b3b7a4aeefa85759f599deaa50afff6f959b1
R
1,631
44
"randomForest.formula" <- function(formula, data = NULL, ..., subset, na.action = na.fail) { ### formula interface for randomForest. ### code gratefully stolen from svm.formula (package e1071). ### if (!inherits(formula, "formula")) stop("method is only for formula objects") m <- match.call(expand.d...
939bc0eb42479772ba6d556d7efe2c661411ce120bbe3ce33867a27340d58f5e
R
1,633
57
setwd("/Volumes/IqraMacFmri/visTac/fMRI_analysis/outputs/derivatives/decoding_pseudoRuns") #The one sample t-test has four main assumptions: #The dependent variable must be continuous (interval/ratio). #The observations are independent of one another. #The dependent variable should be approximately normally distribute...
d383cbdb5cbd31e5ed8b9f4b08a9b607482d5058aa69151dd426bb9fece7e1c7
R
1,634
83
#' Help function checking if a variable is a vector of numerics. #' #' @inherit .check_params params author return #' #' @keywords internal #' @noRd #' check_is_numeric <- function(x, error = FALSE) { # check if input error is boolean vector of length 1 check_is_scalar_boolean(x = erro...
aa56a7fc72355f0aff0c897d71be7aba18c2840ae0b30a613912cae6ab6097ca
R
1,649
41
# Create MTP Open Targets diseases and targets annotation mappings # David Hill and Eric Wafula for Pediatric OpenTargets # 02/14/2023 # Load libraries suppressPackageStartupMessages(library(tidyverse)) # establish base dir root_dir <- rprojroot::find_root(rprojroot::has_dir(".git")) # Set path to scratch, module an...
8756c3f1f0c21dbb9fcfea401fe2bf06ad81e71f1175a53f71e22ac6905beb5f
R
1,650
56
# pROC: Tools Receiver operating characteristic (ROC curves) with # (partial) area under the curve, confidence intervals and comparison. # Copyright (C) 2014 Xavier Robin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the...
a11eadac26d3a2db34a2829c709c7e2ff2ac39be2a72b6183281bdb172c8ead2
R
1,651
53
##-------------------------------------## ## FEATPLOTS TAB ## ##-------------------------------------## plot_featplot <- function(mat, genes, dimred, type, x, y, density_lines) { plots <- list() if (type == "pca"){dimred <- dimred$x} dimred <- dimred[,c(x,y)] names(dimred) <- c("V1",...
4756aa44bf95da15ee8d3c5be424c2a8a943480f63050c3c95353cbdf378f1ed
R
1,658
41
source("./clonal_analysis_common_functions.R") # Parameters dataset.name <- "clonal_dataset" # Seurat object to analyze seur.objs.proj.ca <- c(readRDS(file = "./STICR.seuratobject.RDS")) # Clones of size less than min.clonesizes will be filtered out min.clonesizes <- c(2) # Lineage barcode calling method, which will ...
acaa78dfb435da2fc2f61bbf6e2bfb10095caf16ef803a4f490d10f704113359
R
1,665
38
context("Creating the model from different objects") library(MOFA2) test_that("a model can be created from a list of matrices", { m <- as.matrix(read.csv('matrix.csv')) expect_warning(create_mofa(list("view1" = m))) # no feature names provided rownames(m) <- paste("feature", seq_len(nrow(m)), paste = "", sep = "")...
a6f8f61c0500b6adc2215e9b0f445aa0e5cdb52ad131574e7bd65360a54d2508
R
1,669
42
library(pROC) data(aSAH) context("DeLong Placements C++ code works") for (percent in c(FALSE, TRUE)) { for (marker in c("ndka", "wfns", "s100b")) { desc <- sprintf("delongPlacementsCpp runs with %s (percent = %s)", marker, percent) r <- roc(aSAH$outcome, aSAH[[marker]], percent = percent) test_that(desc...
3cdcb8fe4685caf1eec0ed908f3c82b916ac1b51804c5ddd6924322af4d60263
R
1,671
47
##-------------------------------------## ## QC TAB ## ##-------------------------------------## tab_QC_DOUBLETS <- tabItem( tabName = "Doublets", actionButton(inputId = "calculate_doublets", "Calculate doublets"), actionButton(inputId = "remove_doublets", "Remove doublets"), b...
48411496c2178df3f88739bd30d7eedb26f5d2d012385f1ced53bae369ebcaba
R
1,675
38
## code to prepare internal dataset goes here ## based on https://r-pkgs.org/data.html#sec-data-sysdata # rename local names from Olink wide files to match equivalent long export ---- olink_wide_rename_npxs <- dplyr::tribble( ~OA_internal, ~NPXS, "SampleID", "SampleID", "Ct",...
def103f0ae67a208feb93975991909de29e575b426bf46b6eecddd16a63c247a
R
1,675
45
library(argparse) parser <- parser <- ArgumentParser(description='Generate tabix file from bedpe-like files') parser$add_argument('-i', '--bedpe', type="character", help='input bedpe file') parser$add_argument('-t', '--tabix', type="character", help='output tabix filename') parser$add_argument('-s', '--score', type="c...
cbc89e005712f6e96d2713b168d0e2e8252f33c7c897673e1c4057a9fa58bc9f
R
1,689
43
library(org.Hs.eg.db) library(AnnotationDbi) library(tidyverse) setwd("/Users/melis/Documents/MRI_cortical_layers/MRI_layers/code") dirs <- list.files(path = "../data/GO pathways/GO_pathways_with_offspring/.", pattern = "\\.csv$") for (i in 1:6) { data = read.csv(paste0("../data/GO pathways/GO_pathways_with_offsprin...
05bd7b574978eae3455fa5766b8b0200993d0c239794aff782e3a736bc6dfe73
R
1,691
42
# script to visualize the UMAP results from 01-full_dataset_compute_umap_umap_counts.R # load libraries suppressPackageStartupMessages({ library(ggplot2) library(tidyverse) library(ggpubr) }) # generalized function to call for plotting plot_data <- function(umap_output, title = "", color_var, shape_var, label_v...
2e9cc8f88fc177b047cec7cebe497e2b7b213afddfeba8f38152db0248583d49
R
1,691
51
options(timeout = 3600) # 1 hour for downloads options(repos=structure(c(CRAN="https://cloud.r-project.org")), warn = -1) if (!requireNamespace('BiocManager', quietly = TRUE)) { install.packages('BiocManager') BiocManager::install("remotes") } if (!requireNamespace('data.table', quietly = TRUE)) { install...
31b9c6ec55f0bcd5b46f3243388f8e98a3c20bc52c63abb4f99810e810becb15
R
1,696
53
#' @title Remove a metadata from being included in the shiny app #' @description Remove a metadata from being included in the shiny app. #' @param scConf shinycell config data.table #' @param m metadata to delete. Users can either use the original #' metadata column names or display names. For more information regar...
38b4e6fd1f13383f37415ff4eeff2fdaea20f99f3114b5e085b1877ac0e15567
R
1,698
51
# venn_diagram.R # Create Venn diagrams comparing DEGs between OSNs and Fatbody library(readr) library(dplyr) library(VennDiagram) library(grid) # Input files fatbody_data <- read_csv("InR_Fatbody_All.csv") osns_data <- read_csv("InR_OSNs_All.csv") # Venn plot function generate_venn <- function(set1, set2, filename...
e146edee21457ef8210123a3eead54e2e3a8af7106b6c0e500624ec341667b7d
R
1,699
82
--- title: "Celltype_abundance_MC_sim" author: "AF" date: "`r Sys.Date()`" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r} library(Signac) library(Seurat) library(tidyr) library(dplyr) library(ggplot2) library(rstudioapi) devtools::install_github("rpolicastro/scPro...