sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e5c291d69e5e6def368ad71d0737a0a9433b50c25bcfa0f2c715b4afeae3960c | R | 789 | 36 | #' @tags reset
#' @tags sequential multisession multicore
library(future)
options(future.debug = FALSE)
## Like mean(), but fails 90% of the time
shaky_mean <- function(x) {
if (as.double(Sys.time()) %% 1 < 0.90) stop("boom")
mean(x)
}
x <- rnorm(100)
message("*** reset() ...")
for (strategy in supportedStrate... |
37e9af2969c289eb426d5fa295abba0090adafc528d67643497c526db2938d6d | R | 808 | 26 | # Fig8_b_stats
# R code for pairwise comparisons of proportions with multiple comp. corr. (Benjamini Hochberg)
nhits <- c(156.0520, 108.0000, 109.0000, 66.0000, 89.0000, 53.0000, 44.0000)
ntrls <- c(467, 115, 123, 118, 109, 119, 116)
pairwise.prop.test(nhits , ntrls, p.adjust.method = "BH")
# run here: https://rdr... |
608400529c90b0b32da23c0944916fae0d72a528687e89cb7e33148102b91261 | R | 808 | 24 | # Used by getGlobalsAndPackages()
ConstantFuture <- function(..., substitute = FALSE, globals = NULL, packages = NULL, stdout = NA, conditions = NULL, seed = NULL, lazy = FALSE, envir = emptyenv()) {
future <- Future(..., substitute = substitute, globals = NULL, packages = NULL, stdout = NA, conditions = NULL, seed =... |
68fa010c6c607e57205b7f6dc3909563fcd1addb0fca6a2d183ffc2d43e84b3b | R | 808 | 44 | ---
title: "Toy network example"
author: "Andras Hartmann"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
#output: pdf_document
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
This simple example demonstrates loading, contextualizing and ... |
487808b7bdffa67ea837158e54740d21c45ed974b742da839e5a46f21c1d4da3 | R | 811 | 30 |
library(tidyverse)
set.seed(123)
gamma <- c(1, 2)
lambda <- c(1, .5, 2, 1, .5, 2)
data <- tibble(id = seq_len(500)) %>%
uncount(2, .id = "domain") %>%
mutate(b = rnorm(nrow(.))) %>%
uncount(3, .id = "item") %>%
mutate(item = factor(paste0(domain, item))) %>%
mutate(
x = runif(nrow(.)),
y = b + gamma[... |
cdc605d26eb74142323d2bdd277d67b0e9ffee28014c36f0d3125ac355fee542 | R | 813 | 35 | #' HumanNet v3 XC LLS graph
#'
#' Loads the HumanNet v3 graph object (`graph.hn3`).
#'
#' @usage data("HNv3_XC_LLS")
#' @format An object of class \code{igraph}.
#' @keywords datasets
"HNv3_XC_LLS"
#' HumanNet v3 XC dataset
#'
#' Loads the HumanNet v3 graph object (`HNv3`).
#'
#' @usage data("HNv3_XC")
#' @format An o... |
f95456c66450f2d4a7066453726bf5823981075a8920d2cc616a8f08260531cf | R | 816 | 36 | #' @tags labels
#' @tags sequential multisession multicore
library(future)
message("*** Futures - labels ...")
strategies <- supportedStrategies()
for (strategy in strategies) {
message(sprintf("- plan('%s') ...", strategy))
plan(strategy)
for (label in list(NULL, sprintf("strategy = %s", strategy))) {
f... |
1520fa35f0ae4e47361741567dff5080319ccff745ff26f479b54355314e0a9e | R | 824 | 34 | #' create_column_interval
#'
#' Adds column with intervals spanning multiple time points
#'
#' @param df data frame
#' @param timeVar character-column name for time points (not time exact)
#' @param Interval.list list of vectors specifying time points to include for each interval
#' @export
create_column_interval <-
... |
44a19cc168520e49bca464eb05821ac8e8d329f7e7410b9d609e1d5829f8722b | R | 828 | 33 | ## This test asserts that two R connections part of PSOCK cluster nodes
## are identified as different, although they share the same connection
## index. This is required in order to work around a bug in R [1]
## [1] https://github.com/HenrikBengtsson/Wishlist-for-R/issues/81
library(future)
message("all.equal() for c... |
f1f78af73778ab44005dfdd12dfae4549941c8d4e8a1770863df626080c49cdf | R | 836 | 22 | #!/usr/bin/R
library(UpSetR)
#library(svglite)
args = commandArgs(trailingOnly=TRUE)
movies <- read.csv(file=args[1], header = T, sep = "\t")
nb <- as.integer(args[3])+1
size <- 0.5
if (as.integer(nb)>60){
size <- 0.2
}
sets <- names(movies[2:nb])
#svglite(args[2], width = 4, height = 4)
pdf(args[2])
#upset(movi... |
651b92d01e925abce8902402ca5a9790ae1816ee07b7dabaeb10d999721b2d6b | R | 837 | 26 | #' ACTIONet: Robust multi-resolution analysis of single-cell datasets
#'
#' Joint archetypal/network-based analysis for multi-resolution decomposition of single-cell states.
#'
#' @section Usage:
#'
#' \enumerate{
#' \item ?reduce.sce to reduce raw count matrix in an SummarizedExperiment objects.
#' \item ?run.ACTIONet... |
9e38431b64e3f8acc61e13ced500aff7c8ef716a9124bc1d4c8dacf7d938870f | R | 844 | 29 | # R version:RStudio
# 2022.02.1 Build 461
# © 2009-2022 RStudio, PBC
# load packages:
library(RColorBrewer)
citation("RColorBrewer")
#############################################
# load the fish dataset:
data.file <- read.csv ("C:/Users/pies/Desktop/PCR-heatmap-data-DanioV1.csv",sep=";", header=T, na.string... |
43d856ef8847b0ad8a9ac243d6e92c2ae53e44b102aadfe6fd61038eabcaa9f6 | R | 851 | 25 | ## Run qpgraph
library(qpgraph)
args <- commandArgs(trailingOnly = TRUE)
logdir = args[1]
rho = as.double(args[2])
print(logdir)
print('rho = ')
print(rho)
data = read.csv(file = paste0(logdir,'/adjacency_matrix.csv'), header = FALSE, sep = ',')
nrow = nrow(data)
adj_matrix <- data.matrix(data)
cov_... |
ef6cd933b6d047daf5575cfdbdf4a1320bf91b4d1331232775313f675752a310 | R | 859 | 34 | #' Convert Edge List to Adjacency Matrix
#'
#' \code{adj2el} converts a standard adjacency matrix to edge list
#'
#' @param adj Adjacency Matrix
#' @return Edge List
#' @family network conversion
adj2el <- function(adj){
#empty frame for result set
res = data.frame(TF=character(), effect=character(), target=charac... |
d01752abe0d400a294139d39f52a31a3446d97fb9ea2291ce07bd5f228e6e916 | R | 861 | 30 | ##' @importFrom gratia draw
##' @export draw
NULL
#' Draw method for galamm objects
#'
#' This function uses \code{gratia::draw} to visualize smooth terms. See
#' [gratia::draw()] for details. When \code{object} is not of class
#' \code{galamm}, it is forwarded to \code{gratia::draw()}.
#'
#' @param object An object o... |
e7ef8c45f39067469612c8ec05dc7cd954f1be0d752fe415880c234127773390 | R | 865 | 29 | # This tests the rebuildIndex function.
# library(testthat); library(SingleR); source("setup.R"); source("test-rebuild.R")
trained <- trainSingleR(training, training$label)
test_that("rebuildIndex works correctly", {
ref <- classifySingleR(test, trained)
tmp <- tempfile(fileext=".rds")
saveRDS(trained, f... |
c20bda6a493ea8645263c5d09877425fe065ef35cbfc9a4d42db628ad75fc83a | R | 867 | 40 | # read config file
conf <- read.table(
file = 'config/tools_location.csv',
header = T,
stringsAsFactors = F,
sep = ','
)
# test if tools are named correctly and appear
tools <- c(
'cutadapt',
'bowtie',
'samtools'
)
if(sum(is.element(
tools,
conf[,1])) != length(tools)) {
stop(
'The tools name... |
a8cc7f25c1f8e2dd757129ba3b6f8988ab34415fdfbcfe10b14d3e6952e6c1d0 | R | 868 | 15 | #' @return
#' `minifuture(expr)` creates a future with minimal overhead, by disabling
#' user-friendly behaviors, e.g. automatic identification of global
#' variables and packages needed, and relaying of output. Unless you have
#' good reasons for using this function, please use [future()] instead.
#' This function exi... |
e40bd887a7d682e231805c9832790ce0fa00ffd9640d12bf51454446a8177207 | R | 869 | 27 | ## Register makeClusterMPI() and makeClusterPSOCK() as a cluster types
## such that they can be created using parallel::makeCluster(), e.g.
## cl <- parallel::makeCluster(..., type = parallelly::RPSOCK)
#' @rawNamespace if (getRversion() >= "4.4") export(FUTURE)
FUTURE <- "future::FUTURE"
registerClusterTypes <- loca... |
8e450412ed510429b69fbfa413753655fb890c82049d15cf848296c175ccd881 | R | 882 | 38 |
setwd("/groups/umcg-fg/tmp01/projects/genenetwork/recount3/")
library(readr)
colTypes <- cols(
.default = col_double(),
`X1` = col_character()
)
table_tmp <- read_delim("Recount3_QC_2ndRun/Filtered_Matrices/TPM_log2.txt", delim = "\t", quote = "", col_types = colTypes)
tmpLog2 <- as.matrix(table_tmp[,-1])
row... |
21ef0d532a54d50bc22ea3907f6654422038c30ddabc9ce587997c0da850d362 | R | 897 | 21 | # Consensus clustering analysis of social perceptual features
#
# Severi Santavirta 07.03.2023
library(corrplot)
library(ConsensusClusterPlus)
## Load data
features = read.csv("/path/social_features.csv",sep = ";"); # Read average social feature time series for reliably evaluated features (45 features)
## Concensus ... |
b81fb56db6c1cdb7d33b55d37a806dbd05d4c9bfb2d7d16baaf4cb730e24cbd3 | R | 907 | 32 | rm(list = ls())
library(sRACIPE)
library(combinat)
mk.ecdf <- function(rset){
ecdfs <- vector(mode = "list", length = 10)
x <- scale(log2(t(assay(rset)))[rowSums(log2(t(assay(rset)))) != -Inf,])
a <- x[,"A"]
b <- x[,"B"]
c <- x[,"C"]
d <- x[,"D"]
ecdfs[[1]] <- ecdf(a)
ecdfs[[2]] <- ecdf(b)
ecdfs[[3]] ... |
b0d3f825a53f384721e99bcfbf63fdc7a54d0e67d38b374be46ff48d279ee9a3 | R | 909 | 29 | ##' @importFrom gratia appraise
##' @export appraise
NULL
#' Gratia style model diagnostic plots
#'
#' This function uses \code{gratia::appraise} to make model diagnostic plots.
#' See [gratia::appraise()] for details. When \code{model} is not of class
#' \code{galamm}, it is forwarded to \code{gratia::appraise()}.
#'... |
d26fef510ebe3338d5d7f5837b794703a7c739d28f055e03098726c2322e9560 | R | 916 | 34 | #' @tags minifuture sequential
library(future)
message("*** minifuture() ...")
plan(sequential)
## A minimal future behaves like a regular one for self-contained expressions
f <- minifuture(42L)
stopifnot(inherits(f, "Future"))
stopifnot(identical(value(f), 42L))
## Globals are not identified automatically, so the... |
397dd2df066ce6ad59600ceeecf458d7ff2ecbd351b6d564f9ee3e884030ab83 | R | 930 | 29 | #' @tags demo mandelbrot
#' @tags sequential cluster multisession multicore
library(future)
## Avoid 'Error: C stack usage 7971940 is too close to the limit'
## on R (< 4.1.0)
if (getRversion() < "4.1") options(future.debug = FALSE)
message("*** Mandelbrot demo of the 'future' package ...")
options(future.demo.mand... |
24623e85da17994dcbe2d3c7114c9928da898318b5ada68a6ba86639e975d2bb | R | 933 | 33 | #' @title Extract model fitted values
#'
#' @srrstats {G1.4} Function documented with roxygen2.
#' @srrstats {G2.1a} Expected data types provided for all inputs.
#' @srrstats {RE4.9} Modelled values of response variables.
#'
#' @description
#' Extracts fitted values from a model including random effects.
#'
#' @param o... |
8158f020d9ff306981ae17ab6f1f78641633ebf223b49c3f6b1eb2df7c48f815 | R | 943 | 28 | ## Private future functions
.onLoad <- future:::.onLoad
.onAttach <- future:::.onAttach
asIEC <- future:::asIEC
FutureRegistry <- future:::FutureRegistry
gassign <- future:::gassign
get_future <- future:::get_future
geval <- future:::geval
grmall <- future:::grmall
commaq <- future:::commaq
hpaste <- future:::hpaste
im... |
946c119949f8b083f70b2f1864a2935325b0ab9c3c427a6eef70d5d9c65da2a3 | R | 946 | 34 | #' Title
#'
#' @param par
#'
#' @return
#' NOT EXPORTED @export
#' @keywords internal
#'
#' @examples
slurm_pairTrait_singleStep_likelihood = function(par){
theta=unlist(par)
test = optim(theta, pairTrait_singleStep_likelihood,
betXY=betXY, pi1=pi1, sig1=sig1, w8s=w8s, pi_U=piU,
i_X=i... |
dde735aa5a5385cce9b700c5058c058a6dacac4de59c9cfd5b84f09f00250667 | R | 947 | 34 | #' @title Extract response values
#'
#' @srrstats {G1.4} Function documented with roxygen2.
#' @srrstats {G2.1a} Expected data types provided for all inputs.
#' @srrstats {RE4.8} Response variables, and associated "metadata" where
#' applicable.
#'
#' @description Extracts response values from a model.
#'
#' @param o... |
da229fd9deed2de4bd85c9c963c34596273e67846352a401d1a32bd2cca1ead9 | R | 948 | 34 | #' Title
#'
#' @param par
#'
#' @return
#' NOT EXPORTED @export
#' @keywords internal
#'
#' @examples
slurm_pairTrait_twoStep_likelihood = function(par){
theta=unlist(par)
test = optim(theta, pairTrait_twoStep_likelihood,
betXY=betXY, pi1=pi1, sig1=sig1, w8s=w8s, pi_U=piU,
pi_X=piX, p... |
9a785918adce360399e2aa1d3f105cfd9eb8f103aff4e9fd7b8f9c7daeae5ba4 | R | 955 | 28 | #' Load differentially expressed data
#'
#' Loads a differentially expression profile from booleanized gene expression data. Positive values mean up-regulated genes in the second phenotype
#'
#' @param filename Name of the file containing the differential expression profile (tab separated values)
#' @return List of ge... |
f9ac1808251a5b75a46f26c4d83ac5b4f6bf0104c7c04c101befc45f234bf40a | R | 955 | 40 | #' create_column_treatment
#'
#' Adds column with inhibitors
#'
#' @param df data frame
#' @param Treatment.list list with names equal to intervals
#' @param IntVar character-column name for intervals
#' @export
create_column_treatment <- function(df,
Treatment.list=list(
... |
2e6ba42549e2943ae75be841120852201bdaf6718c6506880e9b28ca4946e011 | R | 965 | 17 | #!/usr/bin/env Rscript
library(Biostrings)
library(tidyverse)
args = commandArgs(trailingOnly=TRUE)
testclass = args[1]
testdata = args[2]
x <- readDNAStringSet(paste("~/pacificfpr/",testclass,"/pacificoutput_rc.pacificoutput_fprtest", testdata, ".", testclass, ".genomes.fasta.gz", sep=""))
x <- names(x)
x <- separate... |
a3dd0e1b808aa9ba5b6e10ba1c96878794e07c07811d259db98232244ab2d147 | R | 971 | 38 | #' Convert SIF network to Edge List
#'
#' \code{sif2el} converts a standard adjacency matrix to edge list
#'
#' @param sif: SIF network
#' @return Edge List
#' @family network conversion
sif2el <- function(sif){
if (nrow(sif)==0) {
return (data.frame(TF=character(), effect=character(), target=character()))
}
... |
9e86e82d7e002f70db8b23a192576b0fbf781677f81b2c373d309d790f1aa2e4 | R | 973 | 24 | # plot feature plots for a list of genes
umap.gene.list <- function(data, gene.list, plot.path){
plot.path = plot.path
dir.create(plot.path, recursive = TRUE)
missing.genes = c()
for(g in gene.list){
if(!g %in% rownames(data)){
missing.genes = c(g, missing.genes)
next
}else{
print(g... |
fc7914c25c007122b6b1606ffaec7b0e2b2ad38605ea6f46d2efd53700a336aa | R | 973 | 46 | #' @tags globals
#' @tags tweakExpression
library(future)
library(globals)
message("*** tweakExpression() ...")
expr <- substitute({ a <<- 1; b <- 2; 3 ->> c }, env = list())
print(expr)
exprT <- tweakExpression(expr)
print(exprT)
b <- 2
exprs <- list(
A = substitute({ a <- b; }, env = list()),
B = substitute... |
779caa89fe82661d0e6bea66ae0574ff5d407d82d261aaaf1fdac2e6edbe1ac1 | R | 974 | 44 | # Extract MAF from NCBI DBSNP
library(dplyr)
library(tidyr)
library(purrr)
library(janitor)
library(tibble)
library(glue)
library(stringr)
library(readr)
library(forcats)
# library(rsnps)
## Snakemake
## Input
path_snps <- snakemake@input[["snps"]]
## Output
outfile <- snakemake@output[["outfile"]]
## Import SNPs
d... |
4b7dd44dd389afe030bc837141a906b5416022e8a4b515bc463a5b322767dbfa | R | 976 | 34 | #' @title Extract galamm coefficients
#'
#' @srrstats {G1.4} Function documented with roxygen2.
#' @srrstats {G2.1a} Expected data types provided for all inputs.
#' @srrstats {RE4.2} Model coefficients (via coef() / coefficients())
#'
#' @description
#' Currently, this function only returns the fixed effects.
#'
#' @pa... |
e6d9ff99b326e8745142c5b1024dd914676fdc700331cce684635bb310175de2 | R | 980 | 21 |
#### cluster at different resolutions and plot clustree
clust.res <- function(seurat.obj, by = 0.1, starting_res = 0){
plots <- list()
resolutions <- c(seq(starting_res, starting_res+9*by, by=by))
if(length(seurat.obj@reductions) == 0){
stop("Carry out dimensionality reduction (PCA) before clustering")
}
... |
8becb70b28c0c72bded238089f1103ba1adf586a7ddef0ba16418231e8f00205 | R | 984 | 57 | #' @tags future
#' @tags sequential
library(future)
message("*** future() ...")
message("*** future() w/ lazy = TRUE ...")
f <- future({
42L
}, lazy = TRUE)
print(resolved(f))
y <- value(f)
print(y)
stopifnot(y == 42L)
message("*** future() w/ lazy = TRUE ... DONE")
message("*** future() w/ lazy = TRUE in loca... |
7491563274ebeb7b663f824f56f60e4f069f8139d934fa769294821e054b5d9c | R | 985 | 32 | #' Temporarily tweaks the arguments of the current backend
#'
#' @usage fassignment \%tweak\% tweaks
#'
#' @param tweaks A named list (or vector) with arguments that
#' should be changed relative to the current backend.
#'
#' @aliases %tweak%
#' @rdname futureAssign
#'
#' @export
`%tweak%` <- function(fassignment, twea... |
5619177d3f0de3bb7a9c9219acf3c39434087aa77694b5b4a73103d418cbdcc0 | R | 989 | 33 | library(dplyr, warn.conflicts = FALSE)
library(tidyr, warn.conflicts = FALSE)
library(purrr, warn.conflicts = FALSE)
set.seed(100)
mresp <- tibble(id = 1:1000) %>%
mutate(b = rnorm(nrow(.))) %>%
uncount(4, .id = "item") %>%
mutate(
x = runif(nrow(.)),
y = pmap_dbl(
list(b, item, x), ~ if_else(..2 %... |
036c76de4646f4e9e476a92c22b2baab6b90f8801e0464b359145ee900425cd6 | R | 992 | 19 | if (!file.exists("/projects/lu-lab/BenStuff/research/projects/oldhome/scripts/networks/clustscore/slap_index/scoredf_term1_NUMBER1")){
load("/projects/lu-lab/BenStuff/research/projects/oldhome/scripts/networks/clustscore/output/scorelistNUMBER1")
num <- NUMBER1
nums <- (((num - 1)*1000)+1):(num * 1000)
scoremat... |
01d709a965a24e9952a88e0ca42baec1b26e8589ffa741feef514b775d41370a | R | 996 | 38 | library(future)
library(listenv)
## IMPORTANT:
## 1. The below usage of lazy futures will only work when they are
## all evaluated in the same process.
## 2. We disable the capturing of standard output (stdout=NA) to avoid
## 'sink stack is full' errors
## 3. We disable the capturing of most conditions (conditio... |
50d086a53573dccb6aa04cd24405b10851ecca52d4ee06fb5471c61cb2bcd03c | R | 997 | 38 | #' @tags requestCore
#' @tags multicore
library(future)
message("*** requestCore() ...")
message("*** requestCore() - exceptions ...")
## There are no cores to choose from
res <- try(requestCore(function() {}, workers = 0), silent = TRUE)
stopifnot(inherits(res, "try-error"))
res <- try(requestCore(function() {}, ... |
3de8549a97227328331fc00f78111af79a755d4edd0fdcbeb8c5ed2590169184 | R | 1,002 | 29 | ### Preprocess the data files
#' Normalize raw data based on total protein count per sample.
#'
#' @param d Input a dataframe with expression values, using the Protein IDs as rows, samples as columns
#' @return Dataframe with the normalized protein expression values from \code{d}.
#' @examples
#' normalize.sam... |
e4f99fbd268ba6a760ff606feb1e1ecec50c8802f53576703b6dd11248b221dc | R | 1,009 | 39 | #' add normalization data
#'
#' adds a column with normalization factors.
#'
#' @param raw.dat dataframe
#' @param norm.dat.dir character-path of files. files are plain text with 8 rows and 12 columns
#' @param norm.meth character
#' @param batch.col character, matches file names
#' @param na what are NA symbols, defau... |
d63f60db56da2a2a2e96383a9c42a8f5c94d435d11dc299222690bdc88c99ef1 | R | 1,016 | 36 | stopf <- function(fmt, ..., call. = TRUE, domain = NULL) { #nolint
msg <- sprintf(fmt, ...)
msg <- .makeMessage(msg, domain = domain)
if (is.call(call.)) {
call <- call.
} else if (isTRUE(call.)) {
call <- sys.call(which = -1L)
} else {
call <- NULL
}
cond <- simpleError(msg, call = call)
s... |
37f6db9ff391455ca6b8890cde7c524730fb84b87c289f967f7684b0004e9141 | R | 1,019 | 32 | ##' @importFrom gratia derivatives
##' @export derivatives
NULL
#' Derivatives of estimated smooth via finite differences
#'
#' This function uses \code{gratia::derivatives} to compute derivatives of
#' estimated smooth via finite differences. See
#' [gratia::derivatives()] for details. When \code{object} is not of cl... |
1650e958812e770e254103b477b85f8d5350a7843298fc0c2e115ca6fc3a0c44 | R | 1,021 | 28 | # Other variants of interst
## Reiman, E. M. et al. Nat Commun 11, 667 (2020).
## Jonsson, T. et al. Nature 488, 96–99 (2012).
library(tibble)
library(tidyr)
library(readr)
library(purrr)
library(plyr)
library(dplyr)
library(stringr)
library(forcats)
other_out.path = snakemake@output[['other_out']]
## All Manual... |
55909ff5e327611da281713bc8de76b20349d0692d663e0f00bcb8c1c9e1220e | R | 1,024 | 45 | # Descriptives of AD GWAS
library(dplyr)
library(tidyr)
library(purrr)
library(janitor)
library(tibble)
library(glue)
library(stringr)
library(readr)
library(forcats)
library(glue)
`%nin%` <- negate(`%in%`)
ad_loci <- "/results/ad_loci.csv" %>%
read_csv() %>%
filter(study %nin% c("Jonsson", "Reiman")) %>%
selec... |
cfd5810dc93342ce1f6af82a2e69dfb55fa35922af296beb3f092649795be2f1 | R | 1,025 | 30 | #' Use a specific plan for a future assignment
#'
#' @usage fassignment \%plan\% strategy
#'
#' @param strategy The backend controlling how the future is
#' resolved. See [plan()] for further details.
#'
#' @aliases %plan%
#' @rdname futureAssign
#'
#' @export
`%plan%` <- function(fassignment, strategy) {
fass... |
4dffb26bc7fe196774fc39a28484b9d0a4aa9f041cf355f27e812cf71a0b4852 | R | 1,026 | 31 | ## Local functions for test scripts
printf <- function(...) cat(sprintf(...))
mstr <- function(...) message(paste(capture.output(str(...)), collapse = "\n"))
attachLocally <- function(x, envir = parent.frame()) {
for (name in names(x)) {
assign(name, value = x[[name]], envir = envir)
}
}
## WORKAROUND: capture... |
525436debaf07aa1195f98804a99b0c01cc48cc9f934d71b730f1098070919d5 | R | 1,027 | 31 |
# subset gene modules based on selected gene list provided
# keep_mod_ID sets the names of the module outputs as their initial input position
# selected_gene_ratio is the ratio of selected genes which must be present in order for the module to be kept
subset.gm <- function(gm, selected_genes, keep_mod_ID = F, selected... |
3e9775620acf15c67636c350ca36c1b50314b51f721280a5c759d279788b8ffe | R | 1,030 | 29 | deprecateArgument <- function(fcn, name, value) {
fcn <- match.arg(fcn, choices = c("future", "plan", "resolved"))
option <- sprintf("future.%s.%s", fcn, name)
action <- getOption(option, "deprecated")
action <- match.arg(action, choices = c("deprecated", "defunct", "ignore"))
if (action == "ignore") return()... |
9dbdc9188bf10a72a4e534ac372143bf2e9840d7425f0bf710d5cd9d54e35569 | R | 1,035 | 21 | # Cluster script
library(data.table)
n.causal <- 100
window <- 50000
ensembl <- fread("../depict2_bundle/reference_datasets/human_b37/ensgR75_protein_coding.txt", data.table=F)
ensembl <- ensembl[ensembl[,2] !="MT",]
sim.pheno <- sapply(1:110, function(x){rnorm(nrow(ensembl))})
pheno.ids <- 11:20
for (i in 1:... |
c47f7c5408d166afde42c0a791a730d8b9d8fb5cdd8b020c6beb876c96080b8e | R | 1,035 | 21 | ## This is needed in order to be able to assert that we later
## actually work with the same connection. See R-devel thread
## 'closeAllConnections() can really mess things up' on 2016-10-30
## (https://stat.ethz.ch/pipermail/r-devel/2016-October/073331.html)
#' @importFrom parallelly isConnectionValid
check_connectio... |
a4ba23b056c724869d1b03dcd75eb276d0cea89248bcff51c3bfe85687bd6d21 | R | 1,038 | 26 | #Load libraries
library(tidyverse)
library(rvest)
#Import manuscript table into R
url <- "https://genomebiology.biomedcentral.com/articles/10.1186/s13059-016-1140-8/tables/1"
tab <- read_html(url) %>%
html_nodes("table") %>%
html_table(fill=T) %>%
.[[1]] %>%
setNames(c("subject","qpcr_species","qpcr_count","qp... |
dfa2e8d15318a69b06f598bcc253e1691aea4bb14015b0c19849efaa9aa04a93 | R | 1,039 | 36 | library(comprehenr)
run_stats <- function( data_name ) {
df <- read.csv( file = paste('data/',data_name,sep='') )
pfc <- to_vec( for (ii in 0:99) tail( df[paste('pfc',ii,sep='')], 1 ) )
pmc <- to_vec( for (ii in 0:99) tail( df[paste('pmc',ii,sep='')], 1 ) )
w = wilcox.test(pfc, pmc, paired = FALSE, alt... |
d1bedfdb5cc2032f2e66eaf1289f876caaa31e5fbfa2e1972e2100d6e427d420 | R | 1,048 | 32 | #' Compute the difference from median
#'
#' Compute the delta value for each cell,
#' defined as the difference between the score for the assigned label and the and median score across all labels.
#'
#' @inheritParams pruneScores
#'
#' @details
#' This funciton computes the same delta value that is used in \code{\link... |
4a4dc56b8aeacd92dbf34920130a5762c2ce16e73fc0b282508b2b2f19d14ce9 | R | 1,070 | 39 | #' @title Extract family or families from fitted galamm
#'
#' @srrstats {G1.4} Function documented with roxygen2.
#' @srrstats {G2.1a} Expected data types provided for all inputs.
#' @description
#' This function returns a list of families for an object of class
#' \code{galamm}, returned from \code{\link{galamm}}.
#'
... |
f0f593b2ca3aee34bc22288293189225e15890a71a9f41b6167011ad01d4c3b8 | R | 1,070 | 44 | #' @tags globals s4
#' @tags sequential multisession multicore
library(future)
library(methods)
message("*** Globals - S4 methods ...")
setGeneric("my_fcn", function(x) standardGeneric("my_fcn"))
setMethod("my_fcn", signature(x = "numeric"), function(x) { -x })
org_my_fcn <- my_fcn
truth <- my_fcn(3)
for (strategy... |
e08cb20c802750b7a714d93c752c0cce9245e99a6ac73e6d51424c94a98ba18e | R | 1,073 | 52 | ## Evaluate futures in parallel
plan(multisession)
## Data
x <- rnorm(100)
y <- 2 * x + 0.2 + rnorm(100)
w <- 1 + x ^ 2
## EXAMPLE: Regular assignments (evaluated sequentially)
fitA <- lm(y ~ x, weights = w) ## with offset
fitB <- lm(y ~ x - 1, weights = w) ## without offset
fitC <- {
w <- 1 + abs(x) ## Dif... |
12ce5258b5efc558c737777927777028f71bd2924c4c00bb66d914a182283f21 | R | 1,074 | 43 | library(tidyverse)
n <- 200
set.seed(1)
latent_covariates <- tibble(
id = seq_len(n),
type = list(c("measurement1", "measurement2", "response")),
x = runif(n)
) %>%
mutate(eta = rnorm(nrow(.))) %>%
unnest(cols = type) %>%
mutate(
y = case_when(
type == "measurement1" ~ eta,
type == "measur... |
ca16e8ee5cc70741c69eeaf4982e01afed9472cc200de47d78079cb6781392cc | R | 1,087 | 26 | #***********************************************************************************
# Defining a function which will calculate fitness value and return weights at each
# layer and fitness value
#***********************************************************************************
fitness<- function(traindf, testd... |
ecf96009ea0f4a5e48d3962e5d042dcdca6d8320829fb059b5ad63467dc4aeef | R | 1,093 | 30 | ## Look for detritus files
testme <- as.environment("testme")
local({
delta <- diff_connections(get_connections(), testme[["testme_connections"]])
if (any(lengths(delta) > 0)) {
message(sprintf("Detritus connections generated by test %s:", sQuote(testme[["name"]])))
print(delta)
## Close added connecti... |
e08367928023564c817f29ebaf2b8cb5530675d12864235e6f41e6cf2c91a04f | R | 1,097 | 34 | #' Grouped families
#'
#' This function is inspired by a function of the same name in the `mgcv`
#' package \insertCite{woodGeneralizedAdditiveModels2017}{galamm}, and supports
#' setting up mixed response type models. When using this function, the response
#' variable must be supported as a two-column matrix, in which... |
9763f8987ec83179bc4676319319279c20ee8933e84d631ba2ed2fab08d01566 | R | 1,098 | 33 | ### Get cytogenic bands
library(dplyr)
library(tidyr)
library(tibble)
library(stringr)
library(readr)
library(httr)
## Snakemake
### Output
outfile <- snakemake@output[["out"]]
bands <-
httr::POST(url = "https://genome.ucsc.edu/cgi-bin/hgTables",
body = list(clade = "mammal", org = "Human", db = "hg19... |
ce47d88939eb64037317577c043ff7192340060956b773d7239f7fe8c73f0887 | R | 1,099 | 44 | #' @tags interrupt
#' @tags detritus-files
#' @tags multisession
library(future)
options(future.debug = FALSE)
plan(multisession, workers = 2)
for (inorder in c(TRUE, FALSE)) {
message(sprintf("inorder = %s ...", inorder))
## Create two futures, where the first is emulated to be interrupted
## Future 1
f1 <... |
8a612dd874fc61371b8caf1b68cfa70bed02ed9d6482c704d898a91ed11da780 | R | 1,117 | 39 | #' @tags worker-killed
#' @tags multicore
#'
library(future)
message("*** multicore() - terminating workers ...")
## IMPORTANT: Skip when testing with 'covr', because killing a worker may
## truncate its 'covr' trace file, which in turn breaks the coverage merge
if (!covr_testing && parallelly::supportsMulticore() &&... |
b65c9f29d7af559c94b87d73eabe3a8369d80930d75e65a697964260e9e0208e | R | 1,117 | 29 | stepped = do.call('rbind',lapply(1:length(tmpM), function(x){setNames(data.frame("window" = names(tmpM)[x],
'border' = unname(tmpM[x])),
nm = c('window', 'border') ) }))
stepped$window = pa... |
4e8631144348fb0051a195fa0f65d18e63dabad7564d56b4a244157ca6ce2d99 | R | 1,119 | 33 | #!/usr/bin/env R
#This script is designed to convert concatenated PACIFIC summaries to metadata
#Load required libraries
library(tidyverse)
#Load dataframe containing concatenated PACIFIC summaries
dat <- read_tsv("pacific/figures/rnaseqtests.txt", col_names=T)
colnames(dat) <- c("filename", "class", "preads", "ppro... |
4ff0e7b29507f8e60cb64b8b9bda5441d43cedd26e2b9da88758ea338f272e8e | R | 1,121 | 35 | ```{r}
if (basename(getwd()) == "downstreamer_main") {setwd("coregulation_calculations")} else {setwd("../coregulation_calculations")}
library(data.table)
eigenvectors <- fread("data/eigenvectors_gene_network_no_celllines_200_components.txt", data.table=F)
rownames(eigenvectors) <- eigenvectors[,1]
eigenvect... |
a6cdf8fc12e5569024f24d63345f611153ff1d88d11f2b6bccf84174e56d4822 | R | 1,122 | 34 | ########
#### Documentation of data in the deconCell package
########
#' DeconCell gene list
#' Vector of gene names (ENSEMBL identifiers) used in all of the Decon cell models
#'
#' @format Lists of 100 elemented with coefficients, names are coded in ENSEMBL identifiers
"dCell.geneList"
#' DeconCell models
#' Lists ... |
ce697426db16a73bfdfe6a504b65bd02131951cfa791002852a4cdbe325a4e3b | R | 1,135 | 31 | ## Look for detritus files
testme <- as.environment("testme")
local({
path <- dirname(tempdir())
if (basename(path) == "working_dir") {
files <- dir(pattern = "^Rscript", path = path, all.files = TRUE, full.names = TRUE)
if (length(files) > 0L) {
message(sprintf("Detritus 'Rscript*' files generate... |
d7782eef271ea8374bb9af47c48d3d60a3e2bc80028571cd4e2d58ca97edd54c | R | 1,136 | 39 | ```{r}
if (basename(getwd()) == "downstreamer_main") {setwd("evaluating_coregulation")} else {setwd("../evaluating_coregulation")}
source("../downstreamer_functions.r")
source("data/source_olivier.r")
datasets.orig <- read.downstreamer.batch(main.downstreamer.output.path, USE.CACHE = T)
datasets.corr ... |
80fff536d370a4565ae3b30de247dcd3245703eaa3df5d4f70af49d9f43f29bb | R | 1,146 | 40 | #' @title Extract formula from fitted galamm object
#'
#' @srrstats {G1.4} Function documented with roxygen2.
#' @srrstats {RE4.4} The specification of the model, generally as a formula (via formula())
#' @param x Object of class \code{galamm} returned from \code{\link{galamm}}.
#' @param ... Optional arguments passed ... |
abef1b26b3fe8f4286410464504eb351ce003700f58f46b81b7ac0014b63445d | R | 1,148 | 43 | rm(list = ls())
options(stringsAsFactors = FALSE);
library(WGCNA);
allowWGCNAThreads()
library(flashClust);
library(gplots)
library(RColorBrewer)
library(limma)
library(ggplot2)
library(MASS)
setwd(dirname(rstudioapi::callFun("getActiveDocumentContext")$path))
# setup-----------
load("../Colon/modules.rda")
load("..... |
22a53a810406111da5a03d2fc3a30d9bee670bb4c0c54bbfd4f239557ce751ab | R | 1,150 | 37 | #' Title
#'
#' @param par pp
#' @param start_ind
#' @param end_ind
#'
#' @return
#' NOT EXPORTED @export
#' @keywords internal
#'
#' @examples
slurm_blockJK_singleStep_likelihood = function(par,start_ind, end_ind){
theta=unlist(par)
test = optim(theta, pairTrait_singleStep_likelihood,
betXY=betXY[-(... |
c8f3a8ae0d05c15910b8e2606b0a3d31819ce180f8cb1a5832943d1e047f9b8c | R | 1,151 | 35 | #' @tags windows
library(future)
adhoc_native_to_utf8 <- future:::adhoc_native_to_utf8
## WORKAROUND: In order to avoid this test script itself to use UTF-8
## encoding, we generate such UTF-8 strings at run-time instead from
## escaped UTF-8 strings.
strings <- c(
"[x] hello" = "[x] hello",
"\\u2713 hel... |
590250cbc66da42f24bdadee66adb05f1496d289fa25670469704d108e1c1952 | R | 1,152 | 37 | #' Title
#'
#' @param par pp
#' @param start_ind
#' @param end_ind
#'
#' @return
#' NOT EXPORTED @export
#' @keywords internal
#'
#' @examples
slurm_blockJK_twoStep_likelihood = function(par,start_ind, end_ind){
theta=unlist(par)
test = optim(theta, pairTrait_twoStep_likelihood,
betXY=betXY[-(start_... |
1d74c7408a18d2c5eb55cd867b777d450ec6aa0339b649bcfb5430de36bd5a3a | R | 1,154 | 29 | library(ggplot2)
library(data.table)
source('../utils.r')
source('../config.r')
df <- fread('learning_curves.csv')
df[,learning_type := factor(learning_type, levels = c("train", "validation"))]
df[learning_type=="train", learning_type := "Training"]
df[learning_type=="validation", learning_type := "Testing"]
df <- df... |
9fe342bdf2399494592459d41621173bc065c95255108b242de55b0dca33dd9e | R | 1,157 | 45 | #' @tags cancel
#' @tags detritus-files
#' @tags detritus-connections
#' @tags multisession multicore
library(future)
options(future.debug = FALSE)
## A sequential future is resolved already when created, so there is
## nothing to cancel
strategies <- setdiff(supportedStrategies(), "sequential")
for (strategy in str... |
0eaa119c2c5c88a91986fc134580b4f0d8d10f77d05ee78c5e9b8cbf50faa825 | R | 1,158 | 45 | #' @tags startup parseCmdArgs
library(future)
options(future.debug = FALSE)
maxCores <- min(2L, availableCores(methods = "system"))
plan("default")
message("*** parseCmdArgs() ...")
args <- parseCmdArgs()
str(args)
options(future.plan = NULL, future.cmdargs = c("-p", 1L))
args <- parseCmdArgs()
str(args)
stopifn... |
3d56c27316106f6ba702cd11483eb6b84e3a25fce879833971cbc21ae9d71205 | R | 1,165 | 32 | # GWAS Meta-data
library(tibble)
library(dplyr)
library(readr)
## Snakemake input/output
outfile <- snakemake@output[["out"]]
## Effective sample size
## https://github.com/neurogenomics/MungeSumstats/blob/master/R/compute_sample_size_neff.R
adgwas <- tribble(
~study, ~year, ~neff, ~n, ~n_pca, ~n_ca, ~n_cn, ~n_l... |
09e1480d4ce90fe2becdfa8b8d5506188664008916374fcfc87d564c034e66cc | R | 1,168 | 37 | #' Evaluate an R expression while collecting journals from completed futures
#'
#' @param expr The R expression to evaluate
#'
#' @param substitute If TRUE, then `expr` is subtituted, otherwise not.
#'
#' @param envir The environment where `expr` should be evaluated
#'
#' @details
#' This function evaluates an R expre... |
b34aec485a31894cc8e236f2a1da43db85468741b11e1ce593b109017c6dcc50 | R | 1,171 | 37 | ---
title: "View the Parcellation"
author: "Damon Pham"
date: "10/8/2020"
output: html_document
---
Parcellation info: https://github.com/ThomasYeoLab/CBIG/tree/master/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal (Version 3)
Parcellation data download source: https://github.com/ThomasYeoLab/CB... |
807cb2d04df0a2ff4a545e05c826ef0a0c7b9e335fd6a3d9c646038cb84c35ff | R | 1,176 | 32 | setwd("C:\\Users\\patri\\Dropbox\\UMCG\\GrantApplications\\2020 Veni")
load("calcium_nephr_ROC_objects.RData")
library(pROC)
pdf(paste0(hpo_name,".pdf"), width = 10, height = 10, version = 1.2)
par(pty="s", bty = "n", cex = 2.2, cex.axis = 1, las = 1, cex.lab = 1.2, xpd = NA)
plot.roc(KN.roc, col = "green", main = hp... |
5393d2f9710bf4b355b53182272dd9fd1b35123b4bd8d37ff0bd2462302377db | R | 1,177 | 34 | #' remove_wells
#'
#' removes background and user-specified.
#'
#' @param dt dataframe
#' @param method character
#' @param background character vector
#' @param exclude character vector
#' @param nMeasures integer - how many timepoints
#' @export
remove_wells <- function(dt, method = "without transformation",
... |
6213d8346d1d5c49369476a1d5265f1d1c652c6f85849fdac8d39eb32a74b011 | R | 1,183 | 26 | ## Comment: The below should be set automatically whenever the future package
## is loaded and 'R CMD check' runs. The below is added in case R is changed
## in the future and we fail to detect 'R CMD check'.
Sys.setenv(R_PARALLELLY_MAKENODEPSOCK_CONNECTTIMEOUT = 2 * 60)
Sys.setenv(R_PARALLELLY_MAKENODEPSOCK_TIMEOUT =... |
85c6dbd835ddd3e1e558cb3f7094cd7d7272070780c3d9753fced1701954e2a9 | R | 1,188 | 44 | #' @tags globals too-large
#' @tags multisession
library(future)
message("*** Globals - too large ...")
a <- integer(length = 1000)
ooptsT <- options(future.globals.maxSize = object.size(a) - 100L)
limit <- getOption("future.globals.maxSize")
cat(sprintf("Max total size of globals: %g bytes\n", limit))
plan(multise... |
489255b7a4628d3ceba97695364e5cfc6ceac92faa49523a5362a5940edb3730 | R | 1,189 | 39 | ```{r}
setwd("../downstreamer_collaborations/metabrain/")
source("../../downstreamer_main/downstreamer_functions.r")
results <- read.downstreamer.batch("data/metabrain_downstreamer_results_with_cerebellum/", potential_traits=c("GenePrioritization_MetaBrain", "GenePrioritization_MetaBrainCor", "GenePrioritization_Meta... |
c2b6a1d159e9beb29f3e059780ab6be787e44becd09b597185d3437676b1891a | R | 1,190 | 37 | #!/usr/bin/env R
#This script is designed to create bar plots of FNR reads
#Load required libraries
library(tidyverse)
#Load dataframe containing concatenated PACIFIC summaries
dat <- read_delim("pacific/figures/fnrtestresults95.txt", delim=":", col_names=F)
colnames(dat) <- c("set", "class", "type", "FNR")
p1 <- d... |
fe0a85df5b72e40d40a83ffd61d344932890b13954227508f42aaa9960ffe9e7 | R | 1,196 | 47 | # Merge SNPs into loci
## A region of ±500 kb was defined around each variant with a stage I P value below 1 × 10−5.
## These regions were then merged using bedtools to define nonoverlapping regions.
library(dplyr)
library(tidyr)
library(purrr)
library(janitor)
library(tibble)
library(glue)
library(stringr)
library(... |
187841e01e1f56cef8173be4a237bb1703ad856a0eaea2f7a67ac89977bda139 | R | 1,197 | 25 | #' Get AmpSeqR extdata
#'
#' The example data that is required for AmpSeqR. The input files are the standard paired-end FASTQ files provided by the common NGS sequencing platforms, as well as sample barcodes and target amplicon details. The sample barcodes file should include sample_id, barcode_fwd, barcode_rev, sample... |
96ff2a904d9ee83fef232c8fd1b6bf147aaa65df160bc16d0e9aa7c872ec9f3b | R | 1,200 | 68 | a <- b <- c <- NA_real_
# An sequential future
plan(sequential)
f <- future({
a <- 7
b <- 3
c <- 2
a * b * c
})
y <- value(f)
print(y)
str(list(a = a, b = b, c = c)) ## All NAs
# A sequential future with lazy evaluation
plan(sequential)
f <- future({
a <- 7
b <- 3
c <- 2
a * b * c
}, lazy = TRUE)
y <... |
6b1292ee3ee2b6d8fb90426702160b6e129e5f2d6a7d346371e8a1963291804b | R | 1,201 | 37 | #' @tags cluster
#' @tags globalenv
library(future)
## The test leaks variables into the global environment on purpose, so
## we need to disable the (default or 'R CMD check') misuse check
options(future.globalenv.onMisuse = "ignore")
message("*** cluster, erase global environment ...")
plan(cluster, workers = 1L)
... |
1b6c9e081eaebab84e235531337cb2479d9fe9e7f8af110828e8e89f48866b76 | R | 1,211 | 37 | ```{r}
library(ggplot2)
library(gridExtra)
source("~/Documents/projects/pr_integration/wd_integration/Code/UtillityScripts/PlottingFunctions.r")
# data <- read.table("~/Desktop/depict2/expression_ced.csv", sep="\t", quote='"', header=T)
data2 <- read.table("~/Desktop/depict2/expression_bmi.csv", sep="\t", quote='"', ... |
5845e207028865e64263b8bf2f5c03df551fb01ae55deaa7c520fca70ed5007c | R | 1,214 | 42 | ##' @importFrom nlme fixef
##' @export fixef
NULL
#' @title Extract fixed effects from galamm objects
#' @srrstats {G1.4} Function documented with roxygen2.
#' @srrstats {G2.1a} Expected data types provided for all inputs.
#'
#' @description
#' Extract the fixed regression coefficients.
#'
#' @param object An object o... |
0041053dc45e707cebcde2b4162506e23c43e20daadd4e9238117a9b52daa3b1 | R | 1,223 | 45 | test_that("Residuals are correctly computed with binomial outcome", {
gm1 <- lme4::glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = lme4::cbpp, family = binomial)
gm2 <- galamm(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = lme4::cbpp, fa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.