sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
f575f2a9b2a9da4078ea96970dfe696fe53dc718e13adf12c383f122677bef35
R
1,098
35
library(LSD) library(data.table) ############################# ##Species-specific analysis## ############################# pdf("Fig2B.pdf") a=read.delim("pM10Kb_1KTest/predictions.txt") actual=read.delim("57epigenomes.median_expr.txt",F) colnames(actual)=c("Gene","UnscaledExpr") actual$UnscaledExpr=log10(actual$Unsca...
a0a5a224ea3a338b2f90b07899341a0fd48b491771078e9ce2b6b17a3656ce3c
R
1,101
39
--- title: "Upload a dataset" #runtime: shiny_prerendered output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) #library(shiny) ``` ### Example A dataset with two conditions and three replicates each would look like this: ```{r tmp, echo = F} m <- matrix(rnorm(60, 200, 50), 6, 6) r...
8fce114e24da5265b90712de2fccc1e2b8f1265e871508d992639c4b65b37791
R
1,105
38
#Convert seu object to anndata object library(withr) library(Seurat) library(reticulate) library(SCP) #Not with conda env activated seu <- readRDS("directory/Consensus_broad_high_res_annotated_seu.rds") Idents(seu) <- seu$Biological_replicate min <- min(table(seu$Biological_replicate)) #Min = 4671 #Downsample func...
0e1499219275ccffd5d793f4e1590ef344469eb0f2871b556e7d0b65c9bd253a
R
1,109
32
#====================================================== # annote a variant to the nearest gene #====================================================== find_closest_gene <- function(chr, bp, g, chrom_col="chr", pos_col="value", ...
ba860a6bceb23c8831bf8d9f8c573170f08f9cf4b457df6dfbcbff145bef5dfb
R
1,109
25
# File: stepprotocol.R # Author: Zhihua Li # Date: 2016 # Version: 1.0 # # Description: Helper R function to define voltage step protocols. # stepprotocol<-function(holdv, holdt,conv,cont,testv,testt,gapt){ #generic step protocol consisting a holding step, a conditioning step, and a te...
8a921f14d22811bf4398b1b6dbaeb3fd46c353ddb3712909747ffd3cfd5d0d22
R
1,116
32
#' Translation of a covariance matrix #' #' Translates a covariance matrix from one basepoint to another, Formally, #' projects a covariance matrix onto the tangent space at one basepoint, #' transports to the tangent space at the second basepoint, and projects back onto #' the space of SPD marices. #' #' @param x A sy...
24d714ffaa4da9dcc413c44d774bcba1b757a6d3f1ce83f326d6e90e245bfe77
R
1,117
38
#====================================================== # annote a variant to the nearest gene #====================================================== library(data.table) library(argparse) parser <- ArgumentParser() parser$add_argument("-v", "--variant_file", help = "path to file with variant p...
fd0bc76b90d140f8d975fd1350e6ec55680fb5ba99f55400597bae43fbefa273
R
1,119
42
#' Aspirin after Myocardial Infarction #' #' @description #' Meta-analysis on aspirin in preventing death after myocardial #' infarction. #' #' Data example in Fleiss (1993) for meta-analysis with binary #' outcomes. #' #' @name Fleiss1993bin #' @aliases Fleiss93 #' #' @docType data #' #' @format #' A data frame w...
9829299839bc31fe8adc3f2c2b7ad49739fc09dbf096972678ab4ed6e0049fc2
R
1,127
57
library(lme4) library(sjPlot) library(performance) library(ggplot2) library(lmerTest) library(multcomp) library(effects) library(report) # Load the package every time you start R library(palmerpenguins) library(car) library(rcompanion) df = read.csv("\\data\\behavior\\repeated_wordsfinal.csv") colnames(df)...
0528a58d91adb14f73eb4728b47d0174b4cd4d2afe6ea813038b21ea3cec0e24
R
1,134
43
############################################# # # These functions are used to estimate the # duration between peak and the hight after # ETS rss estimation ETSmetrices <- function(rss_rile){ sbj <- stringr::str_extract(rss_rile, pattern = 'sub-[0-9]*') rss_raw <- readr::read_csv(rss_rile, col_nam...
8d7159e17c086011f410c57b9f594b8ca23380920c0a14dbd2d511a6a199ee0f
R
1,135
29
library(ggplot2) library(ggeasy) # 设置频率和时间范围 frequency1 <- 0.1 # 0.1 Hz frequency2 <- 0.03 # 0.03 Hz time <- seq(0, 4 / frequency1, length.out = 1000) # 两个周期,时间从0到4/frequency1 # 计算两个余弦曲线的值 cosine_values1 <- cos(2 * pi * frequency1 * time) cosine_values2 <- cos(2 * pi * frequency2 * time) # 创建数据框 df <...
deb0b9f45cdc17eda4ab70978a8cee78d2ed5e1a476b2d7db117e803b2522d3d
R
1,136
51
library(ppcor) library(progressr) library(foreach) library(fastcluster) # Will be the dataset "wang" or "pbmc" dataset <- commandArgs(trailingOnly = TRUE)[1] output_path <- "output" library(data.table) source("../utils/0-indices.R") expression <- fread(file = sprintf("data/%s-pearson-resid.csv", dataset)) genesymbo...
19d0ac1d08d36f61c887774437caafb5b5c886385a9a59c2df8b34cd6ced5a2e
R
1,141
39
library(dplyr) library(ggplot2) ## set _DEBUG_BANDWIDTH = True (or _DEBUG_START_BANDWIDTH) in resquiggle.py ## tombo resquiggle bandwidth_test_reads/ genome.fasta --processes 8 > band_boundary_tuning.txt dat <- read.table('band_boundary_tuning.txt', header=TRUE) std_bw <- names(sort(table(dat$bandwidth), decreasi...
c9310dbc88d966573849aa3d363acd0fce74b3c9ad14accf21ad70c62afbf54c
R
1,141
43
setwd("E:\\platform-paper\\fig2modules_figs3neurites_1224\\") print(getwd()) #import df df = read.csv("middle_files\\df_183brain_316region_density.csv") #create corr b_num = dim(df)[[1]] r_num = dim(df)[[2]]-1 corr = data.frame(matrix(ncol = b_num, nrow = b_num)) colnames(corr) = colnames(df)[1:r_num+1] ro...
06c2a59584485c2be7ca840aa2b28680a7854eb67946beb078236336fbab53dd
R
1,143
25
library(ggplot2) library(dplyr) # def a function to format decimals in ggplot fmt_dcimals <- function(decimals=2){ function(x) format(x, nsmall = decimals,scientific = FALSE) } # read the table including divergence setwd("/Users/siyuansmac/Desktop/PhD research/Suzukii WGS analysis/dataset.nosync/annotation/Refseq/r...
1c2047371e98a96f3edf4dbd94f0ff6603dc81d43dd729abdcafe6c42bc61f62
R
1,145
29
# loading libraries library(Seurat) # v5.0.3 library(SeuratWrappers) library(patchwork) library(dplyr) library(ggplot2) library(sctransform) library(glmGamPoi) # Load merged object after preprocessing stress.merged <- readRDS("~/Downloads/scRNA/stress_merged.rds") # Visualize transcripts per cell VlnPlot(stress.merge...
924246d1ae3c55ae56b19ff2047f97593974f1874d1474d397b61318ef91002c
R
1,147
34
#=============================================== # Perform PCAiR #=============================================== # mostly taken from here: # https://www.bioconductor.org/packages/release/bioc/vignettes/GENESIS/inst/doc/pcair.html library(pacman) p_load(data.table, GENESIS, SNPRelate) cargs <- commandArgs(trailingOnl...
698d0be41e8c709c3b2b1255d7e258111ab7a548d3245cc4b2391472c372f860
R
1,148
24
#' NIDP annotation data #' #' annotation data for all NIDPs taken from the UKbiobank #' #' @docType data #' @name anno #' @format A data.table with 10 columns and 3935 rows: #' \describe{ #' \item{gwas_phenotype}{character: UKB-derived neuroimaging derived phenotype (NIDP)} #' \item{modality}{character: MRI neuroim...
80df5a7698cea301e684e3792e86ff5938c62c1d8a2f34e16597940e1b7e4c9c
R
1,149
49
library(openbabelR) convertTest <- function(){ smi = "cc1cccc1c" inStr = openbabelR:::istreamFromString(smi) outStr = openbabelR:::ostreamToString() conv = openbabelR:::OBConversion(inStr,outStr) message("setting formats") openbabelR:::OBConversion_SetInAndOutFormats(conv,"SMI","SDF") message("converting") ...
c26607ecb17b64daa0243852bf287c2aada33b26ff7d754db7756a0d8ac52e0b
R
1,152
41
rm(list = ls()) setwd("~/Documents/Analyses/Data/Memory") # Choose data myData = read.csv(file="PatientData.csv" ) # PD patients # Check data head(myData, 10) # LF group myDataLF <- subset(myData, Randomisation.order==1) # Create delta myDataLF$DV <- myDataLF$Memory.task.2-myDataLF$Memory.task.1 # rank data myDat...
b153a70506681debb74fd60ff991c390d76a03b418bd4b88115eab9fbf41f466
R
1,154
42
spd.dimred.congedo <- function(X, k = 2, ...){ n <- length(X) S <- matrix(0, nrow = nrow(X[[1]]), ncol = ncol(X[[1]])) W <- matrix(1/(n^2 - n), n, n) Xisqrt <- lapply(X, isqrtm2) for (j in 2:n) { for (i in 1:(j-1)) { L <- logm2(Xisqrt[[i]] %*% X[[j]] %*% Xisqrt[[i]]) ...
4eff5d4555bc80ef503d46ba2cec8062cb4c07b35f8f60bb9d4341ab2ebc78ed
R
1,159
27
#' mochims__get_reference_id #' #' Get reference id with absolute amino acid residue position. #' #' @param input_dt data.table with id and mut_order columns (required) #' @param position_offset residue position offset (default:0) #' #' @return Reference id with absolute amino acid residue position #' @export #' @impo...
704eae05d82f270b32290fcff4e7b60dc8ebce74e42025f7d097b1aa8579281e
R
1,167
50
spd.mean.p.est <- function(x, p = .5, tol = .01, max.iter = 20){ n <- length(x) k <- dim(x[[1]])[1] phi <- .375 / abs(p) # Initialize mean to mutually commutative case X <- Reduce(`+`, lapply(x, mat.frac.pow, p)) / n X <- mat.frac.pow(X, 1/p) # Input matrices, depending on sign(p) ...
e6a8d81440b5eb7221467a5a8338f772b8fe1f4b342091015d7d423fd8dbd149
R
1,169
33
#!/usr/bin/env Rscript # Load necessary libraries library(argparse) library(data.table) # Setting up Argument Parser parser <- ArgumentParser() # Adding arguments parser$add_argument("-i", "--input", type = "character", help = "Input CSV file name") parser$add_argument("-s", "--snp_column", type = "character", defau...
6ddb46599e8ec33f5dfa6d308596671c893599c05a9b650655ee3db49ec378bf
R
1,170
34
library(data.table) library(latticeExtra) getbest <- function(dir){ files = list.files(path=dir, pattern='.txt', full.names=T) sbtable <- as.data.frame(do.call("rbind", lapply(files, FUN=function(file){ cmd = paste("tail -2", file, "| perl -ne \'@a=split /= /; print $a[1];\'") tmp = t(read.table(textConnection(s...
0e1b0e79772e30ed1c38824254092ea7b1e926083d17d2ff7f9e8dbc27c7cee3
R
1,186
42
#============================ # Make covariate file #============================ library(data.table) library(readxl) library(stringi) rosmap <- as.data.table(read_excel( "/data_global/ROSMAP/greg_20200109/dataset_843_basic_01-09-2020.xlsx")) load('data/rosmap/mypcair.Rdata') n_pcs <- 10 pcs <- as.data.table(mypca...
207a2771716ecef6a80a96108ac5ac26eb4eb436efda1da0c97b1b0b7823e7de
R
1,189
39
NonIter1GFit<-function(x,y){ # non-iterative estimation, ised for parameter initialisation x <- x[!is.nan(y)]; y <- y[!is.nan(y)]; x <- x[is.finite(y)]; y <- y[is.finite(y)]; x <- x^2; y <- y-1; n <- length(x); # minimize absolute deviation S = rep(0,n); S[1]= 0; S[2:n] = 1/2*(y[2:n]+y[1:n-1])*(x[2:n]-x...
35032cc53ee2e0c71ec94a7070ee5bdf12b741b2f464a42735a5837229d2b393
R
1,190
30
# loading libraries library(Seurat) # v5.0.3 library(SeuratWrappers) library(patchwork) library(dplyr) library(ggplot2) library(speckle) # v1.2.0 library(sctransform) library(glmGamPoi) # Loading Seurat object stress.merged.filt.sct.cca.umap <- readRDS("~/Downloads/scRNA/stress_merged_filt_sct_cca_umap.rds") # Creati...
0b80281d8d5a25bcee23272c115098a0a117491c23326134bae0389967c0b934
R
1,195
44
library(tidyverse) set.seed(1234) args = commandArgs(trailingOnly = TRUE) out = args[1] reference_name = args[2] lab_path = args[3] ontology_path = args[4] ontology_columns = strsplit(args[5],...
e46604e852a4fbb84b8c64d638b5a7ad35562e2b12c6ff1840be1e0bc37db49a
R
1,196
48
--- title: "gctb_QC" author: "Gokberk Alagoz, L&G Dept., MPI for Psycholinguistics" date: "`r Sys.Date()`" output: rmarkdown::github_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(data.table) ``` ## ```{r cars} genSEM4gctb = fread("/data/clusterfs/lag/users/gokala/beat-dyslexiae...
0cf34c4f5afa6819954958b49ab2b53494bfbbf2f4c43590d2c1e042eec295b1
R
1,197
50
library(data.table) library(dtplyr) library(dplyr, warn.conflicts = FALSE) library(readr) save.image("debug.RData") merge_data <- function(phenotypes_path, SBP_path, DBP_path, variants_path, output_path) { # Read data in p...
37a08f1ab6979ef756bd186fe8cd19f7401b08c8ca5c3ae6c3ed0a0e3fd61ec0
R
1,197
42
library(data.table) get_results <- function(files) { nfiles <- length(files) file_list <- vector(mode = "list", length = nfiles) for (i in 1:nfiles) { file_list[[i]] <- fread(files[i]) } results <- rbindlist(file_list) return(results) } get_file_paths <- function(prefix, pattern) { paste0(prefi...
625d2f72e00dfac31cc274c13d67bf5d450fbdd549b1569db1bda7fc0e774753
R
1,197
62
library(Seurat) ##samples so that evenly distributed between batches batchSample<-function(seur,batchs="batch",total=100,perturbation="perturbation",maxPerc=.3) { seur<-SubsetData(seur,names(seur@ident)[!is.na(seur@meta.data[,perturbation])]) seur<-SetAllIdent(seur,perturbation) seur2<-seur ret...
21394e069c3ff39a00e25d75e124b410a52be1fab8ee333160a7f634f3be0990
R
1,202
53
# HACK use conda env if/when this gets fixed: https://github.com/conda-forge/r-arrow-feedstock/issues/56 renv::activate() library(ukbtools) library(dplyr) # Save image for debugging save.image("debug.RData") extract_ukb <- function(basket_path, phenotypes_file, basket_n...
44453dda4df385933af40e2332c6dd40dd9072263712eb54221b8c7dd6bb6c19
R
1,203
40
#' mochims_position_class_violins_datasets #' #' Coupling scatterplots for multiple datasets. #' #' @param dataset_names character vector of dataset names (required) #' @param annotations Annotations directory (required) #' @param base_dir Base directory (required) #' @param output_dir Output directory (required) #' @...
2a2e086fdf14545d540deabb28a27f42cf4c971538a01159b80974bec0835569
R
1,208
38
--- title: "topoplots" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r} library(tidyverse) library(akima) library(scales) library(mgcv) library(gridExtra) library(png) library(grid) ``` ```{r} df %>% dplyr::group_by(Eyes, State, Electrode, Side) %>% dplyr::sum...
af59c7f913e46f9d011bbd8d71e9da3faf838b56c43e28323896266f28d353d4
R
1,216
40
#' Barbiturates spectra from `.spc` example files #' #' A time series of mass spectra in a list of `hyperSpec` objects. #' #' #' @name barbiturates #' @docType data #' @format The data sets consists of a list of 5 hyperSpec objects with a single #' spectrum each. They are the first five spectra of the BARBITUATES.SPC...
8e0cfd57bd322513c36ae5ef8ee4582c005e84be987f41e0697b022166043e36
R
1,231
52
generate_new_splits <- function(is_regulator) { # Split genes into three group. Group 3 will be used in both runs and # group 1 and 2 in one run each. This way we can evaluate clustering # performance on group 3. shuffle_idx <- sample( which(!is_regulator), sum(!is_regulator), replace = FALSE ) grp_idx ...
b7e8059a27a14fe85a56327d07acc19942d7b6a692e97f2428f4736694385a33
R
1,233
36
library(Seurat) library(dplyr) library(rhdf5) library(Matrix) # Read in the data h5_file = h5read("./mouse_leukocyte.h5", name="dge") sample.data = t(h5_file$block0_values) colnames(sample.data) = h5_file$axis0 rownames(sample.data) = h5_file$axis1 sample.data = as.data.frame(sample.data) # Make seurat object sample ...
c493c85c246cab87f4acaa3286fcc0a8a9dd50cb9dc1c442416df809b59ff5e4
R
1,233
26
options(stringsAsFactors = FALSE) list.of.packages <- c("dplyr") new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])] if(length(new.packages)) install.packages(new.packages) library(dplyr) argv <- commandArgs(TRUE) sample.1000g = read.table("/data_global/1000g/integrated_call_sa...
0dee47d2ef3192cdcbbac1ff2a3266c625d4cdb94ec030c80f89166374cc3f91
R
1,236
35
#' @name hyperSpec-package #' @title Package "hyperSpec": interface for hyperspectral datasets #' @description #' This package gives an interface to handle hyperspectral data sets in R. #' Hyperspectral data are spatially or time-resolved spectra, or spectra with #' any other kind of information associated with the spe...
91f917b41da6f95f8c7a2786045947bcbfd1274b5c427ddb82bf7beca14ee0a9
R
1,242
40
## ----------------------------------------------------------------------------- ## ## Somatic variant detection in lesional focal epilepsy ## Dictionary of constants and strings ## ## Author: Dr. Christian Bosselmann ## ## Date Created: 2023-09-05 ## ## Copyright (c) Christian Bosselmann, 2023 ## Email: bosselc@ccf.or...
b41fc60392d39e2330af9aa39ed8afad56f7d7f2ea4028d080859df4d44285d3
R
1,243
48
## this is a script for applying PEER on gene expression data ## more detailed info can be found: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3398141/ # load library and data # columns = genes, rows = samples library(peer) l <- read.csv("DA_30_norm.csv") l[1:3, 1:3] l2 <- t(l[-c(1)]) l2[1:3, 1:3] colnames(l2) <- l$...
34ca391a018ec1bc76744d379389cc13ab9cace155a260158fbfa5b3e8a933a8
R
1,244
66
--- title: "Behavioral analyises" output: html_notebook --- This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, #load libraries ```{r} library("dplyr") library('lme4') library('lmerTest') library('arrow') require('flexplot') library("tidyverse") library('stats')...
70d0d4b1b306e710eb5db5040ad0d3a570f5f42b612aa804f511155040017dc6
R
1,254
27
minDPScore <- -250 plotDP <- function(dpDat, tbDat){ for(reg in unique(dpDat$Region)){ regDat <- dpDat[dpDat$Region == reg,] regDat$Score[regDat$Score < minDPScore] <- minDPScore mp <- mean(range(regDat$Score[grepl(reg, regDat$Region)])) if (grepl('fwd', reg)){ tbReg <- ...
6f75c7b3c9da3fa93b50dd288e70239285f503ad8911774497202729d5415618
R
1,256
27
#----Figure_06_A---------------------------------------------------------------- #------------------------------------------------------------------------------- # This is the code for Figure 06 Panel A for the connectivity analysis for # Reinhard and Fukuda et al. 2024 #-------------------------------------------...
d529a33727e90855f6d02211c4c660f6725105bad46003955266cd76e2faf86b
R
1,260
66
--- title: "Behavioral analyises" output: html_notebook --- This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, #load libraries ```{r} library("dplyr") library('lme4') library('lmerTest') library('arrow') require('flexplot') library("tidyverse") library('stats')...
1dc9c2d914e511576605915f7777fb93e4c57d3ecbdabdce77f4027e8f5abac2
R
1,266
16
#' Sentiment analysis with included 3-dimensional affect space consiting of rationality, social impact, and valence. #' #' @description Calls the sentiment function using the built-in dictionary. Note that this function will be slow on its first call, because the dictionary is only loaded if needed. This dictionary cov...
44606321e1dfb62d8e425ed9c558112dc7989ae8b81088112a88ae03982ecb48
R
1,266
42
#' Check if a matrix is symmetric and positive definite #' @param ... One or more numeric matrices #' @param tol Numerical tolerance for checking symmetry and positive definiteness #' @details Function checks whether the matrix \code{x} is symmetric and positive #' definite. Symmetry is evaluated up to an entrywise to...
87c1b41eb2520777805281e9e912661bf3f5774fefe8794612a7de23cf34d4fd
R
1,266
29
source('./scripts/01_Setup.R') setwd("./data/processed/rds") aa= grep("_male_median.rds",list.files(), val=T) aa2= aa for (i in 1:length(aa2)){ fname = file.path('./data/processed/rds/',aa2[i]) readRDS(fname)} all = lapply(aa2, function(x) readRDS(x)) all2= data.table::rbindlist(all) all2= data.frame(all2) delimx...
58012304f3a0356e3ef0216983083a5fd71b739fb6a6f1bddeafe522e683912a
R
1,272
24
args <- commandArgs(trailingOnly = T) filenamex=as.character(args[[1]]) turan_SegNorm = read.table(file.path('./data/processed/', filenamex, 'SegFixed'), header=TRUE, sep="\t") turan_SegNorm$CHR= as.character(turan_SegNorm$CHR) turan_ploidy <- readRDS(file.path('./data/processed/rds', paste0('cell_cn_', filenamex, '.r...
9fa4312b9f8eac8601d88fac20497039070589613f0fc9d3be3674eaccc60c61
R
1,276
43
--- title: "Sequential Knit of DEG files" author: "Jonathan Nelson and Katie Emberley" date: "`r format(Sys.time(), '%d %B %Y')`" output: html_document: toc: yes toc_depth: 3 toc_float: true number_sections: yes theme: bootstrap df_print: paged code_folding: hide highlight: pygments -...
3e35b0aff12c41a6a7268184b085bb5276fa75492841600e7b64c521eed6d960
R
1,277
36
nlshrink_analytical <- function(x) { n <- nrow(x) p <- ncol(x) if (n < 12) stop('Sample size must be at least 12 for nonlinear shrinkage') sample <- cov(x) * ((n-1)/n) eig <- eigen(sample) u <- eig$vectors u <- u[,rev(1:ncol(u))] lambda <- rev(eig$values) lambda <- lambda[ma...
914d18b921b85f02847c83ee41457d353ad43c6afb4e3d1e6ef62937adfb0a43
R
1,282
59
#### Output Modules ##### #### XML export #### dend_to_text_wrapper <- function( R, i, filename ){ fileConn<-file(filename) writeLines(paste("<root>",dend_to_text(R, i),"</root>"), fileConn) close(fileConn) } dend_to_text <- function( R, i ){ me <- R$HCL$merge #Leaf case if(i <0){ index <-...
9577fd70b91841b6a9175a71d8006cdaed14cc8fbce78403346de0744f5e5643
R
1,282
45
library(data.table) library(ordinal) coloc <- fread("data/coloc_results.txt") coloc <- coloc[!duplicated(coloc)] coloc <- coloc[QTL_Source == "ROSMAP"] coloc80 <- coloc[QTL_Type == "mQTL" & PPH4 >= 0.8] npe <- coloc80[, names(table(GWAS_Phenotype))] load("data/cpg.RData") np_cpgs <- coloc80[, QTL_Phenotype] cpg_cols <-...
04c19bf42f20e55c72561ea6faa11e6b682b2ef99ea5a26f73aa3a7ac7d981ad
R
1,286
30
library(RColorBrewer) library(zoo) folder = args[1] species = args[2] for (type in c('gradinput','intgrad')){ #'saliency', 'elrp', 'deeplift' b=list() for(num in 1:10){ #10 folds of CV say(type, num) a=fastread(paste("zcat ", folder, type, '.', num, ".txt.gz",sep='')) a$V2=(a$V2-min(a$V2))/(max(a$V2)-...
e8408b6b612be05abd1aadfbdbe88d7baccff81a947d928371ccf1b5ba2feee7
R
1,290
31
library(data.table) library(latticeExtra) cv_folder = args[1] predfolder = args[2] outfile = args[3] files = list.files(path=cv_folder, pattern='.txt', full.names=T) table <- do.call("rbind", lapply(files, FUN=function(file){ cmd = paste("tail -2", file, "| perl -ne \'@a=split /= /; print $a[1];\'") tmp = t(read.t...
c74e785614f6b433f5255d30b230197023941a769672c9525b694f7418ce3b9f
R
1,292
30
library(data.table) library(ordinal) library(mediation) library(MASS) library(readxl) rosmap_clin <- setDT(read_xlsx("/data_global/ROSMAP/greg_20200109/dataset_843_basic_01-09-2020.xlsx")) rna <- fread("../np_phewas/data/rnaseq/rnaseq.txt.gz") grn_col <- colnames(rna)[grep("ENSG00000030582", colnames(rna))] rna_cols <-...
c2d5103262c836041d551b188ff0d31fec089b2084d7e1d3967befa0014130ce
R
1,296
46
--- title: "Pathways_normalized" output: html_document --- ```{r} library(tidyverse) #library(ComplexHeatmap) library(pheatmap) library(RColorBrewer) #library(reshape2) #library(janitor) library(gapminder) library(viridis) ``` ```{r} setwd("P:/PD_Diabetes/Manuscript_1/RNAseq/TPM_data/modeling") data...
fa31ee8ca22ebfacaaeb7ce407bad5be234d5aacca6b5b9e9f912209d0d09f8a
R
1,300
43
--- title: "Sequential Knit of Microglia Subclustering COde author: "Jonathan Nelson and Katie Emberley" date: "`r format(Sys.time(), '%d %B %Y')`" output: html_document: toc: yes toc_depth: 3 toc_float: true number_sections: yes theme: bootstrap df_print: paged code_folding: hide hig...
34693d0058ebe76345fb005908289135864ef886f727538eed5ec82441a4b7be
R
1,304
36
#' string_levels_var #' #' HELPER #' This function allows returning the unique levels of a factor into a new column and concatenating as a string for plotting. #' This is useful when the factor/categorical variable levels/values are nested in the first element of dataframe. #' #' @param data A dataframe containing the ...
6d9e9e3e6f744518f5e37350542ef27762230e0210a6cf429b470cf7390e320d
R
1,309
42
#' @describeIn DEPRECATED-read.ENVI #' @include DEPRECATED-read.ENVI.R #' @export read.ENVI.HySpex <- function(file = stop("read.ENVI.HySpex: file name needed"), headerfile = NULL, header = list(), keys.hdr2data = NULL, ...) { # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
91c81fceb9989858a2742d6c936010d4ffaf4e35c5749ddf689d151ff49d0c07
R
1,319
37
library(data.table) library(rtracklayer) library(stringi) genes <- rtracklayer::import('/home/lmsh224/downloads/gencode.v40.annotation.gtf.gz') genes <- as.data.table(genes) genes[, gene_id_trunc := stri_replace_all_regex(gene_id, '\\..*', '')] coloc_dir <- 'output/coloc/mega/' coloc_files <- list.files(coloc_dir) g...
a891cfde1bdee5de9bd99635e5ee102abd0535c0b34602b4de9af0177bc2c18b
R
1,319
42
#' mochims_thermo_model_results_datasets #' #' Evaluate thermo model results of multiple datasets. #' #' @param dataset_names character vector of dataset names (required) #' @param literature_free_energies path to literature free energies (required) #' @param base_dir Base directory (required) #' @param output_dir Out...
5b795356f0f6c34b818d798d3e3761c8a2642c14244a52666ce6cbd776e5abad
R
1,320
68
--- title: "Prepare Gene marker data" output: html_document --- This script is used to process the marker genes results of each brin region, to be used as input for the correlation analysis of astrocyte subclusters. ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` Load packages ```{r} library(data.t...
1ead6ba08abbbde6ff120c462e5b96f20d4a91e1b20415bd7b2d3bfe5c637cb4
R
1,324
54
# prep POLMM results for METAL meta-analysis library(data.table) library(argparse) source("code/functions/strip_alleles.R") source("code/functions/make_or_95_ci.R") parser = ArgumentParser() parser$add_argument("-r", "--results") parser$add_argument("--bim") parser$add_argument("-n", "--null_model") parser$add_argume...
baa62be1d5e677c53454bb4d283f1ca221b95c335634fd9f69f5609fb9b44c94
R
1,326
45
# # --------------------------------------------------------------------------- # # Title: Combine RT data files # # Contains: Code to combine individual RT data files into a big dataframe # # Project: DPX-EEG # # Author: Jose C. Garcia Alanis (alanis.jcg@gmail.com) # # Date: Mon Sep 18 12:06:31 2023 # # ----...
0f0331ab543cfb9d40437df44b6e26955152921409b1a424356a7bca52b6a530
R
1,329
48
#' Empty `hyperSpec` object #' #' Empty produces an `hyperSpec` object with the same columns and wavelengths #' as `x`. The new object will either contain no rows at all (default), or the #' given number of rows with all data initialized to `spc` and `extra`, #' respectively. #' #' @aliases empty #' @author C. Beleites...
0560b0b307751f0b3c74cb8f376e165c8c0d7bbbc9d10e19dfaa20705fff8323
R
1,342
32
###Script 10 #Export raw gene expressions for neurons only library(Seurat) library(dplyr) library(SoupX) #get non_neuronal subclass IDs tmp <- readxl::read_excel("output/mapmycells/Allen_metadata.xlsx", sheet = "subclass_annotation") non_neuronal <- tmp[c(grep("NN",tmp$subclass_id_label),grep("IMN",tmp$sub...
56f9960e0e3c0f7e21e40d93942fbed6690d102e1aa383f897a09e8906bcdd2c
R
1,346
46
# Initialize subtype parameter c in function ParameterInitialize() #' @importFrom mclust Mclust mclustBIC .InitialC <- function(Y, q = 7) { init <- list() clust_result <- mclust::Mclust(data = Y, G = q, modelNames = "EEE", verbose = FALSE) init$c <- clust_result$classification init$mu <- clust_result$parameters...
db37450df972fa6ba8415b4f97931f50f838e8f9baabac09c432732bbe8162f4
R
1,347
36
#' mochims__predict_fitness_3state #' #' Predict fitness from folding and binding energies for 3-state model. #' #' @param mochi_outpath path to MoCHI thermo model fit results (required) #' @param phenotype_name phenotype name (required) #' @param folding_energy folding energies for 3-state model (required) #' @param ...
315d2d3122c2d7fea3ccfa24f234e18f9a035f0800f411247df3d79fe4b1b4e5
R
1,348
33
#' Interpolation between two symmetric, positive-definite matrices #' #' Function smoothly interpolates between two SPD matrices \code{x} and \code{y}. #' The interpolation is parametrized by \code{t}, where \code{t=0} returns \code{x}, #' \code{t=1} returns \code{y}, and \code{t=.5} returns the mean of \code{x} and \c...
5bf66e33409f1549217cc1021b93109c56caf7159b4e65e1361e114b9929a311
R
1,352
53
# Function ------------------------------------------------------------------- .droplevels <- function(x, ...) { x@data <- droplevels(x@data, ...) x } #' Droplevels for `hyperSpec` objects #' #' Calls [base::droplevels()] on the data.frame in `spc@data`. #' #' @param x hyperSpec object #' @param ... handed to [b...
7911d21cbe34e09d5c45c66bf9efead97b179f8e1b4c04f9f9e3ef0a3cbf5299
R
1,354
39
--- title: "Upload annotation data" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ## Expected format Uploading annotation data is optional and not necessary to run the analysis. In the annotation file, the first column should include the name of each sample, as they are...
bc1d50f2e6ae421055df6ff90e2b91f197a8aae45a97200df7c29ab3e58b9d94
R
1,355
52
#' mochims__distance_matrix_from_PDB #' #' Residue distance matrix from PDB. #' #' @param input_file path to PDB file (required) #' @param residue_subset subset of residues (default:all) #' @param query_chain query chain (default:A) #' @param metric distance metric (default:'scHA') #' #' @return data.table with minimu...
57d3a688d1e58dbed01b51b58170727cbaa2461568e1032ef115cff3fd69f5a5
R
1,363
66
extrVec <- function(x, varname, levs, first = FALSE) { res <- sapply(x, "[", varname) # if (max(sapply(res, length)) == 0) return(NULL) # if (first) res <- lapply(res, first) # if (length(res[[1]]) == 1) { res <- unlist(res) names(res) <- levs return(res) } # print(res) stop("L...
9fa5f44dbde963284b9a2915a3670a0f817f6e48a7e498e9efc32419fccd102e
R
1,363
60
#bootstrap of the correlation coefficient between the two versions of the measures library(ggplot2) #library(CarletonStats) #library(boot) library(bootcorci) #test normality shapiro.test(ukb_1000$proxyBMD) ggplot(ukb_1000, aes(proxyBMD)) + geom_histogram() #######bootstrap set.seed(123) b_BMD <- bootCor(ukb_300...
cdd9ba339e93278848726ed27ebf4467f12f0012a1835b3ccc9d6a8ed0fc6a30
R
1,364
44
ora <- function(gene, database = NULL, pAdjMethod = "BH") { database <- fread(file.path(database), sep = '\t', header = T) gene <- gene[gene %in% database$UniprotID] if(length(gene) == 0) { return (NULL) } else { # Genes and their counts in input and backg...
c48130b1c6ca8a39f63355cb32e8ecabdc13d7a7582b7f973c160f644ceac39e
R
1,365
51
#' @name DEPRECATED-fix_spc_colnames #' @concept deprecated #' #' @title (DEPRECATED) #' Ensure that the spectra matrix has the wavelengths in column names #' #' #' @description #' These \pkg{hyperSpec} functions are **deprecated** and not maintained any #' more. You should not use these. #' Currently they are p...
e43b3669da3a49c638d0b231b7e0f7c65ffc101333c2d49c1293e3d3e6446f1a
R
1,365
48
# The contents of "read.txt.PerkinElmer.R" read.txt.PerkinElmer <- function(files = stop("filenames needed"), ..., label = list()) { ## set default labels label <- modifyList( list( .wavelength = expression(lambda / nm), spc = expression(I[fl] / "a.u.") ), label ) if (length(files) ==...
2d661f0e06aa2d527cf488aad07cd3e0e2cc2089a6336dbbf3570c6498a4b44e
R
1,376
38
library(zoo) library(GenomicRanges) library(mixtools) file = args[1] fold = args[2] species = args[3] if(species == 'human') expr=read.delim("all_crossvalidated_predictions.txt") else expr=read.delim("all_crossvalidated_predictions_mouse.txt") kmerlen = 1 a=fastread(paste("zcat ", file, sep='')) ids=a[,1] preds = e...
47f64cac2a05fe32c3374d962c7b6cd8b6147eea4c86982565ccfcd602da851a
R
1,377
43
#quantile function for fitdist objects quantile.fitdist <- function(x, probs = seq(0.1, 0.9, by=0.1), ...) { if (!inherits(x, "fitdist")) stop("Use only with 'fitdist' objects") myquantiles.fitdist(f = x, probs = probs, cens = FALSE) } #internal quantile function for fitdist myquantiles.fitdist <- fun...
6148173f0a1b7770bc2047b94dd9f4aba76b5b35a5300e8dd600e5e89ae60310
R
1,377
25
#----02_update_root_ids--------------------------------------------------------- #------------------------------------------------------------------------------- # This is the file for updating root ids of clk neurons and NSC used in the # connectivity analysis for Reinhard and Fukuda et al. 2024 # This script ha...
86a0e6a9b16554d0a757c3e2d98ee1540e23e086299fa68ed012d0d482042274
R
1,379
35
test_that("update.meta resets tau methods when adding cluster", { dat <- data.frame(events = 1:5, N = 5:1 * 100, grp = c(1, 1, 2, 2, 3)) ma1 <- metaprop(events, N, data = dat) ma2 <- metaprop(events, N, data = dat, cluster = grp) ma3 <- update(ma1, cluster = grp) expect_false(ma1$three.level) expect_true(...
fb92f00f925f9e797b8bd012cdf39e793d7cd3a7d48aa8213da6406f59615a7d
R
1,381
38
#===================================================================== # Intake a SAIGE null model and output residuals as phenotype in new # phenotype-covariate data table #===================================================================== library(data.table) library(argparse) parser <- ArgumentParser() parser$a...
745c7ec80198dced1c58935dce01ffb1ab6d73b16517f09b851671f3c96a1645
R
1,387
40
args <- commandArgs(trailingOnly = T) filenamex=as.character(args[[1]]) selectedCells = read.table(file.path('./data/processed/', filenamex, 'analysis'), header=TRUE) analysisType = "mad" analysisID <- "analysis" loc= readRDS(file.path('./data/processed/rds', paste0('location_', filenamex, '.rds'))) loca= loc[loc$CH...
0765b1f7c3549460ca0c13e1a596f71ac684fd7bff0410bf6decaf7f56ddc846
R
1,388
46
#==================================================== # Get SAIGE results files by chromosom and rbindlist #==================================================== library(data.table) library(argparse) library(stringi) parser <- ArgumentParser() parser$add_argument("-p", "--prefix", help = paste0("...
78204f8a38e51b7de4ac3b83f0284bf14d2a01f5acd9b7a71b4f0475895ee45e
R
1,390
42
# Load the stats package (if not already loaded) library(stats) #EA # Define variables N <- 20000 # Total number of genes in the background set K <- 1642 # Number of genes in the gene set of interest n <- 149 # Number of genes in the sample being tested k <- 20 # Number of overlapping genes between the gene...
3d06ac772c0c40d119a3eaa15ab5501ac41a6a0e2baffa7cf4d89e82659feba9
R
1,392
45
library(diffusr) library(matrixcalc) library(MASS) library(Matrix) dir_data <- '../data' dir_sparse_index <- paste(dir_data, 'rwr_mat.txt', sep = '/') adjacency_mat_sparse_index <- read.table(dir_sparse_index, header = TRUE, sep ='\t') row_index <- as.matrix(adjacency_mat_sparse_index$row_idx) col_index <- as.matr...
f3ef25596cc36f4bf2d917c29518ddd451f0a059efe02acdeabd93b7d7622ea5
R
1,393
46
library(diffusr) library(matrixcalc) library(MASS) library(Matrix) dir_data <- '../data' dir_sparse_index <- paste(dir_data, 'rwr_mat.txt', sep = '/') adjacency_mat_sparse_index <- read.table(dir_sparse_index, header = TRUE, sep ='\t') row_index <- as.matrix(adjacency_mat_sparse_index$row_idx) col_index <- as.mat...
4640672ac5bafac9b96e3d5a506782a21f3fde8193d375a238bc78b675b7259c
R
1,400
42
#! /usr/bin/Rscript --vanilla #============================================================== # perform PC-AiR #============================================================== library(data.table) library(GENESIS) library(SNPRelate) library(argparse) parser <- ArgumentParser() parser$add_argument("-b", "--bfile", ...
77f9da574496f314d908496d1318b94c334c2a8d53cc7c0bc0a191611e0f3512
R
1,408
64
# Calcuate meta. # args[1]: The input matlab .mat file. Has: 'TVal','N1','N2','nTests' # args[2]: The name for the output matlab .mat file. # install the following R packages: # # install.packages("metansue") # install.packages("R.matlab") # # More details about 'metansue' R package can be found at # https://www.met...
6764c33a5c8888dfd9addfd316decd7ce69e772c33913a83abf73308ceeb58e9
R
1,410
41
#' @name extract_diffusion #' @title Extract latitudinal diffusion of a crop #' #' @description `extract_diffusion()` extracts the diffusion of a crop by latitude. #' #' @param database A data.frame containing a crop database. #' @param direction A string stating the direction of diffusion (i.e., north). #' @return A t...
b73b1945250839536ff445f3985d1532d143c0eec40ee182e35b6060ea675c3b
R
1,410
46
#------------------------------------------------------------------------------- # ggplot themes for figures #------------------------------------------------------------------------------- #' theme with border #' used for volcano plots my_border_theme = function(){ theme( axis.line.x = element_line(color = "b...
df3cebab4cf8e1715acf867dd73ff2722640fe3f5dcf9bf1a66b74cb83e2711e
R
1,410
49
--- title: "Pupilla" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Pupilla} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#" ) ``` An R package for the processing and analysis of eye-track...
e25d0adbe1b69adfa3b6ad595371c02dbb380e8a4416818fe5707e2137175fcc
R
1,412
53
test_that("metacont gives no weight to non-positive or missing sample sizes", { n.e <- c(10, 0, NA, 20) n.c <- c(10, 10, 10, 20) mean.e <- c(2, 3, 5, 6) mean.c <- c(1, 1, 1, 2) sd.e <- rep(1, 4) sd.c <- rep(1, 4) expect_warning( metacont(n.e, mean.e, sd.e, n.c, mean.c, sd.c), "non-positive values...
e63f887250c2347e0bdbb4c3fa503f26ea8f908f639e5a7c0764309bff896fc4
R
1,413
51
## ----------------------------------------------------------------------------- ## ## Somatic variant detection in lesional focal epilepsy ## This script collects plots and finalizes them for publication ## ## Author: Dr. Christian Bosselmann ## ## Date Created: 2023-09-05 ## ## Copyright (c) Christian Bosselmann, 202...
ef12916cbcf4588aee0b1975e47f091f8d7bdea94b1c6b6261ff1e1aadca6387
R
1,413
57
#### Notes #### # Functions for computing expression specificity #### Usage #### # Step 1: Compute mean expression per tissue (if multiple samples per tissue) ## mean.expr <- mean_expr_per_tissue(expr.matrix, metadata) # Step 2: Compute tau from mean expression ## tau <- compute_tau(mean.expr) #### Sourced functions...
f9eb4fb94dbb0759c4994f5dd3b56a0e4af8f0068914707411669ce0d5c07ed1
R
1,417
35
# Write a celltype specific version of the count table with plasmid and each celltype options(stringsAsFactors = FALSE) args = commandArgs(trailingOnly=TRUE) cond.data <- args[1] ## Tab delimited file with celltype in first column and number of replicates in the second. Should include DNA/plasmid count.table <- args[...
9db6df10d894091d232f073661bf722ebb2a8debc8768453910abacbdf98e4e2
R
1,428
36
library(data.table) library(rtracklayer) library(stringi) # colocalization results pheno <- fread("shared/nacc_rosmap_act_np.pheno") phenos <- colnames(pheno)[3:ncol(pheno)] coloc_list <- vector(mode = "list", length = length(phenos)) names(coloc_list) <- phenos for (i in 1:length(phenos)) { p <- phenos[i] coloc_pa...