sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d39ce6536d04439635767f62d6baca901a54dc92a0cc21d66f3737e0097bd45a | R | 1,773 | 59 | #' @title Matrix runif
#'
#' @description
#' Generates random deviates for multiple hyperparameters in matrix format.
#'
#' @param n number of observations
#' @param lower lower bounds
#' @param upper upper bounds
#' @return a matrix of original hyperparameters
#' @importFrom stats runif
#' @importFrom foreach foreach ... |
abd04f235bd9c035a06aa91761d808232ba23abd15e7649fd1774b9bb3386628 | R | 1,778 | 42 | #' @title K-Folds cross validation index generator
#'
#' @description
#' Generates a list of indices for K-Folds Cross-Validation.
#'
#' @param target Samples to split in K folds.
#' @param nfolds Number of folds.
#' @param stratified whether to apply Stratified KFold.
#' @param seed random seed to be used.
#' @return ... |
2c4dc7ccf59126a193e75dbe982e77818ce044363798b7e485e40c2b0cdb5bb7 | R | 1,796 | 30 | ####################################################################################################
# Add MAGMA module enrichments to GO and DRONC celltype enrichment dataframes #
# #
##############... |
848ac5d86a035d501ef9a695117bb0a2cc731c46f0e08cd316c6e46e9bb8ddf4 | R | 1,801 | 44 | Cross_Validation <- function(LabelsPath, col_Index = 1,OutputDir){
"
Cross_Validation
Function returns train and test indices for 5 folds stratified across unique cell populations,
also filter out cell populations with less than 10 cells.
It return a 'CV_folds.RData' file which then used as input to clas... |
ac6f28d7e8fe24db812a9aeb4af988a2f51cf03e1bdb1dcd69c24c4992334145 | R | 1,808 | 56 |
library(ggplot2)
library(RColorBrewer)
dir.create('Plots')
data1 <- read.table('AllelicReads.allVar.pval.txt', header=T)
data1$label <- factor(data1$label, levels=c('altEnrich','refEnrich','unchanged'))
col_list <- c(brewer.pal(8, 'Set2')[1],brewer.pal(8, 'Set2')[2],'grey')
print(table(data1$label))
# v1
p1 <- g... |
aade71163a17c28a9a90438707555637517b08c0f0154a8ffbd93048dcd2e53e | R | 1,837 | 52 | # context("Testing raw_to_sce")
library(geneBasisR)
### set up inputs
## libs
library(SingleCellExperiment)
set.seed(32)
counts_dir = system.file("extdata", "raw_spleen.txt", package = "geneBasisR")
meta_dir = system.file("extdata", "raw_spleen_meta.txt", package = "geneBasisR")
counts_dir_wrong = "/Users/alsu/Deve... |
e908ba002ed99881ceaac4266101af4d4c4db5e206265504e6104e125853408c | R | 1,837 | 70 | #' @importFrom R6 R6Class
#' @include utils.R
#' @include tuner.R
#' @include bayesian_tuner.R
GLMBayesianTuner <- R6Class(
classname = "GLMBayesianTuner",
inherit = BayesianTuner,
public = list(
# Properties --------------------------------------------------
best_model = NULL,
best_loss = Inf,
... |
d8745bd60eb730d5fee28512f7abbc4c77ac5b3bcd42a156356c88c43dabef0e | R | 1,848 | 49 | library(SingleCellExperiment)
library(scmap)
library(Matrix)
memory.limit(40000)
setwd("C:/Users/Plus0/Desktop/Inter-dataset/PbmcBench")
rm(list=ls())
gc()
load("matrix_data.RData")
load("labels.RData")
for (dataset in c("10Xv2", "10Xv3", "CEL_Seq", "Drop_Seq","inDrop", "Seq_Well", "Smart_Seq2")){
... |
5df989b0238f6911c6b44e2e069ec4b737eeba4df0163aba7756cf24491d5e7c | R | 1,871 | 69 |
library(pheatmap)
library(RColorBrewer)
dir.create('Plots')
cellTypeList <- c('DopaN', 'GabaN', 'Oligo', 'OPC', 'Ast', 'Micro', 'Endo', 'Peri')
rnaVal <- read.table('/home/ajl1213/Projects/PD/SciAdv_Data/snRNAseq/03_GetRnaCount/CountByCellType/RawCount.byCellType.qq.txt', header=T, row.names=1)
atacVal <- read.tab... |
68c22f1f83d9086c92cefcd747253298a632a4704ada6b9f7ae2a61ec7d2b768 | R | 1,879 | 63 | library(pheatmap)
library(RColorBrewer)
dir.create('Plots')
knownGeneList <- c(
'SNCA', 'UCHL1', 'PINK1', 'PARK7','LRRK2',
'ATP13A2', 'FBXO7', 'VPS35', 'DNAJC6', 'SYNJ1',
'CHCHD2', 'VPS13C', 'GBA', 'MAPT', 'GAK',
'SMPD1', 'SCARB2', 'SLC17A5','ATP6V0A1','CTSB'
)
for (dataType in c('Down','Up')){
print(dataType)... |
fc1a16b1b67e464629cbfb0827c144d4f40cb80321262b01b53508610b92e5c3 | R | 1,925 | 42 | options(stringsAsFactors=F)
library(motifbreakR)
library(SNPlocs.Hsapiens.dbSNP151.GRCh38) # dbSNP144 in hg38
library(MotifDb)
library(BSgenome.Hsapiens.UCSC.hg38)
bedfile = "/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/data/progenitor_TF_w_dbsnp_all.bed"
# prepare variant file
snps.mb.frombed <- snps.from.file... |
61eb7ca790c36f1d44936d352bdd976a9000b014ae8b8ec2bac23db316ab6856 | R | 1,940 | 69 | #'Converts the RBT array output by calculate_relative_motion( ) to 2D matrix
#'
#'\code{export_rbt} converts the transformation array output by
#'\code{calculate_relative_motion} into a 2D matrix w/ dimensions nFrames x 16
#'suitable for export to .csv that can be read into Maya.
#'
#' @param rbt a 3D transformation ma... |
81a1ec62e1c98af360dec16844f1ec14d5905fa80572a344cf0eb54225fb73e3 | R | 1,968 | 58 | #######################################################################################
## ##
## Script to combine pipeline runs for individual samples into something more useful ##
## ... |
6e2af7804482d1bb382dcb0936558b3789596e9c6cc58d041ca21f746b8e0b1e | R | 1,974 | 47 |
library(Seurat)
library(ggplot2)
seuset <- readRDS('SeuratObjects/PD.SN.snRNA.postAlign.Anno.rds')
dir.create('CellTypeDEGs')
##===============================================================================================================================================================================
## Cell type... |
38139f528af8fbf9dc880129f803bcd8a2de1ffedd0a8700317e2bb6cf64f671 | R | 1,976 | 53 |
#' get_umap_coordinates
#'
#' Function returns UMAP-coordinates if onle selected genes are used.
#'
#' @param sce SingleCellExperiment object containing gene counts matrix (stored in 'logcounts' assay).
#' @param genes Character vector specifying genes to use for calculating umap-coordinates.
#' @param batch Name of t... |
43500f550153acc4bba0a94558ead1890f46fb07b295166526f2c669153c797a | R | 2,004 | 55 | library(SingleCellExperiment)
library(scmap)
library(Matrix)
memory.limit(40000)
setwd("C:/Users/Plus0/Desktop/Inter-dataset/PbmcBench")
set.seed(1)
rm(list=ls())
gc()
load("matrix_data.RData")
load("labels.RData")
for (dataset in c("10Xv2", "10Xv3", "CEL_Seq", "Drop_Seq","inDrop", "Seq_Well", "Smar... |
b8b152ad030d779b6db15f7a7e1043b2a4cc3481484f06e8b2832b5beebca0fd | R | 2,009 | 43 | #' @include RBO_Utils.R
#' @title Utility Maximization Function
#'
#' @description
#' Utility Maximization.
#'
#' @param DT_bounds hyperparameters lower and upper bounds to limit the search of the acq max
#' @param GP an object of class GP
#' @param acq Acquisition function type to be used
#' @param y_max The current ... |
be4d92321ceee1a97dd1d66c1e9b1369c81f612e2980a9c957f90da770223bfc | R | 2,056 | 68 | ##########################################################################################
## Create gene x gene co-expression matrix containing proportionality metric (rho)
## using BrainSpan RNA-seq data
##
## Author: Yu-Han Hsu
#########################################################################################... |
e8dab59d64780c1389c7203f5d4cc28d91c72320a6ec081a0f9b687feffa3df2 | R | 2,146 | 84 | records_number <- nrow(iris)
basic_validation <- function(cross_validator,
folds,
records_number,
expected_folds_number,
expect_all_records = TRUE) {
expect_class(cross_validator, "CrossValidator")
e... |
0485598ce9e330d887a6dda5977f2010af5230a67fed30b3536ff4d7dc4a0242 | R | 2,148 | 41 | shinyjs::hide('step2-dl1')
cor.df<-reactive({
stat.df<-data.table(NE=SCLC.NE(),user.dat())[,lapply(.SD,function(x) unlist(cor.test(NE,x)[c('estimate','p.value')])),.SDcols=-1]
stat.df<-data.table(colnames(user.dat()),t(stat.df));setnames(stat.df,c('gene','r','pv'));stat.df[,padj:=p.adjust(pv,'BH')]
stat.df[,pv:=s... |
1d52318937a4e1e2855e66c01026b90b6f0990900e95e6ba57e9d2f12938daa0 | R | 2,199 | 70 | ##########################################################################################
## Create gene x gene co-expression matrix containing proportionality metric (rho)
## using human cortex gene expression matrix from Velmeshev 2019 (scRNA-seq)
##
## Author: Yu-Han Hsu
############################################... |
b60d8f38ae253e5211c3a2185d1a965995910493f7f018e087785760b7fd0217 | R | 2,215 | 63 | library(Matrix)
library(scmap)
library(SingleCellExperiment)
setwd("C:/Users/Plus0/Desktop/data1/AMB")
raw_data <- read.csv("Filtered_mouse_allen_brain_data.csv", header = T, row.names = 1)
Labels <- read.csv("Labels.csv", header = T)
memory.limit(40000)
data_matrix <- as(as.matrix(t(raw_data)), "dgCMatrix")
... |
a9c03e447806e56e236d0e6247ae6c0f29ea01475eeb55472c4fc9ef4a92666f | R | 2,224 | 42 | library(ggplot2)
Caudate = data.frame(tissue = rep("caudate",4),
age_window = c(rep("juvenile-adult",2),rep("adult-older adult",2)),
type = rep(c("SCZ","ALL"),2),
JI = c(0.62,0.65,0.68,0.74))
DLPFC = data.frame(tissue = rep("dlpfc",6),
... |
8a98bc2ec1ab01ed24cc53605fdcfb1cdb19fc406eeefedaab9f2e6db340877a | R | 2,227 | 59 | library(shiny)
library(shinyjs)
library(shinydashboard)
library(ggplot2)
library(ggridges)
library(DT)
library(data.table)
library(shinycssloaders)
library(ComplexHeatmap)
library(RColorBrewer)
high.NE.col<-"#5e3c99";low.NE.col<-"#e66101"
example.dat<-readRDS('data/example_expr.rds')
sig<-readRDS('data/SCLC_sig.rds')
s... |
66abb031d930742b1a8dfa80bdd7ec9569ee5adff0943c224f610c7b767d075f | R | 2,241 | 57 | # Ruize Liu
# GRS analysis
# Inverse-variance weighted fixed-effect meta-analysis on interaction term across cohorts
library(metafor)
args = commandArgs(trailingOnly = TRUE)
# in_list_addr_l = c('IP_and_InWeb_list_test_p.txt', 'NC_combine_test_p.txt', 'bine_1percent_list_test_p.txt', 'bine_5percent_list_test_p.txt', ... |
42f352cf3da58d58d23cbc8174412bc04bf3c23b6036f94b4ae31d79e9e2aa76 | R | 2,253 | 75 |
library(ggplot2)
library(RColorBrewer)
dir.create('Plots')
data1 <- read.table('PD_GWAS.match.txt', header=T)
##===========================================================================================================================
# Barplot
ctrlDF <- data1[grep('NOSN', data1$SampleID), ]
pdDF <- data1[grep... |
53a26aa692e31e552dbb7136c99e417c525957dc33fbfded4853c4fce545a5f1 | R | 2,256 | 117 | #' Sci Data Paper Supplementary Figure 3
#'
#' @import mdatools
#'
#' @return supplfig3.pdf
#' @export
get_supfig3 = function() {
# warnings off
w <- getOption("warn")
options(warn = -1)
if( !exists("fig"))
dir.create("fig")
# load data
data(noBatchPep, envir = environment())
data(metaDT, envir = e... |
e920c3ddac29358501fd2d3674882ec915868857224cc1d592166f2dbaa80b52 | R | 2,285 | 91 | #' @importFrom R6 R6Class
#' @include utils.R
#' @include gs_predictor_preparator.R
GSBayesianPredictorPreparator <- R6Class(
classname = "GSBayesianPredictorPreparator",
inherit = GSPredictorPreparator,
public = list(
# Properties ---------------------------------------------------------------
model =... |
740d5a228859f1ed18c77207ed0aafd806de97f544fc02eafc35a4a57a94e40c | R | 2,297 | 83 |
library(ggplot2)
library(RColorBrewer)
cellTypeList <- c('DopaN', 'Oligo', 'OPC', 'Ast', 'Micro', 'Endo', 'Peri')
data1 <- read.table('Merged.cor.label.txt', header=T)
data1$label <- factor(data1$label, levels=c('match','unmatch'))
data1$cellType <- factor(data1$cellType, levels=cellTypeList)
data1$atacLibType <- ... |
619123aee648bd9503c3c1fed6479b636d80e6d33dc909cb86fc372d63aa6da0 | R | 2,304 | 44 | options(stringAsFactors=FALSE);
##chrs
Gchrs=c(1:22);
Pchrs=paste0("chr",c(1:22));
Genofile = '/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/genotype/eQTL/truncated/progenitor/';
KinM = '/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/kinship/';
#NPhenfile = '/proj/steinlab/projects/R00/eQTLanalysis/phenofiles/v... |
885f3db4a78acf1bb023b2df38e9d4e38a5480d81c075974eba790767a4ed201 | R | 2,331 | 41 | options(stringAsFactors=FALSE);
##chrs
Gchrs=c(1:22);
Pchrs=paste0("chr",c(1:22));
Genofile = '/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/genotype/caQTL/truncated/progenitor/';
KinM = '/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/kinship/';
PPhenfile = '/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/phe... |
0bdc94b6333bc106f96d4841283581e29a3525fc479e8baa235c440d60316644 | R | 2,338 | 63 | #!/usr/bin/env Rscript
# Run R harmony on the same toy and ircolitis inputs as run_harmonypy.py.
#
# Needs harmony from the harmony2 branch built with LAPACK: the two-column
# ridge step calls inv(). See run_all.sh for a macOS build that links
# Accelerate. Usage (from this folder):
# Rscript run_r_harmony.R
suppress... |
bddaea67fb5ef6c1f4b6f5f7b401811767065b669b3c3f4df80ff215ef394d93 | R | 2,393 | 50 |
#' get_redundancy_stat
#'
#' Functions calculates relevance of each gene (within current selection) to celltype mapping.
#'
#' @param sce SingleCellExperiment object containing gene counts matrix (stored in 'logcounts' assay).
#' @param genes Character vector specifying selected library.
#' @param genes_to_assess Cha... |
8af8101d475d6d2fdad25ababfa052ed17e12a6ff558e23512b420d46124a1f8 | R | 2,395 | 67 | library(Matrix)
library(scmap)
library(SingleCellExperiment)
setwd("C:/Users/zhangjn.CSDOMAIN/Desktop/Zheng 68K")
raw_data <- read.csv("Filtered_68K_PBMC_data.csv", header = T, row.names = 1)
Labels <- read.csv("Labels.csv", header = T)
memory.limit(80000)
data_matrix <- as(as.matrix(t(raw_data)), "dgCMatrix")... |
7bee8db18d2f79d48984bb4099064d9e65d6cf5695bc6aada9357be8db50b132 | R | 2,406 | 85 |
library(ggplot2)
dir.create('Plots')
## Down
# factor list
cellTypeList <- c('DopaN','GabaN','Oligo','OPC','Ast','Micro','Endo','Peri')
windowList <- c('100kb')
# random values
randDF <- NULL
for (cellType in cellTypeList){
for (winDist in windowList){
data1 <- read.table(paste0('RandPeakPermute/Down.', cel... |
6025d0e40061faebcc69abea892155644fe5ae378fddfb855e237831c0003126 | R | 2,411 | 78 | # context("Testing gene_search")
library(geneBasisR)
### set up inputs
## libs
library(SingleCellExperiment)
set.seed(32)
## toy data
counts = t(matrix(c(0,0,0,0,1,0,1,0,1,1,1,1), nrow = 3, ncol = 4))
sce_1 = SingleCellExperiment(list(logcounts = counts))
rownames(sce_1) = c(1,2,3,4)
sce_2 = SingleCellExperiment(li... |
1454a4e218eeeb4b46cf6cc94ab902266199787a622e2402e617cd4ab979ca6a | R | 2,414 | 64 | ##########################################################################################
## ##
## Functions to combine pipeline runs for individual samples into something more useful ##
## ... |
a28f6c33344732ba856902cca3549fb6900b13fa16e9ee84d8700704fffc736e | R | 2,415 | 61 | options(stringAsFactors = F)
library(data.table)
type = commandArgs(trailingOnly=TRUE)[1]
k = commandArgs(trailingOnly=TRUE)[2]
library(data.table)
gtf = fread("/proj/steinlab/projects/R00/eQTLanalysis/phenofiles/gene_transcript_v92.csv",data.table = F)
gtf = gtf[which(gtf$type == "gene"),]
# Extract eGenes
sig_gen... |
1bf18d0d3797e6a9d3e07ee66d2da1ac0f23397c5c051586e24fb65a0419430d | R | 2,419 | 92 | #' @importFrom R6 R6Class
#' @include utils.R
#' @include model_helpers.R
#' @include grid_tuner.R
GLMGridTuner <- R6Class(
classname = "GLMGridTuner",
inherit = GridTuner,
public = list(
# Properties --------------------------------------------------
best_model = NULL,
best_loss = Inf,
# Meth... |
5873ce5ba070ae760c2f1a05ec31526101f5709a228cdabc2ab686794dac7ebe | R | 2,426 | 65 | #Run INSPEcT on Kallisto transcript quantitations
#Model rates and calculate p-values for rate change and chisq fit
library('INSPEcT')
log <- file(snakemake@log[[1]], open="wt")
sink(log)
sink(log, type="message")
rdata_file_in <- snakemake@input[['rdata_file']]
#output files for modeled rates
synth_mod_file <- snak... |
c60a01fc5ef4f9a2e5f665a1d69e4137868a6ccf125345d03e430a975caeaf3e | R | 2,473 | 59 | #################################################################
# Function for GO enrichment #
# modified from clusterProfiler::enrichGO #
#################################################################
#### GO enrichment ####
enrichGO_custom = fun... |
c20be321485b209c1b4b7efefeb61caedcf11a43ef73dd2d59e3a6e12e4a4da1 | R | 2,491 | 58 | ###############################################################################################
# Script to remove confounder effect #
# iPSC data #
#############################... |
383bddb6eb974c7b0c0563edfb7377712eee3801046541ad3f896b3fc0136e68 | R | 2,495 | 73 | # simulating paired scRNA-seq and ST data using splatter.
library(splatter)
# generate gene expression data and spatial coordinates
sim_data_construct <- function(gene_num = 5000,
batch_cell_num_1 = 1000,
batch_cell_num_2 = 1000,
... |
81b5e706ab9940b589df3be9ca6567396a38b006227c8c5d7a10c9ed5ec13bd4 | R | 2,503 | 90 | #' @include utils.R
#' @include validator.R
#' @include gs_bayesian_cross_evaluator.R
#' @title Bayesian Cross Validation for Genomic Selection
#'
#' @inherit gs_fast_bayesian
#'
#' @description
#' This function performs a cross validation using the Bayesian models.
#'
#' @param model (`character`) (case not sensitive... |
0d710c38658faadfdb057b818cfcf5144eac082e0f28ca26a103d891ce8d26f0 | R | 2,505 | 118 | n_rows <- 50
n_cols <- 50
x <- matrix(rnorm(n_rows * n_cols, 100, 20), nrow = n_rows, ncol = n_cols)
test_that("Conventional", {
expect_matrix(
conventional_kernel(x, kernel = "linear"),
any.missing = FALSE,
nrows = n_rows,
ncols = n_rows
)
expect_matrix(
conventional_kernel(x, kernel = "po... |
d70e78286bc3d996441b88b4f7f048b4e32e42677d1988938929c081571400aa | R | 2,545 | 60 |
library(Seurat)
library(Signac)
library(ggplot2)
library(RColorBrewer)
## Load data
seuset.atac <- readRDS('/home/ajl1213/Projects/PD/SciAdv_Data/snATACseq/2_SignacProcess/SeuratObjects/PD.SN.snATAC.postAlign.geneExp.label.anno.rds')
dir.create('CountByCellType')
#===================================================... |
114ce78acb05aa97d4bfb600ea581f22655db5a3e4bfe0e2881091e54c074007 | R | 2,556 | 72 | # Assign ASCA findings to compare Causal vs independence
#----Functions
# Make LD
makeLD <- function(snp,k){
cat("module add plink \n")
system(paste0("module add plink \n plink --bfile ../../../atac-qtl/EMMAXResult/Genotype_Hg38/",k,
".dose.R2g03.QC.IDfixed --keep ../../LD/donorlist_ld.txt --ld-s... |
811978f2bc9097b195e7e9af9b0374fad0933f6ee37ccef9c0a336362e23aae4 | R | 2,565 | 61 | setwd("~/GitHub/twin-data-models")
rm(list = ls())
library(tidyverse)
#### Results Table ####
source("04a_uni_path_covariate_OpenMx.R")
qtab.ses01 <- readRDS("QTAB_familywise_ses01.RDS")
# Single phenotype
result.single <- as_tibble(Univariate_path_covariate(phenotype = "ProcSpeed_rawZ", twin.data = qtab.ses01, cova... |
9d168f918a037dbb9611199ae0cee734006278e991b063410c330e1ca37a8bb6 | R | 2,574 | 88 |
library(pheatmap)
library(RColorBrewer)
dir.create('Plots')
dir.create('CorMat')
cellTypeList <- c('DopaN', 'Oligo', 'OPC', 'Ast', 'Micro', 'Endo', 'Peri')
rna_DIR <- '/home/ajl1213/Projects/PD/SciAdv_Data/snRNAseq/03_GetRnaCount/CountByIndiv'
atac_DIR <- '/home/ajl1213/Projects/PD/SciAdv_Data/snATACseq/4_AtacCou... |
512c31157e4c8d0fc6f9432cbf4e484045f0554e19c975988c4136546c376dd7 | R | 2,584 | 37 | #' @param tune_type (`character(1)`) (case not sensitive) The type of tuning to
#' perform. The options are `"Grid_search"` and "`Bayesian_optimization`".
#' `"Grid_search"` by default.
#' @param tune_cv_type (`character(1)`) (case not sensitive) The type of cross
#' validation to tune the model. The options are ... |
7a41453853c420e99b716e490b8c3fba595234e54a28f229dfbd7576d79bbacc | R | 2,585 | 76 | ## Checks for the differences in overall survival between the participant clusters
insert_head()
# container list------
cl_surv <- list()
# globals ----
insert_msg('Globals setup')
cl_surv$analysis_tbl <- clust$clust_obj %>%
map(extract, 'assignment') %>%
map(set_names, c('... |
4995cc9d8757039c369113d722ede9dcb398d3c99df24d1c4ed690bd0904eaa6 | R | 2,593 | 75 | # Univariate cox modeling. Numeric variables are splinned with rms::rcs
insert_head()
# container list -----
uni_cox <- list()
# globals: median-centered analysis table -----
insert_msg('Analysis table')
uni_cox$analysis_tbl <- pah_study[c('IBK_0', 'LZ_0')] %>%
map(select, - su... |
3f85bc20fc7417164feb33bbf02f67967b7f3f6cd5c3af900264fc77d8029b73 | R | 2,594 | 74 | # The project globals
insert_head()
# container ------
globals <- list()
# plotting theme ------
globals$common_text <-
element_text(size = 8, face = 'plain', color = 'black')
globals$common_margin <-
ggplot2::margin(t = 4, l = 3, r = 2, unit = 'mm')
globals$common... |
ed3d76d82c1a1f1f624f458e8bd8cf562b67a047ae42fe4b9d146d0890b2f767 | R | 2,614 | 76 |
#' retain_informative_genes
#'
#' Function selects variable genes and retains them to represent counts matrix for downstream analysis. This is essentially a wrapper for scran::getTopHVGs +
#' simple check for mt-genes.
#'
#' @param sce SingleCellExperiment object containing gene counts matrix (stored in 'logcounts' as... |
59c238f33b40b8c532a6d3bc6578b842b688caa9ba45b51fcf7e6e29dab3ec6d | R | 2,624 | 64 | ###############################################################################################
# Script to remove confounder effect #
# "Sliding window" study #
# ... |
c9550ceb056706a146a4ec366fbc87f23cf3d42f02f7786dee722eb0b5a17e80 | R | 2,631 | 78 | library(Signac)
library(Seurat)
library(GenomeInfoDb)
library(EnsDb.Hsapiens.v75)
library(ggplot2)
library(patchwork)
args=commandArgs(TRUE)
sampleID=args[1]
print(sampleID)
### Load data
inputFile=paste(sampleID,'/outs/filtered_peak_bc_matrix.h5', sep='')
counts=Read10X_h5(filename=inputFile)
inputFile=paste(sampl... |
12e1d2907c8c1b7a81c93c890d4bfaee380ad0afed53de5db3c487d1f0fa64cd | R | 2,641 | 58 | ####################################################################################################
# Script to Remove confounders effect #
# "Cell-population enrichment" studies #
# ... |
c7fa5ceb7b53e45e5b0add74f18702c911c380823462b7c505f401b0c7beb14c | R | 2,642 | 79 | #' Sci Data Paper Figure 4
#'
#' @return figure4.pdf
#' @export
get_fig4 <- function() {
# warnings off
w <- getOption("warn")
options(warn=-1)
if( !exists("fig"))
dir.create("fig")
# load data
data(raw, envir=environment())
data(median, envir=environment())
data(pepGrp, envir=environment())
da... |
746eaa51dbba846a334bf82edd58f4dea208ed6d2d202a9ffc6c45fbac75b7e5 | R | 2,652 | 89 |
library(ggplot2)
library(RColorBrewer)
dir.create('Plots')
data1 <- read.table('eQTL_HiC.comparison.count.txt', header=T)
celltypes <- c('DopaN', 'GabaN', 'Oligo', 'OPC', 'Ast', 'Micro', 'Endo', 'Peri')
# hypergeometric test
pvals <- c()
for (i in 1:nrow(data1)){
p_hyper <- sum(dhyper(data1$common[i]:data1$h... |
92a4d81960908e796160b9707284de5a5ca445561a26c0eb6aef9cfbbc378a15 | R | 2,660 | 61 | ####################################################################################################
# Script to Get a gene_module_list for all networks from the wide_data_file #
# to be used for enrichment analysis #
# "Regi... |
8f95f26b093d433cff43186cfafcd0da38a0d2d3e8311ca79e464b4a56684d65 | R | 2,664 | 109 | #!/conda2/scEnv
library(RColorBrewer)
library(enrichR)
inputDIR <- '/home/ajl1213/Projects/PD/SciAdv_Anal/CombinedTargetID/01_FindTarget/RESULT'
#
#a <- listEnrichrDbs()
#print(unique(a$libraryName))
#
cellTypeList <- c('DopaN', 'GabaN', 'Oligo', 'OPC', 'Ast', 'Micro', 'Endo', 'Peri')
minAbcScore <- 10
dir.creat... |
0806c11cc0ceee4a578ef3eabf08a687b127b20c676c9ca7ddec30a00d96e8d6 | R | 2,667 | 67 | library(ggplot2)
library(ggrepel)
library(RColorBrewer)
dir.create('Plots')
inputDIR <- '/home/ajl1213/Projects/PD/SciAdv_Anal/CombinedTargetID/01_FindTarget/RESULT'
cellTypeList <- c('DopaN', 'GabaN', 'Oligo', 'OPC', 'Ast', 'Micro', 'Endo', 'Peri')
minAbcScore <- 10
maxAbcScore <- 50
for (cellType in cellTypeList... |
bd5e71f098acbd8db03b23feff53f1b457b79d8d662b14684076ba863b79cfee | R | 2,673 | 74 | options(stringAsFactors = F)
type = "progenitor"
if (type == "progenitor") {
L = "P"
} else {
L = "N"
}
# Subset caQTL for inside the peak (inpeak)
dat = data.frame()
for (i in 1:22) {
ss = data.table::fread(paste0("/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/EMMAX/",type,"/caQTL/",L,"-chr",i,".txt"),d... |
1b19b8b8e93994bc13c3230d9e4fa06ce3c5a813063f5df52049d841e86fd905 | R | 2,698 | 84 | # context("Testing retain_informative_genes")
library(geneBasisR)
### set up inputs
## libs
library(SingleCellExperiment)
set.seed(32)
## toy data
counts = t(matrix(c(0,0,0,0,1,0,1,1,1), nrow = 3, ncol = 3))
sce_1 = SingleCellExperiment(list(logcounts = counts))
rownames(sce_1) = c(1,2,3)
sce_2 = SingleCellExperime... |
41ba3310720c50be0102a5d817a1ea98e5ae86eacacbe51ce546423dd1e97224 | R | 2,698 | 90 |
#======================================================================================================================
# Quantile normalization
library(preprocessCore)
data <- read.table("AdjustedBulk/RNA.cellAdjusted.iter_3.txt",head=T,row.names=1)
valMat=as.matrix(data[, 1:ncol(data)])
qq_values <- normalize.quan... |
20e4af00bd3b1884e38acc99482079d11691966ec715fc79abd034548764319f | R | 2,707 | 75 | library(pheatmap)
library(RColorBrewer)
dir.create('Plots')
for (i in c('Down','Up')){
print(i)
#========================================================================================================================================================================
# order
data1 <- read.table(paste0... |
2b2d065231f2cac5015c42e5036bf0413fc8d2a7c1ae2e9c641a3250620aac7c | R | 2,718 | 75 |
dir.create('Plots')
#=================================================================================================================================================
## Number of valid read-pairs
sampleList <- c(
'X4870NOSN','X4689NOSN','X5628NOSN','X5130NOSN','X5006NOSN','X4996NOSN',
'X5244PDSN','X4831PDSN','X5215... |
b1002f657b12c6eca25e9fb2d65c2f5b7c6c1d11122390bea9b5d40cbd0dc239 | R | 2,728 | 55 | ##### multiplot ####
library(ggplot2)
library(grid)
library(gridExtra)
require(ggrepel)
data.null = rbind(Caudate.null,Dlpfc.null,Hippo.null)
data.null$age_window = factor(data.null$age_window,levels = c("perinatal-juvenile","juvenile-adult","adult-older adult"))
data.null$type = as.character(data.null$type)
... |
eeff8d11b28f30ebe46196fba016c30067e56490e78be2b30283786c9eacdaf2 | R | 2,738 | 92 |
#=========================================================================================================
# Quantile normalization
library(preprocessCore)
data <- read.table("AdjustedBulk/H3K27ac.cellAdjusted.iter_3.txt",head=T,row.names=1)
valMat <- as.matrix(data[, 1:ncol(data)])
qq_values <- normalize.quantiles.... |
799df345c5264b8e4e5883545c31d2786b6e74308e278742f2fde431c15f034e | R | 2,790 | 73 | # Prepare phenotype files for caQTL
# Code modified from Dan Liang
options(stringsAsFactors=F)
outdir = "/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/phenotype/caQTL/"
library(DESeq2);
library(limma);
library(statmod);
options(stringsAsFactors=FALSE);
##load vst count number
load("/proj/steinlab/projects/R00/ATA... |
a091c4f10f6cbd7c560c14a4df47c7d0916d4a45e5ce692ab3fbb06a5a652ea5 | R | 2,836 | 101 | # Ruize Liu
# GRS analysis
# For EAS, fit the linear model GRS ~ Int_Non + Case_Control + Int_Non * Case_Control + PCs and test interaction term: Int_Non * Case_Control.
args = commandArgs(T)
prs_dir = args[1] # input prs dir where prs file located
base_name = args[2] # prefix of output files:
print(prs_dir)
p... |
b79c3489029bc79295dc3d6c045c837d0fe8d139e887d549ce0fcc3f867b904c | R | 2,891 | 57 | options(stringAsFactors=FALSE);
k = commandArgs(trailingOnly=TRUE)[1]
type = commandArgs(trailingOnly=TRUE)[2]
##chrs
Gchrs=c(1:22);
Pchrs=paste0("chr",c(1:22));
Genofile = paste0('/proj/steinlab/projects/R00/eQTLanalysis/path_QTL/genotype/caQTL/truncated/',type,'/TF_map/');
KinM = '/proj/steinlab/projects/R00/eQTLa... |
dc80ab07fdeb3b82df299c43da6e1086475376e3182ef2c694568f50d4d90fc4 | R | 2,893 | 38 | new.SCLC.NE<-reactive({
comp.score(dat=t(user.dat()),sig = NE.sig(),logged = max(user.dat()[1,],na.rm = T)<100)
})
new.NE.df<-reactive({data.table(sample=rownames(user.dat()),`NE score`=round(new.SCLC.NE(),2))})
observeEvent(input$`step3-btn1`,{
output$`step3-tbl1`<-DT::renderDataTable(DT::datatable(data = isolate(... |
1c9a56c7981cd0fa5bf50c42581a20e72980f406cbf31b3d41fd508f96a03af9 | R | 2,921 | 72 | #### Notes ####
# Author: Lachlan T Strike
# Example code for running linear mixed effects models on QTAB data:
# Strike, L. T. et al. QTAB Non-Imaging Phenotypes. UQ eSpace https://doi.org/10.48610/e891597 (2022).
# Strike, L. T. et al. Queensland Twin Adolescent Brain (QTAB). OpenNeuro https://doi.org/10.18112/openne... |
f6381a1e520863ee08586f0e3c00651cdc6a515c7b01ca00b7a7a45ce92b5483 | R | 2,939 | 67 | ####################################################################################################
# Script to Create a combined wide_data_file with WGCNA output from our and other networks, #
# plus genestats, MAGMA stats etc #
# "Regi... |
b22ff68415621dfc48b7d60a19ef208a9caafea3ac994efcfdfb960a88b55bf8 | R | 2,951 | 81 | evaluate <- function(TrueLabelsPath, PredLabelsPath, Indices = NULL){
"
Script to evaluate the performance of the classifier.
It returns multiple evaluation measures: the confusion matrix, median F1-score, F1-score for each class, accuracy, percentage of unlabeled, population size.
The percentage of un... |
e0cb0e8ea0ed9f7c5d7ef90fa5329767609cc2a752776e832001aa701b88ebf4 | R | 3,005 | 65 |
#' get_DE_genes
#'
#' Essentially a wrapper for scran::findMarkers. Returns an aggregated stat across all cell types in a form of data.frame:
#' each row corresponds to cell type and gene which is found to be DE in this cell type (using designated FDR as a threshold for significance), FDR and summary.logFC.
#'
#' @par... |
0a01d849889b6793c0e3fdbeca2de9112ef3552c484a776e92f7104d625662dd | R | 3,021 | 104 | # Ruize Liu
# GRS analysis
# For EUR, fit the linear model GRS ~ Int_Non + Case_Control + Int_Non * Case_Control + PCs and test interaction term: Int_Non * Case_Control.
args = commandArgs(T)
prs_dir = args[1] # input prs dir where prs file located
base_name = args[2] # prefix of output files:
print(prs_dir)
p... |
ea3999e84e37e5c0dce190578ca53f95e12823794575d6edf4f8d9a7fb719f3c | R | 3,105 | 125 | #' @import dplyr
#' @importFrom R6 R6Class
#' @include utils.R
#' @include bayesian_model.R
#' @include gs_cross_evaluator.R
#' @include gs_bayesian_predictor_preparator.R
GSBayesianCrossEvaluator <- R6Class(
classname = "GSBayesianCrossEvaluator",
inherit = GSCrossEvaluator,
public = list(
# Properties --... |
043375429cd0bf02570b31e3f2705bdf65d25a5d177208ff5649f11f976fc83f | R | 3,112 | 28 | ####################################################################################################
# Script to Combine WGCNA output from our networks and other previous published networks #
# "Regional-coexpression", "Age-period" and "Cell-population enrichment" studies #
# ... |
e42de129cce70b33249929d0ebca83e1fa94778ca3c18adf0824d2a283eee47c | R | 3,143 | 59 |
# Perform trans-eQTL analysis for eGenes detected in previous cis-eQTL study
options(stringAsFactors=FALSE);
library(data.table)
##chrs
Gchrs=c(1:22);
Pchrs=paste0("chr",c(1:22));
Genofile = '/proj/steinlab/projects/R00/eQTLanalysis/genofiles/allele_order_corrected_genofiles/';
KinM = '/proj/steinlab/projects/R00/eQT... |
8be6ca014a5136a8922c7db1ca6673227356df8c51798af47d7681aedfedecf7 | R | 3,161 | 168 | # Kernels --------------------------------------------------
CONVENTIONAL_KERNELS <- c(
"Linear",
"Polynomial",
"Exponential",
"Sigmoid",
"Gaussian",
"Arc_cosine"
)
SPARSE_KERNELS <- c(
"Sparse_Linear",
"Sparse_Polynomial",
"Sparse_Exponential",
"Sparse_Sigmoid",
"Sparse_Gaussian",
"Sparse_Arc... |
ad2afccab1d39a9e69a00bc64da9fa69e798a0b1134cd0b4561d4614b05df47a | R | 3,167 | 119 | # Use all default hyperparameters -------------------------------------------
x <- to_matrix(iris[, -1])
y <- iris$Sepal.Length
model <- partial_least_squares(x, y)
# Obtain the optimal number of components to use with predict
model$optimal_components_num
# Obtain the model's coefficients
coef(model)
# Predict using... |
5ca7359f72614835f9aeb7c95d9ae2f46d8a2257eeb2820861b6ec7f142f1dc5 | R | 3,169 | 114 | #' @importFrom R6 R6Class
#' @include utils.R
#' @include model_helpers.R
#' @include metrics.R
Tuner <- R6Class(
classname = "Tuner",
public = list(
# Properties --------------------------------------------------
x = NULL,
y = NULL,
responses = NULL,
is_multivariate = NULL,
hyperparams =... |
aa134d694261e5921e009c0c469f4c4169db001b6c763f5c140a8d0db1fc8bf4 | R | 3,177 | 71 |
library(Seurat)
library(Signac)
library(ggplot2)
seuset.atac=readRDS('SeuratObjects/PD.SN.snATAC.postAlign.geneExp.label.anno.rds')
dir.create('CellTypeDEGs')
##===========================================================================================================================================================... |
2628ff93340c90a45ecdca938ff37c66625b1b7acad42a52fc30c7c0a435b256 | R | 3,205 | 112 | #' @include utils.R
#' @include validator.R
#' @include gs_radial_model.R
#' @export
gs_radial <- function(lines,
envs,
y,
Geno = NULL,
Markers = NULL,
predictors = list(Line = "BGBLUP"),
... |
9423c6eaf4fcf548b9140c86b0fcd02ad658a836e1624cd710ecb79d192a8800 | R | 3,224 | 113 | #' @importFrom R6 R6Class
#' @include utils.R
#' @include tuner.R
#' @export
GridTuner <- R6Class(
classname = "GridTuner",
inherit = Tuner,
public = list(
# Properties --------------------------------------------------
grid_proportion = NULL,
# Constructor ----------------------------------------... |
152d42def45b9bcbdf650fe845438604bf2a210a5d170019e7b7b137835c2cbc | R | 3,236 | 94 | options(stringAsFactors = F)
library(bmediatR)
library(data.table)
pro_qtl = read.csv(paste0("/proj/steinlab/projects/R00/eQTLanalysis/Supplementary_tables/revision/table1/progenitor_eqtl_sumstat.csv"))
neuro_qtl = read.csv(paste0("/proj/steinlab/projects/R00/eQTLanalysis/Supplementary_tables/revision/table1/neuron_eq... |
f83d887eb0fcf01a82db080956baa5c72ae20c0c65f29abcb5af87015566704d | R | 3,243 | 66 | source('../scripts/utils.R')
################## DR.SC ##################
sim_id <- paste0('sim', 1:140)
time_df <- data.frame(matrix(ncol = 1, nrow = 140))
rownames(time_df) <- sim_id; colnames(time_df) <- 'run_time'
res_list <- list()
for (i in 1:length(sim_id)) {
if(i <= 50){
data <- read.csv(paste0('~/worksp... |
42d0683c52735f966c234c97e20f7b43ea28e6e16e6dc398eff876b4d60ea0d7 | R | 3,246 | 65 | #### Notes ####
# Author: Lachlan T Strike
# Example code for running linear mixed effects models on QTAB data:
# Strike, L. T. et al. QTAB Non-Imaging Phenotypes. UQ eSpace https://doi.org/10.48610/e891597 (2022).
# Strike, L. T. et al. Queensland Twin Adolescent Brain (QTAB). OpenNeuro https://doi.org/10.18112/openne... |
5c40d89d04cc0eaa7f7c9688ee64ad0e2c34c714ae93cd4c3c21a67844d9c1fa | R | 3,273 | 60 | #### Notes ####
# Author: Lachlan T Strike
# Example code for running linear mixed effects models on QTAB data:
# Strike, L. T. et al. QTAB Non-Imaging Phenotypes. UQ eSpace https://doi.org/10.48610/e891597 (2022).
# Strike, L. T. et al. Queensland Twin Adolescent Brain (QTAB). OpenNeuro https://doi.org/10.18112/openne... |
4b0b5aa9f04e88fad77fe0b37edf6b26c346080aef21eda839e9220b87594e9b | R | 3,280 | 119 | # Use all default hyperparameters ----------------------------------------------
x <- list(list(x = to_matrix(iris[, -5]), model = "BRR"))
y <- iris$Species
model <- bayesian_model(x, y, testing_indices = c(1:5, 51:55, 101:105))
# Obtain the model's coefficients
coef(model)
# Predict using the fitted model
prediction... |
030866895f45a42dfb2e9d2d5714db2a0e24bc8585076168badaa301fc85c27e | R | 3,281 | 76 | # E-statistic inspection for unmeasured confounding bias
-----------------------------------------------------------
### Install and load Evalue package
#install.packages("EValue")
library(EValue)
# select variables
dat <- dplyr::select(ukb_lbl, f.eid, depr_c.0, wb.0, mean_sbp.0, high_bp.0, htn_meds_count.0,
... |
7a5240fd4b38ad27e4c8ee2a1e85b1e5971dec291aeea80cdaa544c088d22a14 | R | 3,282 | 75 | # Run INSPEcT on Kallisto transcript quantitations
# Calculate first guess rates
# This version will run INPSEcT- rate estimation for experiment with
# no matched 4sU librares. This analysis was done to address a reviewer's
# question about whether the RNA dynamics is changing before and after brain
# incubation
lib... |
c9cd480f184122867e707b965ca2ef077eb06fe36d4ca7e893b910575cc6e199 | R | 3,296 | 87 |
#' get_coexpression_stat
#'
#' For each gene of interest, returns top co-expressed genes from the sce counts matrix (either filtered by number of co-expressed genes or correlation)
#'
#' @param sce SingleCellExperiment object containing gene counts matrix (stored in 'logcounts' assay).
#' @param genes Charcter vector ... |
0ab110a4614efd3d1d13a302eea8d00b41bc083b8089b93f2b525a2074cc5df0 | R | 3,297 | 102 | #' @importFrom R6 R6Class
#' @include utils.R
#' @include tuner.R
#' @include RBO_BayesianOptimization.R
#' @export
BayesianTuner <- R6Class(
classname = "BayesianTuner",
inherit = Tuner,
public = list(
# Properties --------------------------------------------------
folds = NULL,
current_combinatio... |
2cf0b3997c7ce4e148ce14edbccf3e597cf48979cf2252018f7f31a570157ea6 | R | 3,308 | 83 | ###############################################################################################
# Script to clean confounder effcts #
# "Regional-coexpression" and "Age-period" studies #
# ... |
20ee79b88e16d5433c290be01e16e5f0c7c2ee3c9e707ee23386ba8a82eda455 | R | 3,335 | 98 | plot.axis.projection <- function(object,
features,
ab.column = "AB",
a.label = "A",
b.label = "B",
split.on = NULL,
span =... |
618d9e9f86be3fa092a2ce6b3d391c2b19b6dba364076eb3116217990b19c49d | R | 3,361 | 76 |
library(Seurat)
library(ggplot2)
library(RColorBrewer)
## Load data
seuset.rna <- readRDS('/home/ajl1213/Projects/PD/SciAdv_Data/snRNAseq/02_SeuratProcess/SeuratObjects/PD.SN.snRNA.postAlign.Anno.rds')
dir.create('CountByCellType')
#===================================================================================... |
68ca3194945205a92cc1026488d11379e3c82d7466f00e31e219eb3b55a16b48 | R | 3,462 | 96 |
library(Seurat)
library(ggplot2)
library(RColorBrewer)
## Load data
seuset.rna <- readRDS('/home/ajl1213/Projects/PD/SciAdv_Data/snRNAseq/02_SeuratProcess/SeuratObjects/PD.SN.snRNA.postAlign.Anno.rds')
dir.create('CountByIndiv')
#======================================================================================... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.