sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
571c9e4e3483ef5254ef487c87474e8e8c9c96e5ef3bd9f2f895f2469d5c6e88 | R | 1,119 | 37 | #'---
#' title: Create GeneID-GeneName mapping
#' author: mumichae
#' wb:
#' log:
#' - snakemake: '`sm str(tmp_dir / "MAE" / "{annotation}.Rds")`'
#' input:
#' - gtf: '`sm lambda w: cfg.genome.getGeneAnnotationFile(w.annotation) `'
#' output:
#' - gene_name_mapping: '`sm cfg.getProcessedDataDir() + "/mae/gene_... |
90dc926c04f34ffb960fed0b47ba0b53a1117c602e6ba27135241b164fbc516d | R | 1,120 | 32 | #' Mouse Hippocampus VeraFISH data
#'
#' This dataset comprises VeraFISH profiling of cells in the mouse hippocampus.
#' Gene expression and cell centroids for 10,944 cells and 129 genes in 2
#' spatial dimensions are provided. For details on how this dataset was
#' generated, refer to Supplementary Information sectio... |
61691a1be86092127c1e598691120a47a407fe44879ac6c33f20bf5e33e26c6a | R | 1,121 | 36 | #!/usr/bin/env RScript
args=commandArgs(trailingOnly=TRUE)
# usual functions
lire<-function(x, character=FALSE){
if(character){
d<-read.table(file = x,sep = "\t",header=T,row.names = 1,colClasses = "character",quote="",check.names=FALSE)
}else{
d<-read.table(file = x,se... |
6e431b67387f319e2cabfd55048732d92810fb9e17f3b3a00c95d0f0641c8f8b | R | 1,130 | 34 | frb_scatter <-
combined_mods %>%
ggplot(aes(x = truth, y = corrected_pred, color = corrected_gap)) +
# abline of true age above other elements for vis
geom_abline(lty = 1, color = "#cccccc", size = 1.2) +
geom_point(size = 5, alpha = 0.5) +
# linear trend of mod
geom_smooth(
method = lm, formula = y ~... |
b6a47857cd17a40e938b5b20de743ddcc65534b2768f0144bf0093e7efcbcba0 | R | 1,149 | 29 | #'
#' The Banksy package
#'
#' Banksy is a library and R package for network analysis.
#'
#' @rdname Banksy-package
#' @name Banksy-package
#' @keywords internal
#' @aliases Banksy-package Banksy
#' @docType package
#' @useDynLib Banksy, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#'
#' @section Description:
#' ... |
209090ca0674b387fb757f7ce01774a4a779a79ace357d9791aa8d5c1dab63be | R | 1,151 | 29 | #' @title Create Sankey Diagram
#' @description Generates a Sankey diagram to visualize flows or relationships between nodes.
#' Uses the `networkD3` package.
#' @param links Data frame containing 'source', 'target', 'value', and optionally 'color' columns.
#' @return A Sankey diagram widget (networkD3 object).
sa... |
409bcb8f7d27462bdaced8e2526938e6e48b9bfe3aefb45954adedad6faf1985 | R | 1,153 | 29 | # extract.parametrs = function(fit, name_of_model,
# parameters.to.extract = c('chisq', 'df', 'pvalue',
# 'cfi',"tli",'rmsea',"rmsea.ci.lower",
# "rmsea.ci.upper", 'srmr')) {
# i... |
b2c65c3345d8b1625430329418405f1531adb1f0a2eeb7ca4317874555c50cc9 | R | 1,153 | 27 | # Pure functions shared by analysis and checks.
assert_design <- function(md,formula) {
mm <- model.matrix(formula,md)
if(qr(mm)$rank<ncol(mm) || nrow(mm)<=ncol(mm)) stop('Nonestimable or saturated design')
invisible(mm)
}
make_rank <- function(values,symbols) {
keep <- is.finite(values)&!is.na(symbols)&nzchar(... |
f0f585a2a1187b1617150f7e19c1a2d630e4683355db417137e4a6e20c7f5eb3 | R | 1,158 | 37 | # In this script we will be gathering pathology diagnosis
# and pathology free text diagnosis terms to select EPN
# samples for following EPN subtyping analysis and save
# the json file in EPN-subset folder
library(tidyverse)
## Directories
root_dir <- rprojroot::find_root(rprojroot::has_dir(".git"))
output_dir <-... |
de22050f9eaff26fb1fd077ef7c7996f4c15ac87bd2bd619c659fd5a7ac1eba6 | R | 1,164 | 27 | context("geom_polygon_auc")
test_that("geom_polygon_auc works", {
test_geom_polygon_auc_screenshot <- function() {
print(ggroc(r.s100b) + geom_polygon_auc(r.s100b$auc))
}
expect_ggroc_doppelganger("geom_polygon_auc.screenshot", test_geom_polygon_auc_screenshot)
})
test_that("geom_polygon_auc works with perc... |
de64d55f4a56b23600dcad12e11e2cf7c004a5f1238bc3024143c31e743ef498 | R | 1,164 | 38 | #######################################
#
# This function is used to obtain the
# time delay projecton maps from inputs
# while matching the selected participants
#
# This function can load the data of TDp and
# ETS. Indicates what kinds of data you want to
# load in [type] parameter
ObtainBrainData <- fun... |
8df37fccfb5c5f93b76f13f7a0b0f8826f94d10df0c2285d6cec196dee87bfe3 | R | 1,166 | 37 | library(openxlsx) # import excel file
library(reshape2) # reshape data
library(ggplot2) # plots
library(lmerTest) # linear mixed model
library(emmeans) # multiple comparisons
donnees <- read.xlsx("anatExt_decodAccu.xlsx")
donnees$subID <- factor(donnees$subID)
donnees <- melt(donnees)
donnees$FoR <- sub("_.*", "", d... |
9162e5bec222fa93474be95ba15b83d9f40189b5a82365819fd50e052b94cae7 | R | 1,170 | 34 | source("../shinytest_helpers.R")
set_window()
app$setInputs(layout_and_readouts = "separate_files")
app$uploadFile(layout_table_file = demo_path("CRA_Layout.xlsx"))
app$uploadFile(readout_matrices_file = demo_path("CRA_1ReadoutXlsx_INF-R-1632.zip"))
app$setInputs(type_of_analysis = "StepA")
app$setInputs(iTReX = "QCN... |
0e13b5bc737c3bf6c9821893e129cba725e2370ca50ea2d0030cad6e6614fccb | R | 1,173 | 28 | ################################################################################
# Determines if a gene expression plot should be created.
#
# The event reactive that triggers creating a gene expression plot is based on
# the Show plots button being clicked and Gene Expression option being chosen.
# The logic is compli... |
1b6422afb4fda705ea22c2514daa9888aa17eef7e9206ca8e61b3a3bd4cabc70 | R | 1,173 | 36 | # designed to run on a _single_ parcel-beta
make_rdms_from_beta <- function (path_parcel_beta) {
betas <- read_csv(path_parcel_beta)
# in case the ROI has 0 voxels? which happens apparently?
if (nrow(betas) == 0) return (NULL)
roi <- str_sub(basename(path_parcel_beta), start = 7L, end = -5L)
betas ... |
f6283bd9ee609dfdb7b362f22b29bc5f5661310cffdb3866b7fac90faefe73f4 | R | 1,173 | 25 | test_that("NCBI_synonyms2023 maps aliases to official symbols using a supplied annotation", {
# tiny synthetic annotation with the required column order:
# Symbol (2), all_synonyms (3), GeneID (4), ENSG_ID (5)
annotation <- data.frame(
rows = 1:4,
Symbol = c("PTGER3", "PTGER3", "SNTB2", "TP5... |
6c943996fb2092ce72fba6fbd78cd94665d8473928e35be5e2e5a25e14397476 | R | 1,174 | 42 | ---
title: "R Notebook"
output: html_notebook
---
## Load merged gene symbol + ENSG mapping file and PMTL file
```{r}
library(tidyverse)
ens_map <- read_tsv("results/gencode_ensg_symbol_map_merged.tsv") %>%
rename(ensg_id = ensembl)
pmtl <- read_tsv("input/PMTL_v3.1.tsv") %>%
rename(ensg_id = Ensembl_ID, pmtl = F... |
50b18a3094e44a00926f84d7aa5fa11f63792e43387cc53d8e7e2aaaafc59941 | R | 1,179 | 28 | rm(list = ls())
library(ggplot2)
library(openxlsx)
library(tidyverse)
go_enrich = read.xlsx('metascape_result.xlsx', sheet = 2)#read enrichment analysis result
go_enrich <- go_enrich[grepl("Summary", go_enrich$GroupID), ]
go_enrich <- go_enrich[1:10,]
go_enrich$term <- paste(go_enrich$Term, go_enrich$Description... |
113e69af148da57ea0f961f7c2a99a580f40eeb849783abc87a3f58c554fbaf5 | R | 1,180 | 25 | setwd("/data/wuqinhua/phase/covid19/datasets")
library(Seurat)
library(SeuratDisk)
sce1 = readRDS("./pre_data/9_Schulte-Schrepping_2020/seurat_COVID19_PBMC_cohort1_10x_jonas_FG_2020-08-15.rds")
sce2 = readRDS("./pre_data/9_Schulte-Schrepping_2020/seurat_COVID19_PBMC_jonas_FG_2020-07-23.rds")
sce1@meta.data <- as.data... |
2b1a0c36c6fd3c5fc729fddd535b186e8bc2869630a5518c7879566c21614abb | R | 1,180 | 41 |
library(Biobase)
library(GEOquery)
library(Seurat)
library(readxl)
library(ggplot2)
library(dplyr)
library(harmony)
library(GenomicRanges)
library(Seurat)
library(patchwork)
library(cowplot)
library(data.table)
library(scales)
library(org.Hs.eg.db)
library(rtracklayer)
getGEOSuppFiles('GSE76381', baseDir="downloads... |
2c940a8b9d45bf4abf6a19a34683264ea92d50f4494c7ff3b94d128de1d07de9 | R | 1,182 | 41 | #' Batch Correction with SVA
#'
#' This function will do batch correction on mvalues,
#'
#' @param mval matrix of mvalues
#' @param pdata sample Sheet (dataframe)
#' @param model model to apply with sva (string) eg: "~group+gender"
#'
#' @return A matrix of batch corrected mvalues
#'
#' @importFrom sva sva
#' @importFr... |
36f32242f90100354ee484d59a223ec640eb653321335d811ee178a850e6a71a | R | 1,187 | 39 | library(tidyr)
library(dplyr)
library(ggplot2)
library(lme4)
library(lmerTest)
library(performance)
#setwd("R")
data <- read.csv("DFT_glucose.csv",
header = T,
stringsAsFactors = F,
fileEncoding = "SJIS")
delta_data <- data |>
pivot_wider(names_from... |
c2ec47c2bb859611567bc6f56de93dcc044bccb332a62cc6645a15021ff876a0 | R | 1,199 | 42 | na.roughfix <- function(object, ...)
UseMethod("na.roughfix")
na.roughfix.data.frame <- function(object, ...) {
isfac <- sapply(object, is.factor)
isnum <- sapply(object, is.numeric)
if (any(!(isfac | isnum)))
stop("na.roughfix only works for numeric or factor")
roughfix <- function(x) {
if (any(... |
2b9e18c7ece8277445fc4fcefd5c2fa29dd9a77c6fa6e3df53479216ed5502e0 | R | 1,203 | 44 | #' GO annotation data for human
#'
#' A data.frame containing GO annotation mappings for human genes.
#'
#' @format A data.frame with columns:
#' \describe{
#' \item{GeneID}{Gene identifier}
#' \item{GO}{GO term identifier}
#' \item{Ontology}{GO ontology (BP, CC, MF)}
#' }
#' @source Generated from Bioconductor o... |
6cc1a40e18491023dad74ebb64e0f1333fa94f83ea6437d65f7d3758a38b4ef9 | R | 1,203 | 28 | # Load required libraries
# These libraries provide various functionalities such as UI components, data manipulation,
# visualization, and mass spectrometry data processing.
# This file is prefixed with underscore to ensure it loads first alphabetically
library(shiny)
library(shiny.semantic) # For semantic UI componen... |
b4ba2a246d45122cb0c442786efefbb9492446e46ac97d9168757357d073969e | R | 1,203 | 28 | ################################################################################
# Determines if a splice junction plot should be created.
#
# The event reactive that triggers creating a splice junction plot is based on
# the Show plots button being clicked and Splice Junction Usage option being
# chosen. The logic is ... |
825f379abe22de55b2be7877454a3a6a4dbb6d03f4474e5dc10f15b32ed89bc6 | R | 1,206 | 60 | args <- commandArgs(TRUE)
name <- args[1]
set <- as.numeric(args[2])
nrep <- as.numeric(args[3])
combo1 <- eve::edd_combo_maker(
la = c(0.6),
mu = c(0.1),
beta_n = c(-0.12, -0.10, -0.08, -0.06, -0.04, -0.02, 0),
beta_phi = c(-0.04),
age = c(10),
model = "dsce2",
metric = c("pd"),
offset = c("simtime")... |
2430cc6a6d0c6b949d1fa2e25136fc9effff139c809fd5d755c76197447799cf | R | 1,208 | 38 | # Set directories
DATA.DIR <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(DATA.DIR)
# Load files for each genotyping chip
library(dplyr)
mega <- read.delim("MEGA_Chip.bim", header=F, quote="")
neur <- read.delim("Neuro_Chip.bim", header=F, quote="")
# Load call rate for all loci on each chip
cr.mega <-... |
2bc17953b02622818738c09093eee2fd0b670f6274b2bed700dd48b4099bd55c | R | 1,209 | 50 | library(pROC)
data(aSAH)
context("ci.formula")
test_that("bootstrap cov works with smooth and !reuse.auc", {
skip_slow()
if (getRversion() > "3.6.0") {
suppressWarnings(RNGkind(sample.kind = "Rounding"))
}
for (pair in list(
list(ci, list()),
list(ci.se, list(boot.n = 10)),
list(ci.sp, list(b... |
1bbecc754ded785acb3edf2fbb7484543d099da8f731ab8eeaacd54c91836b5c | R | 1,210 | 29 | if (!requireNamespace("here", quietly = TRUE)) install.packages("here")
here::i_am("stats/lme_models/_setup.R") # anchor the repo root
# Prefer sum-to-zero contrasts for ANOVA-style F tests
options(contrasts = c("contr.sum", "contr.poly"))
# Base packages used across scripts (+ the missing ones)
pkgs <- c(
"dplyr"... |
11467a25de278f6d3fe54aa4a3c5d3f7300c6c2addf4ea509ead7f1909e37854 | R | 1,216 | 43 | args <- commandArgs(TRUE)
name <- as.character(args[1])
if (!dir.exists(name)) {
dir.create(name)
}
setwd(name)
if (!dir.exists("DDD_FREE_TES")) {
dir.create("DDD_FREE_TES")
}
dir.create("DDD_FREE_TES")
setwd("DDD_FREE_TES")
dists <- list(
list(distribution = "uniform", n = 1, min = 1.0, max = 1.5),
list(... |
f0ce15b015cee51051f2bed4d4afb0408ec41a136a4cce68e9018c300de13fcc | R | 1,217 | 31 | rm(list=ls(all=TRUE))
library(data.table);library(dplyr);library(stringr)
source('/home/lorincn/isilon/Cheng-Noah/software/corefunctions/functions.R')
##############################################################################
<GWAS filepath (w/ extension) here>
<LD reference (w/o extension) here>
savedir='/home/lor... |
8bafd35e605cef55a0cb5f6bd42473a98b2654b0c34e1ea3268fcb63a5724dfa | R | 1,221 | 25 | #' miReact code dependencies
#' @description This constitutes some of the core miReact code, which bayesReact depends on, obtained from https://github.com/muhligs/miReact (19/12/2023).
#' For more information on miReact, please see their publication: https://doi.org/10.1038/s41598-021-88480-5 (Nielsen et al., Sci Rep, ... |
a3dcece87c94c2eb443460be5c221c2e8e27940b3602e3680346b7588f6aa38e | R | 1,221 | 34 | # In this script we will be gathering pathology diagnosis
# terms to select NBL samples for downstream NBL subtyping
# analysis and save the json file in nbl-subset folder
# Detect the ".git" folder -- this will in the project root directory.
# Use this as the root directory to ensure proper sourcing of functions no
... |
cf7cf7dee692652bcaf91dec4aafa3a9d6534cb0ded13eed222ceb85e61997e3 | R | 1,228 | 40 | # paris_clustering.R
# 1. load libraries & point reticulate at your conda env
library(Seurat)
library(igraph)
library(reticulate)
#Install scikit-network if needed
reticulate::py_require("scikit-network")
###From Seurat object
# 1. load your Seurat object or the adj matrix
# (replace with your actual path)
adj <- S... |
3a7e5d3b93306586854260da53fefd56cee3e2ab16e2dc702702c2d34cedd59c | R | 1,229 | 97 | ---
title: "Lk single cell analysis"
output: html_notebook
---
run once for installation:
```{r}
library(devtools)
devtools::install_github(repo = "hhoeflin/hdf5r")
devtools::install_github(repo = "mojaveazure/loomR", ref = "develop")
devtools::install_github(repo = "aertslab/SCopeLoomR")
```
```{r}
library(lo... |
6697165925a1a453ba0bc13ac3f948c239c82d51d71a3e9a3f0cd9c269f99398 | R | 1,230 | 29 | ar1=function(n,rho=0.9) rho^toeplitz(0:(n-1))
tr=function(x) sum(diag(x))
anova_mugent=function(chisquares,LDlist,p) {
# does NOT all LD matrices are the same across populations
chisquares=c(chisquares)
m=length(chisquares)
R1=matrix(0,nr=m,nc=m)
for(ll in 1:p) R1=R1+LDlist[[ll]]^2; R1=R1/p
D=diag(sqrt(2*p)... |
7e503c293f7f85f9a083a005847d3b1e99f68e1a7028c3640c8881b5c33e4711 | R | 1,230 | 36 | #Purpose: Draw a density plot indicating minimizer density across a chromosome
#Apply hard masking cutoff and see how it affects minimizer distribution
#Assumes a file called "minimizers.txt" containing minimizer locations on a contguous sequence
library(data.table)
library(plyr)
args <- commandArgs(trailingOnly = TR... |
7f6055357095b7f7121acc44608a93db2655ac23bf81e2cc6fd56dc18b8dc3e5 | R | 1,231 | 37 | ar1=function(n,rho=0.9) rho^toeplitz(0:(n-1))
tr=function(x) sum(diag(x))
## MuGenT
mugent=function(Z,ldlist) {
# can actually be general for multiple populations
Z=as.matrix(Z)
p=ncol(Z);m=nrow(Z);j=rep(1,p)
stat=c(t(j)%*%(t(Z)%*%Z/m)%*%j)
EZ=t(j)%*%diag(ncol(Z))%*%j # under H0
Kj=kronecker(t(j),t(j))
VZ... |
0dd679ec077004f3947d245dec9e3cc187b8914624ef464c2a852197878bbd99 | R | 1,232 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
17daac63872e8531d6907490c178c4f7763cc41e537e1e600532a2bed9869f0f | R | 1,232 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
3c55cb88af4cce33a952ce332a6716f491fd59646762eccec95efe59e4b34666 | R | 1,232 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
c77bf86d0c654f28625e771f0b5130f813115b2a6ca17b02a24a60d631061585 | R | 1,232 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
f60149ed7ea8a41557bb722a061c323a61381eaa220cbe602ff63c9c8fdba854 | R | 1,232 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
0c99d5534aa3984f86c693f005350de4620a77b7ad29fd6c9ab3da76b537ebc3 | R | 1,233 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
32d5674822852cc1b9c62b3d5454d08a82dafda7bbdbd6a50a2cc2abf641d0e6 | R | 1,233 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
3d7c3f4b7f7c52c7322e7b4a25d2670f7adb7671d9734f9724eb9807500fc4f1 | R | 1,233 | 38 | # to perform lmm
setwd("/Volumes/IqraMacFmri/visTac/fMRI_analysis/code/betaExtraction/stats_R")
library(openxlsx) # import excel file
library(reshape2) # reshape data
library(ggplot2) # plots
library(lmerTest) # linear mixed model
library(emmeans) # multiple comparisons
donnees <- read.xlsx("betaVal_sphereRoi_Tml_c... |
bd253280a8b44e84cfafa42d032b3d7fe89ecee9b17d9590af951dbb8b0f968b | R | 1,233 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
c7a14c3db8b41f3a5782d99ce259b5474b95ca78851e5bc4aef08151186c70b9 | R | 1,233 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
d0992a5b07cadc2673048819b4b3effbb6ffc490f85547753310abe581307baa | R | 1,233 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
dc3f1a83b23fd5022e270cc92472e1264c5e40d01b4264fc9a97980ce4c06486 | R | 1,233 | 43 | createFolds <- function(z, k = 3) {
s <- sample(1:k, length(z), replace = TRUE)
aa <- sapply(1:k, function(x) which(s == x), simplify = FALSE)
return(aa)
}
library(MASS)
cross_glm <- function(inputData, k = 3, equation)
{
y <- inputData[, 1]
x <- inputData[, -1, drop = FALSE]
folds <- createFolds(y, ... |
ee9fbb6983a7805febf6f782086789c961cb058795945ab763ca352fa45fa046 | R | 1,249 | 42 | ##-------------------------------------##
## COLOURS TAB ##
##-------------------------------------##
tab_COLOURS <- tabItem(
tabName = "Colours",
textOutput(outputId = "session_id"),
sidebarLayout(
sidebarPanel(width = 4,
selectInput(inputId = "... |
00b2e1d09ca722829e97ad360165d6ddf2f7d397310857ec376257e1936e59ef | R | 1,250 | 56 | #' Help function to check if suggested libraries are installed when required.
#'
#' @author Klev Diamanti
#'
#' @param x A character vector of R libraries.
#' @param error Boolean to return error or a boolean (default).
#'
#' @return Boolean if the library is installed or not, and an error if
#' `error = TRUE`.
#'
#' @... |
3578179d1c1b6d094bfa454e3b98b88765ff775480dd7541a622452ee18fa541 | R | 1,252 | 27 | # Helper function to check whether Rslamdunk libraries are available
# Install if libraries are not available
# Copyright (c) 2015 Tobias Neumann, Philipp Rescheneder.
#
# This file is part of Slamdunk.
#
# Slamdunk is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General... |
9d7c927f298d2b872358a95c10567b6868f2218c9a9c87d1c09b8eb916e26148 | R | 1,253 | 27 | varImpPlot <- function(x, sort=TRUE,
n.var=min(30, nrow(x$importance)),
type=NULL, class=NULL, scale=TRUE,
main=deparse(substitute(x)), ...) {
if (!inherits(x, "randomForest"))
stop("This function only works for objects of class `randomFo... |
c0280306d630538018a9b6326fcb6a406b9a801328f4c7bec94c35353072479d | R | 1,254 | 41 | #' Load intensity data in R from tabix file
#'
#' A function to lead the snps data from the tabix indexed intensity file.
#'
#' @param cnv one line data.table in the usual cnv format
#' @param samp one line samples file in the usual format
#' @param snps the snps file for PennCNV, as data.table
#' @param adjusted_lrr l... |
8c4cabcc328c68b36c569a9037256466bd38853b969de46285503d882ac3c7c3 | R | 1,255 | 38 | #' Monte Carlo Integration
#'
#' This internal function allows you to integrate over a half plane in the joint space of independent weighted chi-squares
#' @param lam eigenvalues of positive-definite LD matrix
#' @param niter number of Monte Carlo replicates used to approximate integral
#' @param alpha type I error rat... |
296377a4d26ab3c71a2281767a0f21e46fd3079c6bacfd605fa780990f19925a | R | 1,259 | 35 | ## Example mutli-patient script
library(LQT)
########### Set up config structure ###########
pat_ids = paste0("Subject", 1:45)
lesion_paths = list.files('/Users/JaneGoodall/Study/LesionMasks',
full.names = TRUE)
parcel_path = system.file("extdata","Schaefer_Yeo_Plus_Subcort",
... |
4cece35d87a02836108dcd741a02f8cb4b68e8c123731c43ecd62859e307b1fa | R | 1,262 | 52 |
require("BiocParallel")
# accept a input folder, a sample ID file, and a output folder
# and a core number and then perform trimming for each file
args = commandArgs(trailingOnly=TRUE)
bash_script=args[1]
input_folder=args[2]
sample_ID=args[3]
output_folder=args[4]
core = as.numeric(args[5])
cat("script: ", bash_... |
b2759edaf95bdeb7e7f057149c99f23181e3da2618c5afac2376151be8a3800c | R | 1,267 | 34 | #' @title Create Dockerfile
#' @description Create a dockerfile to build a docker image
#' @param path Path where to create Dockerfile
#' @return Does not return anything. Writes a Dockerfile to current working directory or path specified.
#' @author Roy Francis
#' @importFrom readr write_file
#' @export
#'
make_docker... |
b02f0c80c70025c2840768a7d193b9a35b77b38f6f79496f433655a2ac8ed100 | R | 1,272 | 38 | library(lightgbm)
# Load in the agaricus dataset
data(agaricus.train, package = "lightgbm")
data(agaricus.test, package = "lightgbm")
dtrain <- lgb.Dataset(agaricus.train$data, label = agaricus.train$label)
dtest <- lgb.Dataset.create.valid(dtrain, data = agaricus.test$data, label = agaricus.test$label)
valids <- lis... |
898bc4b79473afa695450951359a4c476ce912cf682b3843710ad99f30329852 | R | 1,276 | 43 |
# should be deflated for large p and small m
# should be inflated for large m and small p
alpha=0.05
at=function(alpha,meff,p) 1-(1-alpha^p)^meff
at(alpha=0.05,meff=30,p=5)
meff=1:100
ps=1:3
plot(meff,meff,type='n',ylim=c(0,1),xlab='effective number of independent SNPs',ylab='Type I error level',yaxt='n')
axis(side=2,... |
4a6162238bc88f74619eff9acee0e2009144af4b8c19d01fd27ff8a8ba6407dc | R | 1,283 | 53 | ---
title: "Seq QC table for manuscript"
author: "Ryan Corbett"
date: "2025"
output:
html_notebook:
toc: TRUE
toc_float: TRUE
params:
release: v15
---
This script adds the `rna-dna-qt-stats.tsv` data file as a supplemental table for the OpenPedCan manuscript.
Load packages
```{r setup, include=FALSE}
l... |
a159df2c076866af37943e004f1f482579ef8144b1e8dde57abe7debaf599cd8 | R | 1,288 | 43 | # Make up some data
# 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)
# Total numbers of cells per sample
numcells <- c(1000,1500,900,1200)
# Generate cell-level vector for sample info
biorep <- rep(c("s1","s2","s3","s4"),numcells)
... |
bafbc2faa09c33949a863a75a333e24758744599820dda60ccfb237d5e9f74e3 | R | 1,290 | 56 | context("Making plots")
library(MOFA2)
test_mofa2 <- load_model("test_mofa2.hdf5")
# Data plots
test_that("plot data overview works", {
expect_silent(p <- plot_data_overview(test_mofa2))
})
test_that("plot data heatmap", {
expect_silent(p <- plot_data_heatmap(test_mofa2, view = 1, factor = 1, silent = TRUE))
})
... |
4d944a31c03a05886b7d6f96a4fc48efff8b2393036dc72de0cdcbb61706024b | R | 1,296 | 25 | library(MOFA2)
# An explicit pin is passed throughout so these keep passing when .mofapy2_version is bumped.
test_that("matching and patch-level versions let training proceed", {
expect_silent(.check_mofapy2_version("0.7.3", "0.7.3"))
expect_message(.check_mofapy2_version("0.7.4", "0.7.3"), "patch release ahe... |
565e84e8a822bd0b64918e7b372129f26cda5bb65594e3480227f99a299d1cd7 | R | 1,296 | 33 | # The working directory is the directory that contains this test R file, if this
# file is executed by testthat::test_dir
#
# testthat package is loaded, if this file is executed by testthat::test_dir
context("tests/test_collapse_name_vec.R")
# import_function is defined in tests/helper_import_function.R and tested in
... |
80bf1ae5ad7931a13e95cc4278a34a1c2abe4591455621976eb5dc7b49f09aab | R | 1,300 | 47 | ## code to prepare internal dataset goes here
## based on https://r-pkgs.org/data.html#sec-data-sysdata
# Specifications for top matrix of Olink wide format data sets ----
olink_wide_spec <- dplyr::tibble(
data_type = c(
"NPX",
"Ct",
"Quantified"
),
has_qc_data = c(
TRUE,
FALSE,
TRUE
)... |
b1cf8dc0be62a2f723996a149244af27b78ed05802ad330a19dad4d8b115e93c | R | 1,305 | 38 | #' Extract the CLR-transformed values from the ALDEX2
#' @description Microbiome data is compositional. When compositional data is examined using non-compositional methods, many problems arise.
#' Performing a centered log-ratio transformation is a reasonable way to address these problems reasonably well. This particul... |
faba9ecc081f36885490713b7386604a710ac3d726d7cb6ae3d9f88a8291c1e8 | R | 1,311 | 43 | ##-------------------------------------##
## NORM TAB ##
##-------------------------------------##
tab_VAREXPLAINED <- tabItem(
tabName = "Variance Explained",
textOutput(outputId = "session_id"),
br(),br(),
tabsetPanel(type = "tabs",
sidebarLayout(
... |
5a77cc239fe9a96e90d29aeff47124911dfb6b892ad7893f4ace3a0732de3844 | R | 1,312 | 42 | args <- commandArgs(TRUE)
name <- as.character(args[1])
beta_n <- as.numeric(args[2])
batch <- as.numeric(args[3])
index <- as.character(args[4])
if (!dir.exists(name)) {
dir.create(name)
}
# Get the current precise time
current_time <- Sys.time()
# Convert the current time to a numeric value
time_numeric <- as.n... |
2282f44ca95145aebf9e015ef9f61469c675129f6f7bcd5a57ca723bac418981 | R | 1,314 | 44 | tr=function(x)sum(diag(x))
ar1=function(n,rho) rho^toeplitz(0:(n-1))
xvegas=function(z,R,Z_xqtls) {
z=as.matrix(z);Z_xqtls=as.matrix(Z_xqtls)
m=nrow(R);p=ncol(Z_xqtls)
L=matrix(0,nrow=nrow(Z_xqtls),ncol=nrow(Z_xqtls))
for(i in 1:p) L=L+Z_xqtls[,i]%*%t(Z_xqtls[,i])
L=L/sqrt(m*p)
mu=tr(R%*%R)
variance=2*tr(... |
b3265f68d4e518cd9460dae562610df891822656f6bda88c0ce11d71c20888fa | R | 1,316 | 75 | #' Help function checking if a variable is a vector of booleans.
#'
#' @inherit .check_params params author return
#'
#' @keywords internal
#' @noRd
#'
check_is_boolean <- function(x,
error = FALSE) {
# check if input is a boolean vector
if (!rlang::is_logical(x)
|| any(rlang::ar... |
f69e7ddb901bcfeba9bebd23f5b7fe30a1374ddbc5e2b1bd1253bd59a834384a | R | 1,316 | 42 | args <- commandArgs(TRUE)
name <- as.character(args[1])
beta_phi <- as.numeric(args[2])
batch <- as.numeric(args[3])
index <- as.character(args[4])
if (!dir.exists(name)) {
dir.create(name)
}
# Get the current precise time
current_time <- Sys.time()
# Convert the current time to a numeric value
time_numeric <- as... |
322ed66bc8b054a1a2d9a3e47f669b9b582eda39f9fc84249e9552428f3de87e | R | 1,318 | 48 | #' @importFrom SeuratObject as.Seurat
#' @export
#' @note See \code{\link{as.Seurat.liger}} for scCustomize extension of this generic to converting Liger objects.
#'
#'
SeuratObject::as.Seurat
#' @importFrom SeuratObject WhichCells
#' @export
#' @note See \code{\link{WhichCells.liger}} for scCustomize extension of thi... |
431f042ee62c0b5856ad45343ad103742278c7b0204fbc46c14cbaa84661bd8f | R | 1,319 | 33 | ##-------------------------------------##
##### REPORT #####
##-------------------------------------##
tab_REPORT <- tabItem(
tabName = "Report",
textOutput(outputId = "session_id"),
tabsetPanel(type = "tabs",
tabPanel("Report",
sidebarLayout(
... |
737108d9e56b944342305c3775dc5f57d920292fd301ce695b50ceb946b8fa08 | R | 1,320 | 53 | # Behavioral GLMM specifications for Mano et al. (2026)
#
# Required packages:
# install.packages(c("lme4", "lmerTest", "readr", "dplyr"))
library(lme4)
library(readr)
library(dplyr)
# USER SETTINGS
data_file <- "path/to/behavior_for_analysis.csv"
dat <- read_csv(data_file, show_col_types = FALSE) |>
filter(condit... |
f9ca2be82c5c752a68172016900be402cd512a66ab6844764a4079119ab09f63 | R | 1,321 | 32 | library(RCircos)
if (!require("RCircos")) install.packages("RCircos")
library(RCircos)
getwd()
setwd( "/data/nas1/liuyiding_OD/project/01_project_147/10_Circos")
bio_markers <- data.frame(
Chromosome = c("chr1", "chr2", "chr8", "chrX"), # 确保染色体格式正确
chromStart = c(1000000, 5000000, 11300000, 2000000),
chromEnd = ... |
46346acd0a024601861d8ae8c7eda57bbf7aed2936b677a4e9a1e7ff1d9d70dc | R | 1,322 | 65 | ---
title: "chipseeker"
output: html_document
date: "2023-06-06"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(ChIPseeker)
library(TxDb.Mmusculus.UCSC.mm10.knownGene)
library(rstudioapi)
library(dplyr)
```
```{r}
#importing all files in the directory
samplefiles <- list.files... |
a8f1ec6395f492d5b389ce05c6d7e511014d7b1569dd814103095bacc3597d79 | R | 1,325 | 48 | ##-------------------------------------##
## BEC TAB ##
##-------------------------------------##
correct_be <- function(countMatrix, method, batch_label1, batch_label2, keep_biological, covariate){
if (method == "limma"){corrected_mat <- correct_limma(countMatrix,
... |
138ab5de5859043abcc6016db37f5bbe52986ee7a4e591610e9b49eb5b11ca8b | R | 1,326 | 49 | ##-------------------------------------##
## COLOURS TAB ##
##-------------------------------------##
make_show_color_plot <- function(df){
text <- df$colors
print(text)
ggplot(df, aes(x = group, y = add, fill = group, text = paste(colors))) +
geom_point(size = 20, colo... |
bed12ae25cb34ac2c29e34f4c65b82c8d9660cd859f9a253f3e60b9add5ad2b3 | R | 1,327 | 71 | # data ----
npx_df <- npx_data1 |>
dplyr::filter(
!grepl(pattern = "control",
x = .data[["SampleID"]],
ignore.case = TRUE)
)
check_log <- check_npx(npx_df)
# statistics ----
ttest_results <- olink_ttest(
df = npx_df,
check_log = check_log,
variable = "Treatment",
alternative = ... |
8094510b9ce4a4fd67457b504c86ca7a8af74a184a8dda8b0a491e58dad80cda | R | 1,330 | 38 | # pROC: Tools Receiver operating characteristic (ROC curves) with
# (partial) area under the curve, confidence intervals and comparison.
# Copyright (C) 2011-2014 Xavier Robin, Alexandre Hainard, Natacha Turck,
# Natalia Tiberti, Frédérique Lisacek, Jean-Charles Sanchez
# and Markus Müller
#
# This program is free soft... |
92f367db56901330753cdd88f8ce78f12c353dde7f6f9df8f785665924e9b743 | R | 1,333 | 40 | ################################################################################
# Create an image of a gene expression 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 is used... |
1d5e70719c47dcb2af88827766ee025ca293a28b7a9c172349008e976065765a | R | 1,335 | 17 | #' Subset of liver cancer data from the Human Cancer Genome Atlas
#'
#' The test data contains fold-change ranked genes from the Human Cancer Genome Atlas (TCGA; n = 20), and matching motif counts and probabilities from human 3' UTR sequences.
#' The data is generated from publicly available mRNA expression data and nu... |
301209f26db98a4c84d72dad70153fb401205f6196466d720a8558a1afc031c4 | R | 1,341 | 31 | #' Perform pairwise PERMANOVAs as a post-hoc
#' @export
#'
pairwise_aitchison_PERMANOVA <- function (clr.samples, groups, relevant.comparisons, adjust.p = T, adj.method = "holm" )
{
out_df <- data.frame()
for (number in 1:nrow(relevant.comparisons)) {
relevant.groups = groups[groups == relevant.comparisons[numb... |
768ceb2d6053b63597e28c5ca94d84a698abb1cf0fe7e3d49be5ac128f4740f1 | R | 1,343 | 50 | ---
title: "QC EFO MONDO Map file"
output: html_notebook
---
## Load libraries
```{r load_libraries}
suppressPackageStartupMessages({
library(tidyverse)
})
```
## Read efo-mondo-map.tsv and histologies file
```{r read the two files}
root_dir <- rprojroot::find_root(rprojroot::has_dir(".git"))
integrate_dir <- fil... |
fbff0db2466936e36b250188f8b1eb84f099cb3beef98381a3923045175674bc | R | 1,343 | 44 | #.libPaths(c("E:/R_packages", .libPaths()))
if (!requireNamespace("rstudioapi", quietly = TRUE)) {
install.packages("rstudioapi")
}
library("rstudioapi")
cur_dir = dirname(getSourceEditorContext()$path)
extdata_source <- normalizePath(file.path(cur_dir, "..", "..", "..", "data", "lqt", "extdata"),
... |
bdc2adc7b3e592e8a0b5b4a70e7aedcc4394bfcf3484254cf190f3619f5eed33 | R | 1,344 | 44 | data<-read.table("results_for_r_sess_paired_side.csv",header=TRUE,sep=",",dec=".")
data$rat<-as.factor(data$rat)
data$time<-as.factor(data$time)
data$behavior<-as.factor(data$behavior)
data$trial<-as.factor(data$trial_ID)
data$sess<-as.factor(data$sess)
data$recording<-as.factor(data$side)
library(lme4)
libra... |
1fe5a63a7fb0e2f1200f21a3143a28ea2d2bd9e8dcdd337532aed4f459d6378c | R | 1,346 | 46 | rm(list=ls(all=TRUE))
library(mvnfast);library(mvnfast)
source('simulations/mugent/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=c(1.5,1.5,1... |
0547a02158e98f5eac3d452497fa280f94ee62131e7b3a0dae2b79a75fed628a | R | 1,348 | 41 | ################################# Fig.1j
#Read in the reduced_all R data file first
DefaultAssay(reduced_all) <- "RNA"
Lung_VNG <- subset(x = reduced_all, seurat_clusters == 6)
nonLung_VNG <- subset(x = reduced_all, subset = Kcng1 == 0)
gene_list <- read.csv(file = "Customized directory/Manuscript.Wei.et.al/Raw_Txt/D... |
6cbd85fbe4fc4d6955760fb2c0a0098eb4d4b4f71e1946faba1e83f5a38223b1 | R | 1,354 | 50 |
# 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)
# Total numbers of cells per sample
numcells <- c(1000,1500,900,1200)
# Generate cell-level vector for sample info
biorep <- rep(c("s1","s2","s3","s4"),numcells)
# Numbers of cells ... |
9d8d0b6ffa8638b9e6e558a857a4ca23006d22a56d85908fe494d320452095ca | R | 1,359 | 31 | ## ---- stats/learning_models/_setup.R ----
if (!requireNamespace("here", quietly = TRUE)) install.packages("here")
here::i_am("stats/learning_models/_setup.R") # pins root to the repo that contains this file
# 1) Packages (install on first run if missing)
pkgs <- c(
"rstan","brms","posterior","tidyverse","dplyr",... |
f92b9f297678f3a6950bb3c4d9a6fd7aa658c59ad3a8d90a5d2ff3a456ecd2fd | R | 1,359 | 38 | #'---
#' title: Calculate PSI values
#' author: Christian Mertes
#' wb:
#' log:
#' - snakemake: '`sm str(tmp_dir / "AS" / "{dataset}" / "02_PSIcalc.Rds")`'
#' params:
#' - setup: '`sm cfg.AS.getWorkdir() + "/config.R"`'
#' - workingDir: '`sm cfg.getProcessedDataDir() + "/aberrant_splicing/datasets/"`'
#' threa... |
e96b3d2f79abea525357f3411daada4e32b55f807859d76b050e7e98e2ada4af | R | 1,364 | 49 | library(raster)
library(sf)
library(rgeos)
library(dplyr)
library(tidyr)
library(sp)
# grid function from https://strimas.com/post/hexagonal-grids/
make_grid <- function(x, type, cell_width, cell_area, clip = FALSE) {
if (!type %in% c("square", "hexagonal")) {
stop("Type must be either 'square' or 'hexagonal'")... |
413802ec16a5225afbea074abf768ebbd4645473d84677c022a376c0acddbd93 | R | 1,368 | 28 | #' Cell type proportions from single cell PBMC data
#'
#' This dataset is from a paper published in PNAS that looked at differences in
#' immune functioning between young and old, male and female samples: \
#' Huang Z. et al. (2021) Effects of sex and aging on the immune cell
#' landscape as assessed by single-cell... |
45c4537d4ddef5b41b40133af3a335e6abe46bf4d63a19e9cf51a0084cd9219a | R | 1,370 | 58 | rm(list=ls())
## COMMON LIBRARIES AND FUNCTIONS
source("100.common-variables.r")
source("101.common-functions.r")
source("300.variables.r")
source("301.functions.r")
## SCRIPT SPECIFIC LIBRARIES
##
##
library("doSNOW")
library("foreach") ## loaded by doSNOW
## SCRIPT SPECIFIC FUNCTIONS
## SCRIPT CODE
##
##
if( 1 ) ... |
479225bbf4de54972ef4dc174cdd29b44dfa1dd1754691b2a556ed7c725ac0c8 | R | 1,371 | 40 | library(readr)
library(dplyr)
library(stringr)
library(openxlsx)
## set directories
root_dir <- rprojroot::find_root(rprojroot::has_dir(".git"))
analysis_dir <- file.path(root_dir, "analyses")
output_dir <- file.path(root_dir, "tables", "results")
output_file <- file.path(output_dir, "SuppTable2-Modules.xlsx")
# 1. ... |
e757423223a82dc32eda338c981b2c64325518fc67b78fd1cfdf6ae2b140c1e7 | R | 1,371 | 57 | library(MOFA2)
filepath <- system.file("extdata", "model.hdf5", package = "MOFA2")
test_mofa2 <- load_model(filepath)
# Data plots
test_that("plot data overview works", {
expect_silent(p <- plot_data_overview(test_mofa2))
})
test_that("plot data heatmap", {
expect_silent(p <- plot_data_heatmap(test_mofa2, view = ... |
d1edbe2dfa2e1691871b98ba18c4cce5f21f03d822d237a548551c4c1347696c | R | 1,373 | 36 | # Efficient training means training without giving up too much RAM
# In the case of many trainings (like 100+ models), RAM will be eaten very quickly
# Therefore, it is essential to know a strategy to deal with such issue
# More results can be found here: https://github.com/lightgbm-org/LightGBM/issues/879#issuecommen... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.