sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
9eae1e609f07a05b0b08966daaa7f819b0bb9b0654ce0855a844e2e0db1d6d93 | R | 338 | 11 | args <- commandArgs(trailingOnly = T)
tpms <- read.csv(args[1], sep = "\t", check.names = F)
meta <- read.csv(args[2], sep = "\t")
# split psi into cell types
sapply(unique(meta$condition), function(ct) {
s <- meta[meta$condition==ct,"sample"]
write.table(tpms[,s], file = paste0(ct, ".tsv"),
sep = "... |
d83b308368123f5f1940b87db941990a13e369eb790bc78c931e8052252bb721 | R | 341 | 19 | ---
title: "CellBench User's Guide"
author: "Shian Su"
date: "`r Sys.Date()`"
output: BiocStyle::pdf_document
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Introduction
# Ben... |
6e894ad770a1872ea7e69026cefc728a8fc56e629cf372684fc579bec72b71c6 | R | 343 | 11 | context("Data list constructor")
test_that(
"Data list constructor works properly", {
expect_is(data_list(a = 1, b = 2), "list")
expect_is(data_list(a = "a", b = "b"), "list")
expect_error(data_list(1, b = 2))
expect_error(data_list(a = 1, 2))
expect_error(data_list(a = 1, b = "b"))
expect_... |
34f1a6ad333e6b4ca1f75dbe756a0b8de3e4cd1079305019a09fb49a1054b842 | R | 351 | 15 | #' Open vignetted containing a case study using CellBench
#'
#' @return opens a vignette containing a case study
#'
#' @examples
#' \dontrun{
#' cellbench_case_study()
#' }
#'
#' @importFrom utils browseURL
#'
#' @export
cellbench_case_study <- function() {
browseURL(system.file("case-study", "CellBenchCaseStudy.ht... |
2253b2cc6078ca3037c7e48a28dd29ff2f92e855574a51b47a0a1d6a0b4c93af | R | 358 | 13 | .onLoad <- function(libname, pkgname) {
op <- options()
op.CellBench <- list(
CellBench.threads = 1,
CellBench.bpparam = BiocParallel::SerialParam(stop.on.error = FALSE)
)
# set any options not already set
toset <- !(names(op.CellBench) %in% names(op))
if (any(toset)) options(op... |
e178f0b0b073a61bff4ec7e31d3efb17eef3b722f4f44dfb8c65244d0c73a8af | R | 372 | 12 | # This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/tests.html
# * https://testthat.r-lib.org/reference/test_package.html#special-files
libr... |
c57aa6b5ad3aae5356ac458e49c0e9833ebb43ca98d2c8ef114a8015bd5e9268 | R | 386 | 9 | #' @name meanExp
#' @title Example input data set
#' @description
#' This example data set is provided to allow the user to run the examples
#' in the documentation of each package function
#' @format Dataframe of ensembl_gene_ids, their rpkm in each tissue
#' @source The data frame has been randomly generated, no bi... |
a59454223e4a5510ccab4a54a191247b7b01c06c8cf43557830ae6c701436df9 | R | 387 | 11 | .get_assay_data <- function(object, assay = "RNA", layer = "counts") {
# Try SeuratObject v5-style first
out <- tryCatch(
SeuratObject::GetAssayData(object = object, assay = assay, layer = layer),
error = function(e) e
)
if (!inherits(out, "error")) return(out)
# Fall back to v4-style slot
SeuratOb... |
ebebe5857320604332e3b48d97fbdf89b12c923742f633b026d837b4120b8ffc | R | 389 | 9 | #' @name optimum
#' @title Example output of getOptimum()
#' @description
#' This example data set is provided to allow the user to run the examples in
#' the documentation of each package function
#' @format A list containing 2 objects: dataframe and barplot.
#' @source The data frame has been randomly generated, no... |
48639f83da9f72806cfec792b559ea0782e0f92a832c4744d3d169cf385ad6e2 | R | 412 | 18 | library(Matrix)
library(lme4)
library(car)
# Clear the workspace
rm(list=ls())
# Read in the data
data <- read.table(header=T,"LMM_allMeasures.xls")
# Fit the Linear Mixed-Effects Model
interaction.lmer = lmer(y ~ tms_site*measure + (1 + tms_site + measure | Subject), data=data, REML=FALSE);
# Summarise model outpu... |
a3f1e1308d7ada8669b636d0af755641c75d95a25a4897cd7f2730f97708baf9 | R | 415 | 22 | require(lattice)
source("local-functions.R")
plotfun <- function(dvname, df){
df$dv = df[[dvname]]
mypanel <- function(x,y,...){
panel.xyplot(x,y,...)
panel.xyplot(x,y, type = "l",...)
}
xyplot(dv ~ as.factor(configuration)|test
, groups = id
, data = df
, panel = mypanel
... |
54dc0e38cb31523bba9189efcf5e7d54750ec838492f65cb1abf7ff4808d21e2 | R | 418 | 11 | library(uwot)
context("Random initialization")
n_vertices <- 10
res_rand <- rand_init(n_vertices, ndim = 2, verbose = FALSE)
expect_ok_matrix(rand_init(n_vertices, ndim = 2, verbose = FALSE))
expect_ok_matrix(rand_init_lv(n_vertices, ndim = 2, verbose = FALSE))
expect_ok_matrix(rand_init(n_vertices, ndim = 1, verbos... |
9a90e09ee6532bc8e37a8590f1b955b3ff8360dc80136937e53d66d73d1baf28 | R | 420 | 18 | context("Random sampling")
test_that(
"Correct number of rows sampled", {
data("sample_sce_data")
x <- sample_cells(sample_sce_data, n = 5)
expect_equal(ncol(x), 5)
x <- sample_cells(sample_sce_data, n = 51)
expect_equal(ncol(x), 50)
y <- sample_genes(sample_sce_data, n = 5)
expect_e... |
f06c3e7025f30ad77506f0abd6b5b42b11e8d173af4cddc1366880b5a87148d5 | R | 422 | 19 | ## File containing simple function aliases that do not need to be tested.
# apply function across rows
row_apply <- purrr::partial(apply, MARGIN = 1)
# apply function down columns
col_apply <- purrr::partial(apply, MARGIN = 2)
# glue collapse with default sep and last
collapse_with_comma <- purrr::partial(
glue:... |
8fc8afc8f58d2065c512d90166fdf3d3b1ca5d043523f272e9b35a2e7d919b04 | R | 427 | 9 | #' @name log2Exp
#' @title Example log normalised data set output of log2Trans()
#' @description
#' This example data set is provided to allow the user to run the examples
#' in the documentation of each package function
#' @format Dataframe of ensembl_gene_ids, and their log2(rpkm) in each tissue
#' @source The data... |
4d2cc3126c5745372a1789cf32dacf2bb7b871bc98bb7d5e6ca7cfb969617a66 | R | 438 | 13 | #' Check for task errors
#'
#' This is a helper function for checking the result column of a benchmark_tbl
#' for task_error objects. This is useful for filtering out rows where the
#' result is a task error.
#'
#' @param x the object to be tested
#'
#' @return vector of logicals denoting if elements of the list are ta... |
b4f998004c4eace4bb3214dcbe586503465f94adac7bbd3e036632e4ace2c621 | R | 443 | 15 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
eigenMapMatMult <- function(A, B) {
.Call('_scAI_eigenMapMatMult', PACKAGE = 'scAI', A, B)
}
eigenMapMatcrossprod <- function(A, B) {
.Call('_scAI_eigenMapMatcrossprod', PACKAGE = 'scA... |
141f4bf69ab289e287588082e4fcc9b6080a9a07278cc55a0cc3ac3a365de54d | R | 447 | 19 | # Hello, world!
#
# This is an example function named 'hello'
# which prints 'Hello, world!'.
#
# You can learn more about package authoring with RStudio at:
#
# http://r-pkgs.had.co.nz/
#
# Some useful keyboard shortcuts for package authoring:
#
# Build and Reload Package: 'Cmd + Shift + B'
# Check Package: ... |
70899f5963cccdf15883c7a885033f1dbe113293fa3dd04f87c59b6448f1ed1f | R | 455 | 10 | #' @name qnExp
#' @title Example quantile normalised data set output of quantNorm()
#' @description
#' This example data set is provided to allow the user to run the examples
#' in the documentation of each package function
#' @format Dataframe of ensembl_gene_ids, and their quantile normalised
#' expression across a... |
44087f6674e6fae95653478d1723652c0da5c00b0e1c0c70a72eda204a5cdf61 | R | 458 | 9 | path <- "C:/Users/Manuel/Nextcloud/Masterarbeit/dat/tls/Test/X0"
outpath <- "C:/Users/Manuel/Nextcloud/Masterarbeit/dat/tls/Test/X/1"
files <- list.files(path, pattern = ".tif", full.names = TRUE)
names <- list.files(path, pattern = ".tif", full.names = FALSE)
require("raster")
for(i in 1:length(files)){
rast <- stac... |
3a7ea262ce47278986d85471fa9d131cc46490a5a7003fe5ecf6519da2e09e91 | R | 459 | 18 | context("benchmark_tbl methods")
test_that(
"benchmark_tbl summary works properly", {
sample_sce_data <- readRDS(cellbench_file("10x_sce_sample.rds"))
data_list <- list(
data = sample_sce_data
)
method_list <- list(
sample_cells = purrr::partial(sample_cells, n = 10),
sampl... |
c74eda5a49218b98d475a15639ffd46411bdc1a8d033feafbc2424bccfe68d22 | R | 462 | 12 | test_that("the platform cache is the default", {
expected <- file.path(tools::R_user_dir("datamonger", "cache"), "r")
expect_identical(datamonger_cache_dir(), expected)
})
test_that("choosing a cache path does not create it", {
explicit <- file.path(tempdir(), paste0("datamonger-", Sys.getpid()), "cache")
unli... |
90db516b3a59481ed121febf16543f34ca3cc4a28179f5f1280ed59ccafee288 | R | 467 | 10 | #' @name tauAnno
#' @title Example ensembl annotation of data set output of getMart()
#' @description
#' This example data set is provided to allow the user to run the examples
#' in the documentation of each package function
#' @format Dataframe of ensembl_gene_id, external_gene_name, gene_biotype, tau,
#' and tau ... |
fbabec801f4c050fc03f5809513767734b39525eaa248246d092c2d5648e384b | R | 478 | 16 | context("Helper for CellBench internal files")
test_that(
"cellbench_file works properly", {
expect_is(cellbench_file(), "character")
expect_gt(length(cellbench_file()), 0)
expect_is(cellbench_file("10x_sce_sample.rds"), "character")
expect_length(cellbench_file("10x_sce_sample.rds"), 1)
expe... |
38f14a2e10189e146594026b2eb978b236f7ca65aeceed8733c8020b3779acc0 | R | 487 | 15 | test_that("shared semantic categories map to distinct R condition classes", {
cases <- read_fixture_json("conformance", "errors.json")$cases
classes <- vapply(
cases,
function(case) dm_internal(".condition_class")(case$expected),
character(1)
)
expect_setequal(
vapply(cases, `[[`, character(1),... |
bfd9c562fd2b8ea14494302791547236eeb1ab0e4e6367c6ac900030d3745145 | R | 507 | 30 | ---
title: "SSD PINT analyses"
author: "Erin Dickie"
date: "`r Sys.Date()`"
output: bookdown::git_book
github-repo: https://github.com/TIGRLab/SSD_PINT
description: "This contains the analysis reported with the SSD pint paper"
---
# The index page
## all the packages in this book
```{r}
library(tidyverse)
library(h... |
1ad463fa7af72f881945491516157e81d508ef130fe7f7757261f6dcac4df230 | R | 523 | 11 | #' @name tissueB
#' @title Example tissueB output of GetTissue()
#' @description
#' This example data set is provided to allow the user to run the examples in
#' the documentation of each package function
#' @format A dataframe of ensembl_gene_ids and their names, biotypes,
#' quantile normalized expression in tissue... |
191f6e2736f4780fee6b517d362ba998150f8d92ded26ffa5ca92c61471dc89e | R | 524 | 11 | #' @name tissueA
#' @title Example tissueA output of getTissue()
#' @description
#' This example data set is provided to allow the user to run the examples in
#' the documentation of each package function
#' @format A dataframe of ensembl_gene_ids and their names, biotypes,
#' quantile normalized expression in tissu... |
b907b50f7ae769f6e8c0e5df0ac8d56cf60cf39bfcad26be8cbb1092ef850434 | R | 533 | 18 | ---
title: "Creating Benchmarks"
author: "Shian Su"
date: "`r Sys.Date()`"
output: BiocStyle::pdf_document
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
# Introduction
This vignette will provide a tutorial on how to construct your own benchmark... |
19b30a2dfc962edf75c30bd9dc226f5cb8accbcb0e385abf36300e127dd1d25a | R | 546 | 21 | .native_result <- function(result) {
if (is.null(result$category)) {
return(result$value)
}
if (identical(result$category, "interrupted")) {
stop(structure(
list(message = result$message, call = NULL),
class = c("interrupt", "condition")
))
}
.abort_category(result$category, result$mes... |
4a74c052c2d6c1dc89e1be960d7463c5b1710ff21edad3cc70be8330a165d729 | R | 557 | 29 | context("Function list constructor")
test_that(
"fn_list constructor works properly", {
flist <- fn_list(
mean = mean,
median = median
)
expected <- list(
mean = mean,
median = median
)
expect_identical(flist, expected)
expect_error(
fn_list(1),
... |
9241f0d08f750a65a1b5c75c832c471b6ac03336a1a6a214a663b2eb79cee191 | R | 563 | 11 | #' @name tauExp
#' @title Example tau + expression fraction output of calcTau()
#' @description
#' This example data set is provided to allow the user to run the examples
#' in the documentation of each package function
#' @format Dataframe of ensembl_gene_ids, their global tau values,
#' and their tau expression fr... |
cd764b0b83c0c5042def5988c9af88674388713d2324c29cd6c0abd869dceea1 | R | 579 | 20 | #!/usr/bin/env Rscript
args = commandArgs(trailingOnly = TRUE)
sample_files <- list.files(path = args[1], full.names = T, pattern = "gene_expression\\.tsv$", recursive = T)
out_file <- args[2]
print(sample_files)
total_expr <- data.frame()
for (idx in seq_along(sample_files)) {
file <- sample_files[idx]
gene_ex... |
27b16c3ecd622e668bb548ae9cc86715819ed033fd0864bb3aa03e3e28b857a8 | R | 583 | 26 | table <- tibble(x = c(TRUE, TRUE, TRUE, TRUE, FALSE), y = c(FALSE, TRUE, TRUE, TRUE, TRUE))
#when x is TRUE, what is the false rate for y? (should be equal to 3)
data <- table %>%
filter(x == TRUE) %>%
summarise(freq = sum(!y, na.rm = TRUE)/sum(!is.na(y)))
#new practice problem:
library(stats)
table <- tibble... |
435fd1159f287fbf18cdf29778404a4a02ef1e6669930007a9dd48e27828f6ec | R | 584 | 17 | #' Select the R client's private cache directory
#'
#' Datamonger uses the platform user cache by default. An explicit `cache_dir`
#' always takes precedence and can select temporary storage when persistence is
#' undesirable.
#'
#' @param cache_dir An explicit cache directory, or `NULL` for the platform
#' default.
... |
20942b7f7bb95fc18f7ea55b822b8d139a671667b273682fa157e843a3f0fa5f | R | 589 | 15 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
CSCORE_IRLS_cpp_impl <- function(X, seq_depth_sq, D_mu, D_sigma2, D_sigma, post_process = TRUE, n_iter = 10L, eps = 0.05, verbose = FALSE, conv = "q95", return_all = FALSE) {
.Call(`_CSCORE... |
20bc75d355ced1b442c9564e30a7a9d677726ac5b6d9481eb4bbaccb9ce9e64c | R | 591 | 17 | context("Checking functions")
test_that(
"Test class testing functions", {
expect_true(is_one_of(1, c("numeric", "character")))
expect_true(is_one_of("A", c("numeric", "character")))
expect_false(is_one_of(TRUE, c("numeric", "character")))
expect_false(is_one_of("A", c("numeric", "logical")))
expec... |
b18021536c92cd0693c56be317bba433678e56b6bcbf3817d68d59fe4178233f | R | 597 | 22 |
#!/usr/bin/env Rscript
# module load R/4.0.2
# Load libraries:
library(melange)
library(dplyr)
library(Seurat)
library(patchwork)
library(ggplot2)
library(clustree)
library(stringr)
# Use arguments:
args<-commandArgs(TRUE)
# Load Seurat object
seurat.object <- readRDS(file = "seurat.object_clustered.rds")
# Load gene ... |
31cc4d1ac7a4c6953b038fe06bde7d2790177260126558db14d9307d2e4aeaec | R | 606 | 18 | #!/usr/bin/env Rscript
if(!require(pacman)) install.packages("pacman", repos = "http://cran.us.r-project.org")
pacman::p_load(BSgenome, Biostrings, GenomicRanges, GenomicFeatures, seqinr, rtracklayer)
# fasta, gtf, circRNA hits
args = commandArgs(trailingOnly = TRUE)
# load fasta
print("loading fasta...")
fasta <- r... |
154a52f00dcc1a379a62e2810d9b772a270af450492426e6e49b5e73d4f07ad8 | R | 609 | 12 | ## Script to generate top_enrich_go_diff.rda
##
## Run this script once after completing the differential co-expression analysis
## in vignettes/differential_coexpression.Rmd to cache the GO enrichment results
## so that the vignette can render without re-running the full pipeline.
##
## Prerequisites: the objects `ego... |
64bec84615df2c55394c70221577c7b2040ee8aa139d8b6328bd9ce901b5f021 | R | 620 | 21 | library(uwot)
context("Epochs")
V <- fuzzy_simplicial_set(nn = nn)
n_epochs <- 500
V@x[V@x < max(V@x) / n_epochs] <- 0
V <- Matrix::drop0(V)
expect_equal(make_epochs_per_sample(V@x, n_epochs),
c(
1.0, 1.0, 1.0, 6.1763447, 1.44948659, 2.16709542,
2.35197392, 1.0, 1.44948659, 1.0, 1.0, 1.73965964,
2.0000... |
40a949851716b99d13a6580cc72dab7cc47d585d0fef19ec3d08a06948333898 | R | 624 | 18 | directory <- "F:/"
block <- "1"
plot <- "6"
folder <- paste(directory, "Block_", block, "/Block", block, "_", plot, sep = "")
imgs <- list.files(folder, full.names = TRUE, pattern = ".JPG")
#for(i in 1:length(imgs)){
# date <- file.info(imgs[[i]])$ctime
# file.rename(imgs[[i]], paste("/home/manuel/Desktop/Block08/100... |
d792e5df994aa79416607a63277fa1061b79ef925b20d7648851d869a9a84ebb | R | 630 | 20 | pairwise_intersect <- function(list_sets) {
set_names <- names(list_sets)
pairwise_matrix <- matrix(ncol=length(set_names), nrow=length(set_names))
rownames(pairwise_matrix) <- set_names
colnames(pairwise_matrix) <- set_names
for(set_name_a in set_names){
set_a <- list_sets[[set_name_a]]
set_a <- ... |
90b114d9ac2b234ef0b79561fb850c2c322ea01ed58ee247f88c390de4695a82 | R | 637 | 21 | # check the number of genes in files to track if any genes were lost
natural_data <- read.csv(file = "./data/PSICOV_box_20/output/natural_max_freq_files/natural_max_freq_all.csv", header=TRUE, sep=",")
stats_align_all <- read.csv(file = "./output/output_PSICOV/stats_align_all.csv", header=TRUE, sep=",")
cnn_wt_max_f... |
cfd016b53c6e5046d98e6266fa56d7f0a1dae49c0d84005946fc10caf743653f | R | 645 | 16 | wd <- "C:/Users/Manuel/Nextcloud/Masterarbeit/out/mod_FCD"
dat <- read.table(file.path(wd, "confusion_matr.csv"), header = FALSE, sep = "\t")
colnames(dat) <- seq(1, ncol(dat))
rownames(dat) <- seq(1, ncol(dat))
library(tidyverse)
data <- dat %>%
rownames_to_column() %>%
gather(colname, value, -rowname)
d... |
0133a217c1fc1bdaf69e5a3b1d0d9c77191be8f4e6ba110a62263cfb4ee37549 | R | 704 | 24 | library(Matrix)
library(lme4)
library(car)
# Clear the workspace
rm(list=ls())
# Read in the data
data <- read.table(header=T,"LMM_separateMeasures_4regions.xls")
# Fit the mixed-effects models with tms_site being a fixed effect and subject a random effect
att.lmer = lmer(Attention ~ 1 + tms_site + (1|Subject), data... |
3eca8314d73e8285257951360df189e64a1cfbe67c4bddba5ccd13ecc287c3c2 | R | 707 | 20 | ## code to prepare `ind_gene_pair` dataset goes here
# Generate highly variable seq depths from a log normal distribution
set.seed(202212)
sim_seq_depths <- exp(rnorm(2000, 7.3, sd=0.6))
sim_seq_depths <- sim_seq_depths[!sim_seq_depths < 400]
sim_seq_depths <- round(sim_seq_depths)
summary(sim_seq_depths)
# Generate ... |
d4ce7baa9f7dd5060f47a6a96cb5cdec669c2afe9e92d590b5abe2a08af39e1b | R | 734 | 35 | context("Bechmark timing table methods")
test_that("benchmark_timing_tbl methods work", {
datasets <- list(
data1 = 1:10,
data2 = 11:20
)
transform <- list(
identity = identity
)
res <- datasets %>%
time_methods(transform)
res_timing_stripped <- res %>% strip_... |
1cf925a6a470ed80b6d0b197862871b294f16c54e0f7adfb6bc062a1da90df71 | R | 735 | 34 | ---
title: "LaTeX README.md"
author: "Simon Frost"
date: "25 February 2016"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
require(devtools)
install_git("https://github.com/muschellij2/latexreadme")
```
```{r}
library(latexreadme)
```
```{r}
md = file.path("READ... |
a2117ed586f43d3f67ba3d482b8a0c62bc34b37cfb417eba68d2a8793a61404a | R | 742 | 24 | #' Filter bed file to retain only peaks that
#' were found in at least 2 bio reps
# req'd pkgs
x <- c("data.table", "dplyr")
sapply(x, library, character.only = TRUE)
# pull merged peaks from .bed file
t <- fread("./data/4075NIH_Lonza_MeDIP_ucsctracks_bw.txt", fill = T)
t <- t %>% filter(!grepl("track", t$V1))
t <- ... |
fbeebbd7cf9027333a4c76e5395bef7099c9ce5b4cc6cee598f14f363a2f810c | R | 756 | 17 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 3L)
options(OutDec = ".")
invisible(Sys.setlocale("LC_NUMERIC", "C"))
source(args[[3]])
prepared <- read_source(args[[1]])
values <- cbind(prepared$X, y = prepared$y)
names <- c("sample_id", colnames(values))
header <- paste0('"', gsub('"', '""', names,... |
0660091a7b9e7ffec3ca921ef63aa55f432d44da064b5806cd10dea2bc973ab6 | R | 757 | 17 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 3L)
options(OutDec = ".")
invisible(Sys.setlocale("LC_NUMERIC", "C"))
source(args[[3]])
prepared <- read_source(args[[1]])
values <- cbind(prepared$X, y = prepared$y)
names <- c("sample_id", colnames(values))
header <- paste0('"', gsub('"', '""', names,... |
f3b43049bbac3bb7351dbb0bf4e58ed8e41d9de905b2f74e5b8aa7c58c31ffd0 | R | 769 | 24 | #' Get path to CellBench packaged data
#'
#' Search CellBench package for packaged data, leaving argument empty will list
#' the available data.
#'
#' @param filename the name of the file to look for
#'
#' @return string containing the path to the packaged data
#' @export
#'
#' @examples
#' cellbench_file() # shows ava... |
812004c7475ae3357ecbb5706ead7735ee8a5d69bbed4a5a81ef4d936ad2c402 | R | 772 | 21 | df = read.csv2("../data/clinical_data.csv")
ddf = data.frame(condition = rep(c("ON","OFF"), each = nrow(df))
,updrs = c(df$UPDRS_III_Score_ON, df$UPDRS_III_Score_OFF))
boxplot(updrs~condition, ddf, yaxt = "n", xaxt = "n", ylab = "", xlab = "", cex.axis = 2
, cex.lab = 2.5
, mar = pa... |
ce64dac2dda9f291ad9d4603adb0b0869138da2613a1c34df8851cdf3227269b | R | 784 | 30 | require(lattice)
save = TRUE
if(save){
fname = file.path(loc$paths$img,"lowfreq_gait_speed_by_stride_length.png")
png(fname, height=2800, width=2800,res=300)
}
p=xyplot(gait_speed_meter_per_second~stride_length_cm|id,df,cex.axis=2
,xlab=list(label = "stride length (cm)", cex = 2)
,ylab=list(label ... |
1584b81ddf5c654c02bcb6fe814114c1cc90a93e22611ea2cdd6dab62970dd8c | R | 799 | 24 | # start all statistical analyses from here in order to avoid loading the data
# several times over and also in order to keep an overview of the current pipeline
# of statistical analysis. All packages needed should also be loaded here
# --- Preparation -----------------------------------------------------------
# get... |
de6115da8f23a65338133af34b5629b41811829f7efac95b4c165add3779eaa1 | R | 812 | 22 | library(ggpubr)
df <- read.csv("./CMOT_Final/A549/A549_DisPlusenrichment_CMOTvsMOFA2.csv")
df$MOFA. <- as.numeric(df$MOFA.)
df$X = str_wrap(df$X, width = 30)
ggbarplot(df, x = "X", y = "MOFA.",
fill = "#7dbb41", # change fill color by cyl
color = "black", # Set bar borde... |
e3594d740b0599dec5992de2f2461f173ce74f81a7d8c6ab4576b6982556c5bb | R | 823 | 20 | #' This is data for testing functions in CellBench.
#'
#' A dataset containing 200 genes and 50 cells randomly sampled from the CelSeq
#' mRNA mixture dataset, each sample is a mixture of mRNA material from 3
#' different human adenocarcinoma cell lines. Useful for quick prototyping of
#' method wrappers.
#'
#' @usage ... |
c152b68efdc67c4236917a98bfbc7a532295c5cc392ad4d0b78d252d4deb93b6 | R | 826 | 22 | setwd('30_SARTools_d7')
annot <- read.delim('../ref/Biomart_ensembl_for_R.txt')
colnames(annot) <- c('gene_id', 'gene_name', 'gene_description')
write_annot <- function(filename) {
data <- read.delim(filename, check.names=F)
merge_data <- merge(unique(annot), data, by.x='gene_id', by.y='Id')
write.table(... |
bf91e28b2835211bd8bebd988558ed54b271713ad22e4e4f6f6ce9db99bad6ab | R | 838 | 35 | #' Check if any tasks produced errors
#'
#' Check the results column of a benchmark tibble for any task_error objects.
#'
#' @param x the tibble to check
#' @param verbose TRUE if the rows with errors should be reported
#'
#' @return TRUE if any entry in the result column is a task_error object
#' @export
any_task_erro... |
ec27a5fc9490c5e81dc52d4ce4c1d4ed087b2dc1cf200ec311e032831a31871c | R | 845 | 22 | setwd('30_SARTools_d20')
annot <- read.delim('../ref/Biomart_ensembl_for_R.txt')
colnames(annot) <- c('gene_id', 'gene_name', 'gene_description')
write_annot <- function(filename) {
data <- read.delim(filename, check.names=F)
merge_data <- merge(unique(annot), data, by.x='gene_id', by.y='Id')
write.table... |
aa833ce134515d335813089f0ed380b41869d073a4520372a541ea4cf7833483 | R | 867 | 30 | #!/usr/bin/env Rscript
# module load R/4.0.2
library(tidyverse)
# args[1] = Input file
# args[2] = Column name
# args[3] = Output file (root)
args<-commandArgs(TRUE)
data <- read.delim(args[1], header=T, sep="\t")
pvvector <- c()
corvector <- c()
namevector <- c()
colname <- as.character(args[2])
for (name i... |
226f025dd205053c290eaf932e9860ed3ff79e83617e07d3f64db6e70b29c886 | R | 870 | 30 | #!/usr/bin/env Rscript
# module load R/4.0.2
library(tidyverse)
# args[1] = Input file
# args[2] = Column name
# args[3] = Output file (root)
args<-commandArgs(TRUE)
data <- read.delim(args[1], header=T, sep="\t")
pvvector <- c()
corvector <- c()
namevector <- c()
colname <- as.character(args[2])
for (name i... |
7b30e1f4a62456f250429a75cc4f849125041280ffc34f3612adb771e98e148c | R | 875 | 40 | context("Time methods")
# System.time has rather large overhead and it's difficult to write extensive
# unit tests without enormous cost.
test_that("Time methods works", {
datasets <- list(
data1 = 1:10,
data2 = 11:20
)
transform <- list(
exp = exp
)
res <- datasets %>%
... |
344b11aae98f8b97e80c6e195fc498b23ef4960afe10568c8dcc269e3684a928 | R | 889 | 21 | #' A framework for benchmarking combinations of methods in multi-stage pipelines
#'
#' This package contains a framework for benchmarking combinations of methods in
#' a multi-stage pipeline. It is mainly based around the \code{apply_methods}
#' function, which takes lists of functions to be applied in stages of a
#' p... |
7cb37869ed696af18eeaae353a6a8910c0ac64e3366cf95023d71664e42194d1 | R | 889 | 39 | context("Option setting")
test_that(
"Threads can be set properly", {
set_cellbench_threads(1)
expect_identical(getOption("CellBench.threads"), 1)
set_cellbench_threads(2)
expect_identical(getOption("CellBench.threads"), 2)
expect_error(
set_cellbench_threads("foo"),
"is.numer... |
4fd70e58d0d859cf89ba60be87f468c6d4604cbeeb43f13949715167df04da49 | R | 894 | 26 | #!/usr/bin/env Rscript
library(ggplot2)
library(plyr)
library(dplyr)
args = commandArgs(trailingOnly=TRUE)
if (length(args)!=1) {
stop("One argument must be supplied", call.=FALSE)
}
raw_bindSites_file = args[1]
raw_bindSites <- read.table(raw_bindSites_file, header = T, sep = '\t', stringsAsFactors = F)
bindSites ... |
225a1f3752378f0fb628fac49e244e8c9bd7996a6b20a0a89c8bd7e23aff5ea9 | R | 895 | 25 | library(ChIPseeker)
library(ChIPpeakAnno)
library(GenomicRanges)
library(genomation) #
library(data.table)
suppressPackageStartupMessages(library("argparse"))
require(TxDb.Hsapiens.UCSC.hg38.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene
parser <- ArgumentParser()
parser$add_argument( "--path_... |
4e94e16866173bec98a9392fbd96504f5f4da1499091e8d9dd1b86e746529a96 | R | 904 | 42 | context("Generating functions with sequence of arguments")
test_that(
"Function sequence generated correctly", {
fn <- function(x, y) {
x + y
}
fn_list <- fn_arg_seq(fn, y = 1:3)
expect_identical(
names(fn_list),
c("fn(y = 1)", "fn(y = 2)", "fn(y = 3)")
)
expect_i... |
3cb45ad5d575218acf13fe419d6e3d8ba819742687fdb30c2ae1b5b954e8b47e | R | 918 | 23 | # Generated by extendr: Do not edit by hand
# nolint start
#' @usage NULL
#' @useDynLib datamonger, .registration = TRUE
NULL
#' Decode verified artifact paths and optionally hash before converting buffers.
dm_decode <- function(decoder, paths, compressions, options, hash) .Call(wrap__dm_decode, decoder, paths, compr... |
9df204fc3b03d52996f74ba7e8a056697fceb6c122b468d5c7bc606cb84b6318 | R | 921 | 38 | ---
title: "Figure_2d"
author: "Brett Hale"
date: "7/29/2022"
output: html_document
---
```{r}
library(dbplyr)
library(dplyr)
library(ggplot2)
library(tidyverse)
library(devtools)
library(viridis)
```
```{r}
ggplot(transcriptome_heatmap, aes(x = FC_Type, y = geneId, fill = FC)) +
facet_grid(cluster ~ FC_Type, swit... |
6c72edef11becd1ece2af22a274813cdc011d46748d24ed8ddb4855f578f3d93 | R | 930 | 39 | bigstatsr_is_installed <- function() {
is_installed("bigstatsr")
}
bigstatsr_scores <- function(X,
ncol,
center = TRUE,
ret_extra = FALSE,
ncores = 1,
verbose = FALSE) {
... |
3eedad5122e28e0be899692444b8a3b000f8b4ccbdb95fcf1e46d050708c8e5b | R | 937 | 27 | #' @name log2Tran
#' @title Log Transforms a data frame
#' @description
#' Adds a pseudocount (1e-10) to remove zeros, then log2 transforms each
#' column independently. This normalises the data frame within each column
#' only (not across columns - see tispec::QuantNorm). After log2
#' transformation, it resets al... |
65b3245d4fb146498bcbf81aa3939bec14482d1e6b8c97db56838c09fe9b634c | R | 945 | 24 | read_source <- function(path) {
gene <- read.delim(path, na.strings = c("NA", ""), stringsAsFactors = FALSE)
start <- which(names(gene) == "P1")
stopifnot(length(start) == 1L, identical(tail(names(gene), 1L), "P99"))
positions <- start:ncol(gene)
valid <- apply(gene[, positions], 1L, function(row) {
all(g... |
01501fabf61deaaae339b427a7a1c484a7a491bb8f83d5bed7c4ec973276b90a | R | 969 | 25 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 5L)
source(args[[5]])
prepared <- read_source(args[[1]], args[[2]], args[[3]])
reference <- readRDS(args[[4]])
stopifnot(
identical(dim(reference$X), c(101L, 34694L)),
setequal(colnames(prepared$X), colnames(reference$X)),
identical(rownames(refer... |
f601845addeedf4fd92c200b7bcb55a07828e22169692ff0377f2b3183a9fabd | R | 969 | 32 | library(corrplot)
cor.mtest <- function(mat, ...) {
mat <- as.matrix(mat)
n <- ncol(mat)
p.mat<- matrix(NA, n, n)
diag(p.mat) <- 0
for (i in 1:(n - 1)) {
for (j in (i + 1):n) {
tmp <- cor.test(mat[, i], mat[, j], ...)
p.mat[i, j] <- p.mat[j, i] <- tmp$p.value
}
}
colnames(p.mat) <- row... |
2a25f50f27b962a359291362c2a60bf045bd496b5b9fba2f82e7b53f22eaf931 | R | 971 | 35 | #' Constructor for a function list
#'
#' Constructor for a list of functions, a thin wrapper around list() which
#' checks that all the inputs are functions and have names
#'
#' @param ... objects, must all be named
#'
#' @return a list of named functions
#' @export
#'
#' @examples
#' flist <- fn_list(
#' mean = me... |
a1aeb99249617400928d08fef427d40bd47e90337d43a64c6f2147e21faf30af | R | 979 | 30 | pkgload::load_all(".", quiet = TRUE)
args <- commandArgs(trailingOnly = TRUE)
release <- if (length(args)) args[[1L]] else "candidate-0002"
release_root <- file.path("../../registry/releases", release)
selector_document <- jsonlite::fromJSON(
file.path(release_root, "selector.json"),
simplifyVector = FALSE
)
index... |
a93fae5e55f0125262b3af7093cd8984c3b5410b7c4077ef184da95ec9b26e25 | R | 983 | 31 | library(ggplot2)
args = commandArgs(trailingOnly=TRUE)
input_FL = args[1] #'successrate_melted.tsv'
outFL = args[2] #'successrate.png'
df = read.csv(input_FL, sep = '\t')
df$label = factor(df$label, levels = c('Train','Valid','Test'))
print(df[0:5,])
font_size = 20
text_style = element_text(size=font_size, family... |
8e1977b75c46fa045b6a5e15149c380116b0fb6ed9dc69b83ecce6c31297f1e8 | R | 985 | 28 | # library
library(ggplot2)
library(plotly)
library(dplyr)
library(tidyverse)
library(hrbrthemes)
library(viridis)
df <-read.csv("./CMOT_Poster_Plots/LiuCancer/ATAC_TO_RNA_SilhouetteScore_Boxplot.csv")
colnames(df)[1] <- "MOFA+"
colnames(df)[2] <- "Measured \nGene Expression"
g3 <- melt(df)
# Boxplot basic
p<- ggplot... |
420370861b0093a01410e026a0e7171dce3bd8a27c3cd818b87149f519274906 | R | 1,008 | 36 | #' Constructor for a data list
#'
#' Constructor for a list of data, a thin wrapper around list() which
#' checks that all the inputs are of the same type and have names
#'
#' @param ... objects, must all be named
#'
#' @return a list of named data
#' @export
#'
#' @examples
#' data(iris)
#' flist <- data_list(
#' ... |
e0c5461e1244e2e4e71cdfa5fdfa6e6798b7b66508d217415f5797129a09943e | R | 1,025 | 26 |
# Use arguments:
args<-commandArgs(TRUE)
library(MGFR)
data <- read.csv(args[1], sep=",", header=TRUE, row.names=1)
CV <- read.csv(args[2], sep="", header=FALSE)
cv <- CV$V2
M <- getMarkerGenes.rnaseq(data, class.vec=cv, samples2compare="all", annotate=FALSE, score.cutoff=0.75)
outfilebasal <- paste(args[3],"Basa... |
041cd1436d6c34531c806f9449780b15827bcdb0e7f20f107eae53bbe011ce8c | R | 1,029 | 22 | library("Seurat")
set.seed(123)
# Read object
setwd("/storage/scratch01/users/chernandez/rscripts")
se_subset <- readRDS("se_subset_res_482N1_box3_round3.rds")
#pos2cells <- WhichCells(se_subset, cells = rownames(se_subset@meta.data)[which(se_subset@assays$RNA@data["Egr1", ] > 2)])
#se_subset$Egr1.Expression.2 <- ife... |
71e86f2027ff8088ec53500b6f19c113358d114521181c8b32e1aaadc1adb32f | R | 1,057 | 24 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 2L)
pkgload::load_all(file.path(args[[1]], "packages/r"), quiet = TRUE)
bundle <- args[[2]]
manifest <- jsonlite::fromJSON(file.path(bundle, "provenance.json"))
values <- read.csv(gzfile(file.path(bundle, "data.csv.gz")), check.names = FALSE)
stopifnot(... |
881adaa267d74901ffd0e710d8e4c72914e7a7c74409dc4bfe3f32222ef6e0ff | R | 1,059 | 28 | reqPkg = c("data.table", "Matrix", "hdf5r", "ggplot2", "gridExtra",
"glue", "readr", "RColorBrewer", "R.utils", "Seurat")
newPkg = reqPkg[!(reqPkg %in% installed.packages()[,"Package"])]
if(length(newPkg)){install.packages(newPkg)}
reqPkg = c("shiny", "shinyhelper", "data.table", "Matrix", "hdf5r",
... |
7c31ef6814a5b2b04005b874a383ba01d57e2b96a57623053c083a472ab70e14 | R | 1,067 | 38 | # INPUT: hitrate_melted.tsv
#
# label rank Methods hit_rate
# Test 1 hitRate_DR 0.01
# Test 2 hitRate_DR 0.02
library(ggplot2)
args = commandArgs(trailingOnly=TRUE)
hitrate_FL = args[1] #'hitrate_melted.tsv'
outFL = args[2] #'hitrate.png'
df_tmp = read.csv(hitrate_FL, sep = '\t')
df_tmp$label = factor(df_t... |
926707a28520e9b4f302d01beaeb6413f14236d087004201309aa62e0918fab4 | R | 1,068 | 25 | ## Script to generate cached data objects for the differential co-expression vignette.
##
## Prerequisites: run the full analysis in vignettes/differential_coexpression.Rmd.orig
## first so that the following objects are available in your R session:
## diff_result -- output of diff_CSCORE()
## ego_result -- list... |
eb8c34a43d50073ed7fc225b249810c3ca982006877aa543eb6e43711c7d29a2 | R | 1,073 | 39 | # INPUT: rawdata.tsv
#
# label caseID modelID target DR HS
# Test 1YVB 1YVB_ranair-it0_4286 0 0.56818 4.04629
# Test 1PPE 1PPE_ranair-it0_2999 0 0.56486 50.17506
library(ggplot2)
args = commandArgs(trailingOnly=TRUE)
input_FL = args[1] #'it0.rawdata.tsv'
outFL = args[2] #'boxplot.png'
data = read.csv(input_F... |
27f4407b8dc55a85a05da1612072ffc2dd4d29d99699e61cdb11e96d2b7ca5c9 | R | 1,074 | 35 | #' Weighted Least Squares Covariance Estimation (Rcpp)
#'
#' Computes WLS estimates of gene-gene covariance and test statistics that assess
#' the statistical significance of co-expression using moment-based regressions.
#'
#' @param D Design matrix for WLS (size n x k)
#' @param X Gene expression matrix (n x p)
#' @pa... |
01c62d903f17451e98307485d8f94fa949b4325c10ebd4ab1010b42757ae966e | R | 1,086 | 29 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 3L)
source(args[[3]])
prepared <- read_source(args[[1]])
reference <- readRDS(args[[2]])
stopifnot(
identical(dim(reference$X), c(120L, 18975L)),
all(colnames(reference$X) %in% colnames(prepared$X)),
ncol(prepared$X) - ncol(reference$X) == 10L
)
v... |
aa730814c1d834f6e51500b30ffb610cfe86cf8432dc1bdef8cd3875d3f3fa6e | R | 1,087 | 26 | test_that("the introduction renders metadata without downloads", {
root <- getNamespaceInfo(asNamespace("datamonger"), "path")
article <- file.path(root, "vignettes", "introduction.Rmd")
if (!file.exists(article)) {
article <- system.file("doc", "introduction.Rmd", package = "datamonger",
... |
d6554caf9b98f3aa39d97954827ae0019ca7e7281b4d1d2afb99c8dcc53697d7 | R | 1,087 | 41 | #load packages
library(jpeg)
library(plyr)
library(readxl)
library(filesstrings)
library(tidyr)
#import dataset, and convert variables to numeric
md_res <- read_excel("/Users/tijmendelorm/Library/CloudStorage/OneDrive-ImperialCollegeLondon/MRES/Final_Version_Paper/Results/megadetector_results.xls")
md_res = md_res[-1... |
55c1c465a03cca6bed2fd1312891d9cecb20c0acf166455814d45c9ec1319a31 | R | 1,144 | 32 | #' @name quantNorm
#' @title Quantile normalise a data frame
#' @description
#' This function quantile normalises the entire data frame of log normalised
#' counts, allowing comparisons across tissues. First, the row and column
#' names are collected and all zeros are changed to NA. After converting to a
#' matrix,... |
8a72b2eb20e92e42e7fe6a85a7578a4c1a9f627dd6a570539c27c900dfbe6c05 | R | 1,152 | 34 | # remove "OFF" from dbsconditions
dbsconds = unique(df$dbscond)[!unique(df$dbscond) %in% "OFF"]
# define mixed effects model
model <- function(dv, cond){
df$dv = df[[dv]] # inefficient but when using formula(paste(...
# there are problems with consecutive anova
m0 = lme( dv ~ 1
, r... |
6a6087da61d3d13955fc3af1229b37a9171c4b7e3c6004b80b397518946da541 | R | 1,172 | 23 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 3L)
pkgload::load_all(file.path(args[[1]], "packages/r"), quiet = TRUE)
source(file.path(args[[2]], "read_source.R"))
source <- read_source(file.path(args[[2]], "PI_DATA.txt"))
values <- cbind(source$X, y = source$y)
components <- lapply(seq_len(ncol(va... |
3fc2d4ad1381c20160f32d93b907e6e91c1e888d39a9e47f9f36aad9d647400d | R | 1,173 | 23 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 5L)
options(OutDec = ".")
invisible(Sys.setlocale("LC_NUMERIC", "C"))
source(args[[5]])
prepared <- read_source(args[[1]], args[[2]], args[[3]])
values <- cbind(prepared$X, y = prepared$y)
metadata_names <- c("sample_id", "tumor_id", "Treatment", "Day",... |
d91a0e499e2ace3598ab128dedcf2445aee248daaef7e33e7b5bf848d9a1b7ca | R | 1,184 | 30 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 5L)
pkgload::load_all(file.path(args[[1]], "packages/r"), quiet = TRUE)
source(args[[4]])
prepared <- read_source(args[[2]])
values <- cbind(prepared$X, y = prepared$y)
restored <- read.csv(
args[[3]], check.names = FALSE,
colClasses = c("character"... |
afd8a5aa1ea041ed92cc8d2dde94062ded99bb12ad2532655746e37d43e1f255 | R | 1,197 | 57 | context("Filtering utilities")
test_that(
"Filtering zero genes works", {
x <- matrix(runif(100), nrow = 10, ncol = 10)
x[1, ] <- 0
expect_identical(
filter_zero_genes(x),
x[-1, ]
)
sample_sce_data <- readRDS(cellbench_file("10x_sce_sample.rds"))
x <- sample_sce_data
... |
5beea54fbe9468c10b55efabcfbc1ba699c85634bffc5e8e0dd07a6b307d0cc2 | R | 1,199 | 29 | args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(args) == 3L)
options(OutDec = ".")
invisible(Sys.setlocale("LC_NUMERIC", "C"))
source(args[[3]])
source <- read_source(args[[1]])
stopifnot(
identical(names(source), c("X", "y")),
is.matrix(source$X), is.double(source$X),
identical(dim(source$X), c(842L, 3... |
b07ee94a52556d74ca378525dc4154e03d81870d68a1acd4b30951d91027101f | R | 1,208 | 42 | #!/usr/bin/env Rscript
library(Rsubread)
args = commandArgs(trailingOnly = TRUE)
# sam file
sam_file <- args[1]
# id
id <- args[2]
# genome version
genome_version <- args[3]
# gtf
gtf_file <- args[4]
# read mode
is_single_end <- function(isT) {
if (isT == "true") {
return (FALSE)
} else {
return (TRUE)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.