sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
1356ac7cb4ab3b5f478011f522bb224f9924022e7e0f432433c9b9f4577f3840 | R | 894 | 14 | # This file is used to compile vignettes prior to release.
knitr::opts_knit$set(root.dir = getwd())
knitr::opts_knit$set(base.dir = "vignettes")
knitr::opts_chunk$set(fig.path = "eval_and_explain/")
# Render RMD.orig-files to RMD. This is done for compute-heavy data.
# See https://ropensci.org/blog/2019/12/08/precomp... |
c6beedfec76dcfeae05a75163abc48a38b20368870b6bf77bf0eb8fa35e829e3 | R | 897 | 40 | library(parallel)
library(ArchR)
args <- commandArgs(TRUE)
frag <- args[1]
ref <- args[2]
prefix <- args[3]
set.seed(1)
print(ref)
if (!ref %in% c("hg38", "hg19", "mm10", "mm9")) {
if (ref == "GRCh38") {
ref <- "hg38"
} else if (ref == "GRCh37") {
ref <- "hg19"
} else if (ref == "GRCm37... |
37e7c48972c5116ef06372e353bff19e1abd2a376f8f501b4229132a1b2a4e6a | R | 908 | 27 | # Don't perform any further tests on CRAN due to time of running the complete
# test.
testthat::skip_on_cran()
testthat::skip_on_ci()
debug_flag <- FALSE
familiar:::test_export(
export_function = familiar:::export_hyperparameters,
data_element = "hyperparameters",
not_available_no_samples = FALSE,
not_availab... |
798f717772e33d5b50628ce40f60f3300d4b53d3b9c35affb0cbc515da37736e | R | 912 | 32 | ###############################
## Function for defining credible sets using approximated asymptotic Bayes' factors (Wakefield's method)
## William Reay (2020)
################################
Finemapping_abf <- function(SNP, beta, stderr, W, coverage = 0.95) {
logsum <- function(x, base = exp(1), na.rm = FALSE) ... |
4ae4ccababaa32e09aa8d0e22b2103f52efef6d6e261f4637a998b04f55197fb | R | 914 | 18 | #' gUtils - Extending GenomicRanges
#'
#' @import GenomicRanges
#' @import data.table
#' @importFrom GenomeInfoDb Seqinfo keepSeqlevels seqlengths seqlengths<- genome<- seqinfo seqinfo<- seqnames seqnames<- seqlevels seqlevels<- seqlevelsStyle seqlevelsStyle<- isCircular orderSeqlevels rankSeqlevels
#' @importFrom uti... |
5633ab59a60ad3d5740f18a7bedbeaeba821df1501ab7e0ad2728aef18adb816 | R | 914 | 25 | process = function(fit, threshold = NULL){
if (is.null(threshold)){ threshold = fit$threshold }
alternative = fit$alternative
n.locations = fit$nlocations
if (alternative =="two.sided"){
Tstat_max = apply(matrix(fit$Tstat, n.locations), 1, max)
Tstat_min = apply(matrix(fit$Tstat, n.locations), 1, min)
... |
7421f6dcd53c2df89369bb4f16982fef928e8164d61b19eb8ef5a46a2898f55a | R | 919 | 27 | # First test if all selectable learners are also available
familiar:::test_all_learners_available(
learners = familiar:::.get_available_naive_learners(show_general = TRUE)
)
# Don't perform any further tests on CRAN due to time of running the complete
# test.
testthat::skip_on_cran()
testthat::skip_on_ci()
familiar... |
6a51721de584926927b9c50c494dee931caeb59afcc6d75186ccc17398dcf73f | R | 921 | 33 | testthat::skip_on_cran()
testthat::skip_on_ci()
debug_flag <- FALSE
# Simple test
vimp_methods <- c("none", "mim")
# Imbalance corrections using full undersampling
experimental_designs <- c("ip(fs+mb)", "ip(mb)")
for (ii in seq_along(vimp_methods)) {
familiar:::integrated_test(
experimental_design = experiment... |
85f36c2aecb368d43bb5d234b38d92ac69737e71fcd87c4c480ddbaa5c52e3b9 | R | 921 | 33 | library(dplyr)
library(data.table)
args <- commandArgs(TRUE)
indir <- args[1]
pattern <- args[2]
output <- args[3]
stats_files <- list.files(path = indir, pattern = pattern, full.names = T)
stats <- lapply(stats_files, function(x) {
df <- fread(x)
colnames(df) <- c("barcode", "nFrags", "datasize", "min_len",... |
05168078a97245095913097a0588d4c7120824eb028e3ead948e0422b2e514e7 | R | 924 | 34 |
source("load-infomap.R")
infomap <- Infomap("--two-level --silent")
# Add output directory (and output name) to automatically write result to file
# infomap <- Infomap("--two-level . --out-name test")
infomap$addLink(0, 1);
infomap$addLink(0, 2);
infomap$addLink(0, 3);
infomap$addLink(1, 0);
infomap$addLink(1, 2);
i... |
5be8a5eb5cef999ee0b606e3f51c70b490d56f8fa04a613d22cc238ce1695f2e | R | 926 | 35 | usethis::use_package("Matrix")
CovRegOptim2=function(phi, epsilon, corMat_base1, corMat_base2){
phi1=phi[1]
phi2=phi[2]
p=nrow(epsilon)
n=ncol(epsilon)
corMat1=corMat_base1^phi1
corMat2=corMat_base2^phi2
corMat1_norm=sum(corMat1^2)
corMat2_norm=sum(corMat2^2)
corMat12_norm=sum(corMat1*corMat2)
Mat=... |
755568c936ac63621e3c61e793c6913a35a272106036c9b302e54bcc0fe3d854 | R | 941 | 26 | # Gina Norato; gina.norato@nih.gov
library(plyr)
library(tidyverse)
dat<-read.csv(file="Z://Office of Biostatistics/Analyses/16-N-0058/supp table 7 data.csv")
dat$group<-ifelse(dat$group==1,"HV","CFS")
res.dat<-data.frame(vars=vars,mean.hv=NA,sd.hv=NA,mean.cfs=NA,sd.cfs=NA,p=NA)
vars<-tail(head(names(dat)... |
7d05d97ef0b46a3ae524af5d8cc66fc3d9f0afae20d2feab57152f06fabecee8 | R | 943 | 42 | #' @include FamiliarS4Generics.R
#' @include FamiliarS4Classes.R
setClass("familiarHyperparameterRandomSearch",
contains = "familiarHyperparameterLearner"
)
# initialize -------------------------------------------------------------------
setMethod(
"initialize",
signature(.Object = "familiarHyperparameterRand... |
de73a17ddfdffb81b8928dac141dd9f00381176111db409e6f9a471a41fbca0a | R | 946 | 37 | usethis::use_package("Matrix")
constructNNGPinfo=function(distMat, NN=50, start.vertex=NULL){
orders=NULL
m=nrow(distMat)
out=matrix(NA, m,NN)
if (is.null(start.vertex)){
sum.dist=apply(distMat,1,sum)
prev.vertex=which.min(sum.dist)
}
else{prev.vertex=start.vertex}
current.indices=1:m
out[... |
c5dae4a168a99ccaacfa239b6b3104bf2acaaf3510167cc759c8f65dd4d6bbbb | R | 949 | 38 | setwd("/Users/hongbin/Desktop/r work document/")
library(RobustRankAggreg)
#随机数据
set.seed(123)
glist <- list(gene_set1 = sample(letters, 23),
gene_set2 = sample(letters, 21),
gene_set3 = sample(letters, 20))
#统计所有基因出现的次数
freq <- as.data.frame(table(unlist(glist)))
#应用RRA,对基因进行整合排序
ag = agg... |
5789a3ebaaab8e34b492728dc92f5a2e34fcbf1012f9a3d4208f3038af33bb08 | R | 951 | 18 | #' estimate_genome_completeness(taxonomic_completeness = NULL, taxon = NULL)
#'
#' JAMSalpha function. Given a JAMSalpha style taxonomic_completeness data frame, will estimate the genome completeness using the "Percent contig sum over expected genome size" method, for entities which cannot be evaluated using checkM (no... |
2bce99c56a58d7b9e7ff04b5048499d6ff5e41499424e5ea6c90040503dccd91 | R | 963 | 32 | #' filter_correlations(corrmat = NULL, mincorrelcoeff = NULL)
#' Given a pairwise correlation matrix, eliminate features which do not present an absolute correlation coefficient smaller than mincorrelcoeff with all other features other than itself.
#'
#' @export
filter_correlations <- function(corrmat = NULL, mincorre... |
918e62caf6467cf41249ca29c6f1a32928d791514927396d04fd9b28dcba306e | R | 976 | 28 | getFixedEventTimes = function() {
tbl = setNames(as.data.table(excel_to_R(input$events_fixed_list)), c("start", "end"))
tbl$start = as.numeric(tbl$start)
tbl$end = as.numeric(tbl$end)
tbl
}
output$events_fixed_list = renderExcel({
excelTable(default$fixed_list,
allowInsertColumn = ... |
4aee29d55671a9582f9de34e85c4a7ea74ae0fad92b7ba86e6559cfca8d227e0 | R | 979 | 20 | #05. compute DEGs
library(MAST)
# MAST test
SeuratObject@meta.data$Sex2 = ifelse(SeuratObject@meta.data$Sex == 'F', 0 , 1)
latent.vars = c('Age', 'PMI', 'Sex2')
logfc.threshold <- log2(1.2)
result <- list()
for(c1 in levels(Idents(SeuratObject))){
r1 <- try(FindMarkers(object = SeuratObject, slot = 'data', assay = 'RN... |
2ca667ebeed8cc4a816fc2cffbf5b82cb7a76188969bd55d512c0007c869c70a | R | 983 | 28 |
library(data.table)
library(ggplot2)
library(ggtext)
library(tidyverse)
library(qvalue)
library(ggrepel)
test = "Cns.Toxicity"
variants <- read.csv(paste0(
"Resultat/burden/",test, ".tsv")
, sep = "\t")
n_cases = 66
VF_t <- (1/n_cases)^(1/2)
VF_column <- paste0(test, "~rest_VF")
## OBS 2 är cases
case_freq <- ... |
6bdb20c4f3752ccdefd7f8e64f407bf3d61b8ce04f366ad2356b00d9a94aa863 | R | 989 | 20 | # Example codes for calculating connectivity signature score
# Using AddModuleScore function in Seurat
library(Seurat)
SeuratObject <- readRDS('YourSeuratObject.rds')
# Connectivity signature (71 DEGs derived from SR101 scRNA-Seq data)
Signature <- read.csv("ConnectivitySignature.csv",stringsAsFactors = F)
# Conne... |
48e6377a820b45eea9503eae95a0d4e40712ac267292da6a55124c799e51edbd | R | 993 | 29 | plot_corr <- function(df, pal = 'RdBu'){
df <- df %>%
dplyr::mutate(cluster = as.factor(cluster))
df %>%
ggplot2::ggplot(aes(x = term,
y = as.factor(cluster))) +
geom_point(aes(size = abs(filt.t),
colour = filt.t)) +
geom_shadowtext(aes(lab... |
c32b752d3ec00f0732ddfc7c17032d679b320ad4abcec32144a975028aaa8356 | R | 995 | 24 | library(ggplot2)
library(stringr)
library(dplyr)
library(patchwork)
input_path='/scratch/users/banwang3/celllines/ATAC/human/bam/'
xaxis=seq(170822915,170823954)
celltypes = c('CM','HP','MN','PP','SKM')
for (celltype in celltypes){
df = read.csv(paste0(input_path,celltype,'_Hume_Chpe_bigwigCompare.bedgraph'),sep='\... |
03f1870ff748bc312890b2dcf27aaa196e36a79fa225e92f04ab05bcd4f093fe | R | 1,013 | 29 | context("decontam")
test_that("decontam", {
data(esophagus, package="mia")
# setup of some mock data
colData(esophagus)$concentration <- c(1,2,3)
colData(esophagus)$control <- c(FALSE,FALSE,TRUE)
#
tse <- addContaminantQC(
esophagus, method = "frequency", concentration = "concentration")... |
395d6674b95c7a6ff3a3302835930bc7e56ca3c21cf466a20d1b125072b6587c | R | 1,016 | 31 | library(ggplot2)
library(qvalue)
library(ggtext)
library(tidyverse)
df_burden <- read.csv("data/burden_results/burden_allow_all_results.tsv", sep = "\t", stringsAsFactors = F)
q <- qvalue(p=df_burden$p)
df_burden$fdr <- p.adjust(df_burden$p, method="fdr")
df_burden <- df_burden[order(df_burden$p, df_burden$gene, dec... |
69922aa1840a8463eb16855c3ca783d359e62c4d8cb95a47f7d310075c7a5ed5 | R | 1,030 | 20 | #06. subclustering
for(Clust1 in c('6', '7')){
so1 = SeuratObject[, SeuratObject@meta.data[, Ident1] == Clust1]
so1 <- RunPCA(so1, verbose = FALSE)
sds = Stdev(object = so1, reduction = "pca")
print(cumsum(sds^2) / sum(sds^2))
dims = 1:which(cumsum(sds^2) / sum(sds^2) >= 0.9)[1]
dims = 1:10
... |
9d189c6ca2b2d232d0415f9e8637e993dfc265d06427c1ad0939c84cb5858637 | R | 1,030 | 37 | library(plyr)
options(digits = 4)
input <- read.csv(file = 'output.csv',header = FALSE)
njdist <- input[which(input$V1 == 'njdist'),]
sumnj <- count(njdist,"V2")
totalnj<-sum(sumnj[,'freq'])
cornj<-sumnj[which(sumnj$V2 == 0),]
corrnj<-cornj$freq
accnj <-corrnj/totalnj
if(identical(accnj,numeric(0))){
accnj<-0
}
mldis... |
6ea0021c832b5058f8acad7d2495ba72b25f25d80cdb425b5af0424d213b2a0c | R | 1,031 | 48 | #############################
## Strength of retinol IVs (F-statistic and I^2 stat)
## William Reay (2023)
#############################
library(data.table)
library(TwoSampleMR)
library(dplyr)
ivs <- fread("~/Desktop/Retinol_GWAS/MR_all_cis_acting_SNPs/Clumped_retinol_IVs.txt")
## F statistic
F_statistic <- functi... |
1aa56a11b884341f97c54c82b9da8c03a2cebe93ea97f76bfc54f4f69e1e95b0 | R | 1,042 | 25 | context("addNMDS")
test_that("addNMDS", {
mat <- matrix(1:60, nrow = 6)
df <- DataFrame(n = c(1:6))
se <- SummarizedExperiment(assays = list(counts = mat),
rowData = df)
#
actual <- getNMDS(se)
expect_true(is.matrix(actual))
expect_equal(dim(actual),c(10,2))
... |
446d008fb1c243e5fc603ae0b335d75d0ef86735a9d44b6b13f791960779993f | R | 1,043 | 44 | library(tidyverse)
library(data.table)
tests = c(
"Hypersensitivity.All~rest",
"Hypersensitivity.Narrow~rest",
"Fototoxicitet~rest",
"SJS.TEN~rest",
"Cytopenia.All~rest",
"White.Blood.Cytopenia~rest",
"Trombocytopeni~rest",
"Blödning~rest",
"CNS.toxicitet~rest",
"Hypo.Siadh~rest",
"Levertoxicitet... |
8b5e9d0f7a2487a420276a581239edc6bfc3f0b62852366fab30e92bcf75c389 | R | 1,047 | 39 |
# Load igraph library (assuming installed, else do install.package("igraph"))
message("Load igraph library...")
library(igraph)
# Load Infomap library
source("load-infomap.R")
## Zachary's karate club
g <- graph.famous("Zachary")
# Init Infomap network
infomap <- Infomap("--two-level --silent")
# Add links to Info... |
f97f0a21978b5e08f9c41da273d525a9bae614439f61ecb344c81345f113788c | R | 1,060 | 39 | # Don't perform any further tests on CRAN due to running time.
testthat::skip_on_cran()
testthat::skip_on_ci()
# Default
results <- familiar:::test_export_specific(
export_function = familiar:::export_sample_similarity,
data_element = "sample_similarity",
sample_limit = 20L,
debug = FALSE
)
testthat::test_tha... |
ee81d78230094c12e8751b3ad0e33275d1adcf77e24012607df6eb0a51675fb2 | R | 1,064 | 50 | #' @include FamiliarS4Generics.R
#' @include FamiliarS4Classes.R
NULL
# familiarNoneNoveltyDetector --------------------------------------------------
setClass(
"familiarNoneNoveltyDetector",
contains = "familiarNoveltyDetector"
)
# is_available -----------------------------------------------------------------... |
db564d142d4cdf541a9c6604eb91b1d4274268e439eef1c1dc068d400ca1eded | R | 1,065 | 36 | # setup libraries and seed
set.seed(2178)
library(Seurat)
library(VISION)
library(GSEABase)
library(dplyr)
library(here)
library(RColorBrewer)
library(circlize)
library(ComplexHeatmap)
library(tidyr)
library(readr)
library(ggplot2)
library(org.Hs.eg.db)
library(org.Mm.eg.db)
# load data
load(here("data/setbp1_cerebral... |
2895438c867d4057e4c9ee47c0a25822d95296a5dec18cbdabada9eb5945ea41 | R | 1,070 | 42 | library(ape)
library(phangorn)
library(adegenet)
d = read.table("dataset/labels12062021.in", header = FALSE)
d = head(d, 100)
n = length(d$V1)
quintet = c("((1,2),(3,4),5);", "((1,2),(3,5),4);", "((1,2),(4,5),3);",
"((1,3),(2,4),5);", "((1,3),(2,5),4);", "((1,3),(4,5),2);",
"((1,4),(2,3),5);",... |
2916e95fce9865398f1aa8f66e67d744e101f1a7e598364141bcfed8b7bec080 | R | 1,086 | 33 | plot_bl <- function(df, pal, ttl, sttl){
df %>%
dplyr::mutate(for.t = as.character(signif(filt.t, 3))) %>%
ggplot2::ggplot(aes(x = term,
y = as.factor(cluster))) +
geom_point(aes(size = abs(filt.t)),
pch = 21,
stroke = 2,
... |
cdca544f856ec98f4d94dc543ca02e10bf32c4b93e15b1705cd92b76fa782caf | R | 1,086 | 32 | #############################
## Effect of lead SNPs on estimated retinol intake (UKBB - IEUGWAS)
## Dr William Reay (2023)
#########################
library(ieugwasr)
library(dplyr)
library(ggplot2)
library(viridis)
Ret_intake <- associations(c("rs1260326", "rs34898035", "rs11762406",
... |
684b485510628ab7d5d0857ec6708a1281350ab3bb4b9eb7ac540a79a9c8e524 | R | 1,092 | 30 | # Don't perform any further tests on CRAN due to time of running the complete
# test.
testthat::skip_on_cran()
testthat::skip_on_ci()
debug_flag <- FALSE
familiar:::test_plots(
plot_function = familiar:::plot_ice,
not_available_some_predictions_fail = FALSE,
data_element = "ice_data",
debug = debug_flag
)
# ... |
b0f949e7a91cfd9e039afab7d76606154839c6e64038ff838b79dd414dd9c799 | R | 1,092 | 25 |
print('Loading R packages ...')
library(scales) # to use 'show_col' function
library(ggpubr) # to use 'ggarrange' function
# also has a mutate function so load it early
library(plyr) # load plyr before dplyr (within tidyverse)
# to use 'adply', mapvalues function
librar... |
41cbff3f58aa3ab58fa5c8c3058fc1922fdf3450a998d8f15a55c85892c0cbb9 | R | 1,118 | 44 | testthat::skip_on_cran()
testthat::skip_on_ci()
# Perform an integrated test. Note that learner is set automatically.
familiar:::integrated_test(
backend_type = "none",
experimental_design = "bt(fs+mb,20)",
parallel_nr_cores = 2,
vimp_method = "none",
cluster_method = "none",
imputation_method = "simple",
... |
ec2b40240470538ab979e96ec13e33176dc4c8175315c4118fa28b3120b9ffee | R | 1,119 | 25 | # Example codes for cell state assignment based on cell state signature score
# Using AddModuleScore function in Seurat
library(Seurat)
SeuratObject <- readRDS('YourSeuratObject.rds')
# Cell state signatures obtained from Neftel et. al. 2019
CellStateSignatures <- read.csv('CellStateSignatures.csv',stringsAsFactor=F,... |
25fffca79fe7134cfc52d0edc9747457a7d2c0b9403b51b2f9e4cfac2bf1558d | R | 1,123 | 30 | #heatmap
setwd("/Users/hongbin/Desktop/r work document/")
library(pheatmap)
library(ggplot2)
df1 <- read.csv("dem exp heatmap.csv",header = TRUE, row.names = 1)
df2 <- as.matrix(df1)
an_col <- data.frame(Group = c(rep("WT-3xTg",8),rep("3xTg-AD",8)))
row.names(an_col) <- colnames(df2)
g_col <- c("#25B678","#888AC3")
na... |
c8ca638928f722283a6b9b65aa51c7107eb0ca543c5ab31dc23f24961040d763 | R | 1,125 | 33 |
getIntervalNames = function() {
intervals = setNames(as.data.table(excel_to_R(input$events_intervals)), names(default$intervals))
return(intervals$name)
}
getIntervals = function() {
setNames(as.data.table(excel_to_R(input$intervals)), names(default$intervals))
}
observeEvent(input$events_inter... |
cdbef52114c5396f35d9efb6e62fda1602a6c4a4e1130771208c27abed0acdfe | R | 1,128 | 30 | #heatmap
setwd("/Users/hongbin/Desktop/r work document/")
library(pheatmap)
library(ggplot2)
df1 <- read.csv("heatmap + rra pathway.csv",header = TRUE, row.names = 1)
df2 <- as.matrix(df1)
an_col <- data.frame(Group = c(rep("WT",8),rep("3xTg-AD",8)))
row.names(an_col) <- colnames(df2)
g_col <- c("#25B678","#888AC3")
n... |
7312692f043a0e478d187a3e86a9d5d2f1d65f43db34f37d8d7fb92726d74839 | R | 1,129 | 44 | ##################################
## Effect of body fat % on retinol associated brain regions
## William Reay (2023)
##################################
library(data.table)
library(dplyr)
library(TwoSampleMR)
setwd("~/Desktop/Retinol_GWAS/MR_all_cis_acting_SNPs/")
## Import IVs for body fat %
BF_IVs <- extract_i... |
da272491400013a24e55d937ff2bc0d4f18f8b99efd30987244ba6e773b29b2f | R | 1,139 | 38 | ###########################
## Selecting exposures to test with retinol as outcome
## Dr William Reay (2023)
###########################
library(dplyr)
library(ieugwasr)
library(data.table)
setwd("~/Desktop/Retinol_GWAS/MR_retinol_as_outcome/")
List_of_traits <- fread("../IEUGWAS_available_outcomes.txt")
## Step... |
30889a0f8567bb519e7d5c33547e92003e322fd2eb8e189ca61c9af6b9ae4f49 | R | 1,141 | 37 | # Don't perform any further tests on CRAN due to time of running the complete test.
testthat::skip_on_cran()
testthat::skip_on_ci()
debug_flag <- FALSE
# Default
familiar:::test_export(
export_function = familiar:::export_risk_stratification_info,
not_available_some_predictions_fail = FALSE,
not_available_no_sa... |
d3e693a9875f8a8397d05f9e5e26a71162f9c511bd1792a30021a87e868e8f85 | R | 1,154 | 41 | usethis::use_package("Matrix")
buildNNGPmat=function(distMat, NNGPinfo, params, kernel = "exp"){
m=nrow(distMat)
A=matrix(0,m,m)
D=matrix(0,m,m)
phi=params$phi
sigma2=params$sigma2
tau2=params$tau2
k=params$K
f.exp=function(phi, d){ exp(-phi*d) }
f.gau=function(phi, d){ exp(-phi*d^2/2)}
for... |
b3e63cf5c3ef9c6e729698ebe1b02f21714d4253caf92ea359fe7245a28c076d | R | 1,155 | 34 | library(ape)
library(phangorn)
## read true trees
d = read.table("labels4728283-0.5-10.0-0.01.in", header=FALSE)
n = length(d$V1)
## labels from the simulating script:
quartets = c("((1,2),(3,4));", "((1,3),(2,4));", "((1,4),(2,3));")
## to which quartet the label corresponds to:
truetree = read.tree(text=quartets[d[n,... |
e212b31c448c90f6556409d0b9ff183025c2162931a122100c0765a9bf91568b | R | 1,162 | 31 | # Don't perform any further tests on CRAN due to running time.
testthat::skip_on_cran()
testthat::skip_on_ci()
debug_flag <- FALSE
# Default
familiar:::test_export(
export_function = familiar:::export_model_performance,
data_element = "model_performance",
not_available_all_prospective = TRUE,
not_available_mo... |
e6ada929ae9b3d0249005d9dc4c885dcf737cca5a21e8089469125012a2adf41 | R | 1,165 | 36 | library(ape)
library(phangorn)
library(adegenet)
## Reading fasta file
aa = read.aa(file="test0.fasta", format="fasta")
## Write as nexus file
write.nexus.data(aa,file="test0.nexus",format="protein")
aa = read.aa(file="test1.fasta", format="fasta")
write.nexus.data(aa,file="test1.nexus",format="protein")
aa = read.... |
7803dc4b7d91526307a83b899c42457efa71723a1f179f0c75165000edbb360a | R | 1,198 | 35 | # Load mia R package
library(mia)
# Set file paths for input data
biom_file_path <- "PATH_TO_BIOM_FILE"
sample_meta_file_path <- "PATH_TO_SAMPLE_METADATA_FILE"
tree_file_path <- "PATH_TO_PHYLOGENETIC_TREE_FILE"
# Load data from the biom file into a TreeSummarizedExperiment container
tse <- importBIOM(biom_file_path, ... |
43e22415f9325f24f0d6107ecebdb779113420f0df229deaea9c07dad32b68b3 | R | 1,222 | 31 | # Function for detecting if the user has an outdated version of JAMS
.onAttach <- function(libname, pkgname) {
# find dir and run git fetch
jams_dir <- packageDescription("JAMS")$RemoteUrl
if (is.null(jams_dir)) {
jams_dir <- file.path(Sys.getenv("HOME"), "bin", "JAMS_BW")
if (!fil... |
571465aef953424aca06eb2f8684258838545da6ae22e80f74ab69030cce2687 | R | 1,222 | 32 | ##########################################
## Retinol GWAS meta - annotate METSIM+INTERVAL with dbSNP
## William Reay (2022)
##########################################
library(dplyr)
library(data.table)
setwd("~/data/users/william/Meta_retinol_GWAS")
MET_IVW <- fread("~/data/users/william/Meta_retinol_GWAS/Meta_a... |
efb4140559e0945207ff4efcf649d7c4dba719ca309f986b12ad6e1d885629fe | R | 1,227 | 39 | #' bank_reads
#'
#' JAMSalpha function
#' @export
bank_reads <- function(opt = opt){
#Check if reads are in tmpdir
if (opt$workdir != opt$sampledir){
readsworkdir <- file.path(opt$workdir, "reads")
} else {
readsworkdir <- opt$readsdir
}
setwd(readsworkdir)
if (opt$host != "non... |
696245e1bd522ee18728b0dee057c75a3e5dad20742b9d218992aa12ba8a7e14 | R | 1,241 | 36 | #' launch_interpro
#'
#' JAMSalpha function
#' @export
launch_interpro <- function(opt = NULL){
#Set working directory to sampledir
setwd(opt$sampledir)
#Discard proteins with stop codons in them, as this blocks interpro
CDSswithstop <- names(which(sapply(names(opt$proteome), function (x) { length(gr... |
b20f958bf61612026af3b344c31709340e23d90ab61e30acdf05f0d35ee667fc | R | 1,258 | 50 | #############################################################
###################### LOAD LIBRARIES #######################
#############################################################
## to generate time series
if (!require(timeSeries))
install.packages('timeSeries')
if (!require(fracdiff))
install.packages('f... |
2f88de32b242b59f12d81f75ae21a479b37199fceb557bc607a2b06c6e6b21a1 | R | 1,259 | 37 | # Calculate spatial correlation and Dice coefficients for Limited vs Amplified maps
# Inputs:
# Limited motion beta coefficient map
# Amplified motion beta coefficient map
# Limited motion tstat map of significant positive voxels
# Amplified motion tstat map of significant positive voxels
# Brain mask
library(oro.nif... |
191abc5bfebad1348a2570c265db709380139ad40bf6350f6e983096ac643d14 | R | 1,268 | 32 | library(argparse)
parser <- ArgumentParser()
parser$add_argument("--generator", default="GLI2_1")
args <- parser$parse_args()
folder_name=args$generator
input_path = paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/sei/')
output_path=paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/s... |
b7050760052ecef7b4e011d4867fb170857138bd0dcbbc17b8fdd2e02cadcb81 | R | 1,269 | 44 | patmotJSON <- function(path){
require(rjson)
json <- fromJSON(file = path)
motparam_fd <- c(NA,json$motparam_fd)[1:2300]
motparam_fd_outlier <- (motparam_fd > (1.5 * IQR(motparam_fd,
na.rm = TRUE) + quantile(motparam_fd,
... |
c217feafc89d52e2685c5654d2926b007bcdf0f13ceb29f324cd8900c6e10d75 | R | 1,270 | 26 | #############################################################
##################### SYNTHETIC DGP #########################
#############################################################
#######################################################
## simulate Synthetic DGP's
## linear models
WN_ts <- gera_TimeSeries(T, th... |
49438454f5e9610d69d2b80b86919e25e62b3fdb466dd4f9ef9152fa0f543d47 | R | 1,271 | 32 | library(argparse)
parser <- ArgumentParser()
parser$add_argument("--generator", default="GLI2_1")
args <- parser$parse_args()
folder_name=args$generator
input_path = paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/sei/')
output_path=paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/s... |
34c7de9788dec990523890fde897194f26631fd2c2c887b97610d74ab6f6dd07 | R | 1,272 | 40 | safe_spLeverage <- function(res, distmat, sacf = c("mix"), nngp, nngp.J) {
try_spLeverage <- function(method) {
tryCatch({
out <- spLeverage_op(data = t(res), distmat = distmat, sacf = method, nngp = nngp, nngp.J = nngp.J)
phi <- out$params.covariance$phi
sigma2 <- out$params.covariance$si... |
f4734e0374a245c64213e9c450e0d5584e5f20c49b690efe49b37d9e44ee0f15 | R | 1,283 | 24 | #' EEG decision-making data from Nunez et al. (2017)
#'
#' This dataset contains EEG data from a decision-making task described in Nunez et al. (2017)
#'
#' Nunez, M. D., Vandekerckhove, J., & Srinivasan, R. (2017).
#' How attention influences perceptual decision making: Single-trial EEG correlates of drift-diffusion m... |
b9eb5357b07e9a12798a378415fd3aaa418795436046ae239059c1cc03ddf3cb | R | 1,284 | 27 | ## Assessing our SNPs for ones that are incorrect and should be thrown out
## Human genome
human_snps = read.table("/Users/rachelagoglia/Desktop/GRCH38_SNPreview.ALL.SPLIT_SPECIES.txt", header=FALSE)
expLvl_human = human_snps$V3+human_snps$V4+human_snps$V5
expLvl_chimp = human_snps$V6+human_snps$V7+human_snps$V8
perc... |
f63e4151928ca1e19bd45b2b34c7871fbb4623598749bebf635d82c5ba009893 | R | 1,285 | 42 | #############################################################
################### TIME SERIES MAPPINGS ####################
################### QUANTILE GRAPHS ####################
#############################################################
#######################################################
#### Quantile Gr... |
ccd5dd6cea8cde696ae54e876da842e4237c30fb88327b2e1c97001cdffff93c | R | 1,307 | 42 | #!/usr/bin/env Rscript
set.seed(2178)
# Load necessary libraries
library(dplyr)
library(decoupleR)
# Fetch command line arguments
args <- commandArgs(trailingOnly = TRUE)
rdata_file <- args[1]
prior_net <- args[2]
cell_type <- args[3]
tissue <- args[4]
min_n <- as.numeric(args[5])
print(rdata_file)
print(prior_net)... |
84a92e387d10ed41960b194b6c4bd38d30149e5be3f74676eb27479505c71a30 | R | 1,316 | 52 | ################ EXTRACT MRIDATA SEPARATED FOR REFERENCING PROTOCOLS
colnames(mridata)
mridata_long <- gather(
data = mridata,
key = biomarker,
value = conc,
BG.Cho:PWM.Ins.Cr,
factor_key = T
)
mridata_long$region <- rep(c("Basal Ganglia", "MidFrontal Gray Matter", "Peritrigonal White Matter"),... |
2c2eba8ac18180d811511a8c36292c3ed24c0efb28a3f85d3836cbc9761c69b4 | R | 1,317 | 27 | test_that("getPCA and addPCA", {
data(GlobalPatterns, package = "mia")
# The signs of the components from scater::calculatePCA() can differ
# between identical calls, so components are compared up to their sign
expect_same_pca <- function(res, ref){
expect_equal(unname(abs(diag(cor(res, ref)))),... |
4069a225effb0d85070d99eaf68b98dcc8cb0703d63587f5a13bc79fbaf63be9 | R | 1,320 | 29 | library(ggplot2)
library(scales)
output_path='/scratch/users/banwang3/references/scripts/seifigures/'
SNP=read.csv('SNPlist_hg38_4096bp.bed',sep='\t',header=F)
windowstart = SNP$V6[1]
windowend= SNP$V7[1]
SNP=SNP[,1:3]
colnames(SNP)=c('chr','start','end')
SNP$label=paste0('SNP',seq(1,nrow(SNP)))
SNP$order=seq(1,nrow... |
1f288f35373971c68779deca6466327776061082f1372a3c6da8163de82222db | R | 1,321 | 29 | library(ggplot2)
library(scales)
output_path='/scratch/users/banwang3/references/scripts/seifigures/'
SNP=read.csv('SNPlist_hg38_4096bp.bed',sep='\t',header=F)
windowstart = SNP$V6[1]
windowend= SNP$V7[1]
SNP=SNP[,1:3]
colnames(SNP)=c('chr','start','end')
SNP$label=paste0('SNP',seq(1,nrow(SNP)))
SNP$order=seq(1,nrow... |
e6a85eb9f9c1afcd9028e693c46112319b8a58bb3a0659bbe5fb32cbadcb463c | R | 1,321 | 33 | folder_name='FABP7'
input_path = paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/sei/')
input_path1=paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/sei1/')
output_path=paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/sei/')
align2='hg38'
df1 = list.files(input_pat... |
81b5aff167c13e77b7e742d48ead02a528ef3432154a24aa249f37e107f0673f | R | 1,323 | 33 | #' reformat_completeness_to_CheckM_style(completeness_df = NULL)
#'
#' JAMSalpha function
#' @export
reformat_completeness_to_CheckM_style <- function(completeness_df = NULL){
#I know a loop in inefficient, but keeping it safe for now.
for (rn in 1:nrow(completeness_df)){
#If Completeness is NA, set t... |
39b1657e4fc7f4751427aba5e0353fece376dd0269d3bb84f012bc43b8a53646 | R | 1,324 | 28 |
observeEvent(input$data_ratio_finish, {
data$raw[[input$data_dataset]][, (input$data_ratio_name) := get(input$data_ratio_num) / get(input$data_ratio_den)]
# update variables
variables = names(data$raw[[input$data_dataset]])
updatePickerInput(session, "data_plot_x", choices = variables, selec... |
1e7b53f56aa2133a53ab0907dce700f83a52675a77c34c51cd1886072301f19c | R | 1,331 | 39 | #' Get an example
#'
#' @param name The name of the example
#' @param type The name of sampler template
#' @param filename What filename you want to save (defaults to the name of the exercise in the working directory)
#'
#' @return Saves a file to the working directory (or path from filename)
#' @export
#'
#' @examples... |
7b950b7e8f8950cc389f557d31d0df2023bae339aed67ec750e4cbbec24e6b5c | R | 1,337 | 41 |
# function for model simulation
FuncModelSimu = function(tmpdata,alpha,theta,nodors,ncues){
# func works on a single run's data: tmpdata
# alpha: learning rate (0-1)
# theta: temperature in softmax (>0)
# nodors: # of odors
# ncues: # of cues
ntrials = nrow(tmpdata)
Cue = tmpdata$Cue
Odor = tmpdata... |
9f02c98708d4db9919aaf2aedaa799fd88d935dcaf9cb495ee9d8609105aefa9 | R | 1,343 | 28 | # NOTE: be sure to run this script to set up list of files BEFORE constructing networks with '02_PANDA_array.sh' bash script.
# This script was run inside of JW docker container jordanwhitlock/setbp1_manuscript:1.0.5 (setbp1_manuscript_1.0.5.sif) using Singularity/3.5.2-GCC-5.4.0-2.26
set.seed(2178)
##Load libraries... |
af8d795ba567a87f408f313274b20db76c8eff6ef0c1e830b757c594df4add12 | R | 1,365 | 54 |
.calc_observed <- function(mat, detection = 0, ...){
if( !.is_a_numeric(detection) ){
stop("'detection' must be numeric value.", call. = FALSE)
}
colSums(mat > detection)
}
.calc_chao1 <- function(mat, ...){
# Required to work with DelayedArray
if(is(mat, "DelayedArray")) {
mat <- ... |
cea86bb1a42d269fb194b118db058beb22ced9fb41bb0d86b0d8de6646b5f68a | R | 1,365 | 59 | test_create_generic_info <- function(
data
) {
# Setup feature info task.
feature_info_task <- methods::new(
"familiarTaskGenericFeatureInfo"
)
# Feature information objects are created from the bypass dataset.
feature_info <- .perform_task(
object = feature_info_task,
data = data
)
... |
7ee75a7016296430cab373f08e9e4e158bcc7a9f5b68f5e1226cd815ef657cc5 | R | 1,366 | 37 |
context("Overlap")
test_that("Overlap", {
# Get data
data(esophagus, package="mia")
tse <- esophagus
# Test input
expect_error(
getDissimilarity(tse, method = "overlap", assay.type = "relabundance", detection = 0.15))
expect_error(getDissimilarity(tse, method = "overlap", detection = ... |
329d0c2568d8e9c090c2b6a2411ad7bb47f949d7be9b4526c0458198e9b8169c | R | 1,369 | 37 | #' consolidate_tables(opt=opt)
#'
#' JAMSalpha function
#' @export
consolidate_tables <- function(opt = opt, elements = NULL, taxonomic_spaces = c("Contig_LKT", "MB2bin", "ConsolidatedGenomeBin")){
valid_taxonomic_spaces <- taxonomic_spaces[taxonomic_spaces %in% colnames(opt$featuredata)]
#Consolidate resfin... |
95cd189e1a034dab2c48132463a712e19d968254caf45f9582f5a3eadc16cef9 | R | 1,371 | 51 | library(R.matlab)
library(tidyverse)
library(ggplot2)
library(ggpubr)
figPath = "Z:/projects/ANLS Modeling/Figures/"
setwd("C:/Work/MatlabCode/projects/HMASandbox/HMA_Sandbox/Single-cell Modeling/NeuronModeling/")
############################################
# Fig Half-lives
#########################################... |
7b009ca5a236281969b35b8c6cbedd7445709ac1eb18fe18b7943e9da3276791 | R | 1,383 | 45 | library(stringr)
library(argparse)
parser <- ArgumentParser()
parser$add_argument("--generator", default="FABP7")
args <- parser$parse_args()
foldername=args$generator
input_path=paste0('/scratch/users/banwang3/references/outputs/',foldername,'/')
align2s=c('hg38','pantro6')
for (align2 in align2s){
filename=paste0('SN... |
4388fe256b2f9fb7868f487e15ac4a45ebf5554e2b36843c005495333450225e | R | 1,396 | 50 | ---
title: "Test_GGSEG"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(ggseg)
library(patchwork)
library(tidyverse)
```
```{r}
plot_region <- function(region, atlas){
x = data.frame(
region = region,
region_to_fill = region,
stringsAsFactors ... |
e30256394009bf5977710613aa801b0cc82c589f93d588e90e8bd7065da7bdec | R | 1,399 | 33 | folder_name='FABP7_centeratpromoter'
input_path = paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/sei_pantro6/sei/')
input_path1=paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/sei_pantro6/sei1/')
output_path=paste0('/scratch/users/banwang3/references/outputs/',folder_name,'/sei_pa... |
21dd0fffad98edda94b2b105ce1760854dcc1a3f060fcb6e300727dc7ae923f7 | R | 1,421 | 32 | identify.binary.events = function(dt, t, x, inverted = F) {
suppressWarnings({
signal = as.numeric(dt[, get(x)])
})
signal[which(is.na(signal))] = 0
signal[which(is.null(signal))] = 0
assert_that(length(unique(signal)) == 2, msg = "more than just 0 and 1 in selected binary event variab... |
7169f3ebd05fb9529aec33b6f833eae1c6af51cf01cf45b2fc29f7ca6e5e42c2 | R | 1,422 | 51 | library(R.matlab)
library(tidyverse)
library(ggplot2)
library(ggpubr)
figPath = "Z:/projects/ANLS Modeling/Figures/"
setwd("C:/Work/MatlabCode/projects/HMASandbox/HMA_Sandbox/Single-cell Modeling/NeuronModeling/")
############################################
# Fig Half-lives
##############################... |
279422a47391f280a7e4999fd093db51ae106c6d28a6f65f4ba02f7bf2122f92 | R | 1,437 | 42 | # Avoid warnings due to non-standard evaluation in data.table.
outcome <- outcome_time <- NULL
for (outcome_type in c("continuous", "binomial", "multinomial", "survival")) {
# Generate data.
data <- familiar:::test_create_good_data(outcome_type = outcome_type)
data@data[, "batch_id" := "A"]
data_b <- familiar:... |
e6cb62fddc9e266d71fc6b36dc3eba5cdc1b49304b3aa53266e8fc9e8fe2b8c9 | R | 1,445 | 57 | library(rjson)
library(dplyr)
library(tidyr)
library(tibble)
library(feather)
library(R.matlab)
source("patmotJSON.R")
source("outliers.R")
mat <- R.matlab::readMat("../data/2020_04_MASTER_connectomes90_AllFCrerun2_withSCifAvailable_shard4_584subjs.mat")
pma <- unlist(mat$pma)
sub <- unlist(mat$sub)
ses <- unlist(mat... |
dcf790b658c57b0dfd0451ae5543ea44f975e9ae437e941ddd8d956a50c94909 | R | 1,453 | 48 | ##############
### Script ###
##############
# Script to get marginal posterior of gamma under prior v0=0 plots across range of spike variances in backwards DPE procedure.
# (Code for Simulation Study)
#################
### Libraries ###
#################
library(ggplot2)
library(latex2exp)
############
### Plot ##... |
240f9838673ea493d01c2ee68dfe6560016531a4a7a13ffd1ff3b18fd500ebfa | R | 1,461 | 55 | iDeepViewLearn_checkpy <- function(python_path){
library(reticulate)
use_python(python_path)
py_config()
if (!py_available()) {
stop("python not available")
}
# Check python packages
print("The following packages used in the functions shoule be pre-installed with python:")
print("random, itertool... |
127e092c57c250d5965c8bf21cf7d81208ec7d66d73ad70f6f4aa51cef4f91c2 | R | 1,471 | 52 | # Don't perform these tests on CRAN due to running time.
testthat::skip_on_cran()
testthat::skip_on_ci()
debug_flag <- FALSE
outcome_type_available = c("continuous", "binomial", "multinomial", "survival")
for (outcome_type in outcome_type_available) {
# Create dataset
full_data <- familiar:::test_create_good_dat... |
7bea6b04036d26eb7a512fdf09d087c9cd20ea1e1dc53d7cc0ee10f3b331b458 | R | 1,493 | 39 | args <- commandArgs() #extract the argument given on the command line
print(args)
expr_table_dir <- args[6] #complete directory of input expression table
output_dir <- args[7] #directory of output table
output_name <- args[8] #name of output table
packages_dir <- args[9] #directory of R packages
lioness_dir <- args[10]... |
0a2365a65868c63d502c59e8f317c5ca7c482f90c880b53a06c0aed546fb2f8e | R | 1,502 | 25 | SSN_edges_part1 <- function(expr_data, sample){
sample_name <- colnames(expr_data)[sample] ###
print(sample_name) ###
expr_data_m <- data.matrix(expr_data)
print(dim(expr_data_m))
n <- dim(expr_data_m)[2]
PCC_ref <- cor(t(expr_data_m)) #pearson correlation network of all samples
PCC_ref_zs <- cor(t... |
b08aedc70fa458dd49f9a143112c8f07b655f0a655a445fadf1f14ad0b94a5ff | R | 1,504 | 32 | iDeepViewLearn_test = function(python_path,
X_train, X_test, best_comb, features, model, clf,
y_train=NULL, y_test=NULL, outtype = NULL,
top_rate=0.1, edged=NULL, vWeightd=NULL, epochs=1000L,
plot... |
51c786513167105e6d36cd3ba5984acc69d8d8f43ae567e01afd8410559eadaa | R | 1,508 | 54 | # Script for subsetting GTEx TPM counts for SETBP1 and its known targets
# (aggregated across sources in 01_setbp1_combine_targets.R script)
# load in package libraries
suppressPackageStartupMessages({
set.seed(2178)
library(here)
library(tidyverse)
library(data.table)
})
# load in the input data needed and ... |
51596484a0601b89d794236d07ad34605e7b6225f4490b0f5670c32a741e54b4 | R | 1,515 | 50 | # Don't perform tests on CRAN due to time of running the complete test.
testthat::skip_on_cran()
testthat::skip_on_ci()
# debug flag
debug <- FALSE
# Create datasets
full_data <- familiar:::test_create_good_data("binomial")
full_data@data <- full_data@data[1L:20L]
# Set learner
learner <- "lasso"
# Parse hyperpar... |
48de6e38cfd85a91c7ea52735a35227dfacba980d8d1aef6eb245f524f02b1a4 | R | 1,539 | 55 | #############################
## Bidirectional retinol MR effects
## Dr William Reay (2023)
#############################
library(data.table)
library(dplyr)
library(ggplot2)
setwd("~/Desktop/Retinol_GWAS/")
## Read in ret as exposure (IVW-MRE)
Ret_exp <- fread("MR_all_cis_acting_SNPs/All_MRE_IVW_results_ret_as_e... |
cf1452a0fb0fe033ea2f24344502c02145a6a7ed56c06bb5b74cddc11ab6caaf | R | 1,547 | 61 | library(ape)
library(phangorn)
library(adegenet)
## Reading fasta file
aa = read.aa(file="test0.fasta", format="fasta")
## Estimating evolutionary distances using same model as in simulations
D = dist.ml(aa, model="Dayhoff")
## Estimating tree
tree = nj(D)
## Saving estimated tree to text file
write.tree(tree,file... |
45cfa0b85d316c061ad7745a7dc9ee8b33cc3541978d3c4d283531011912fccf | R | 1,564 | 45 |
.get_overlap <- function(x, detection = 0, ...){
############################# INPUT CHECK ##############################
# Check detection
if (!.is_numeric_string(detection)) {
stop("'detection' must be a single numeric value or coercible to ",
"one.",
call. = FALSE)
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.