sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
a9795c2b0e01f819421e29e2656e3c54e936524f07784730049541adc5572450 | R | 382 | 13 | #Load package
suppressMessages(library(qvalue))
#Read command line arguments
args <- commandArgs(trailingOnly = TRUE)
try(if(length(args) != 1) stop("Incorrect number of arguments, usage> Rscript pi1.R INPUT"))
opt_input = args[1];
#caucalate pi1
a<-read.table(opt_input)
library(qvalue)
pi0<-pi0est(a$V1,... |
50f1688f01ac04d909011aa74522bc2d8990ec3b9aaa68e335fade8c5a4ed376 | R | 389 | 18 | #### Notes ####
#### Libraries ####
library(matrixStats)
#### Sourced functions ####
#### Functions ####
# Convert expression matrix to z-score matrix
compute_zscore <- function(expr.matrix) {
means <- rowMeans(expr.matrix, na.rm=TRUE)
sds <- matrixStats::rowSds(expr.matrix, useNames=TRUE, na.rm=TRUE)
zsco... |
9acff3b747e529500b787e18583a522f9ed3b63a21e1564312d9217995730096 | R | 398 | 12 | library(ggplot2)
a <- 0.5
b <- 2
mDat <- do.call(rbind.data.frame, lapply(1:20, function(i)
data.frame(postProb=sapply(0:i, function(j) (a+i-j) / (a+i+b)), coverage=i, notMod=0:i)))
pdf('test_priors.pdf', width=8)
ggplot(mDat) + geom_tile(aes(x=coverage, y=notMod, fill=postProb)) +
theme_bw() + scale_fill_gr... |
ccfafee986811b4916c686c0b6a1de6058bc411f0666b32ab20d6865f6ad8630 | R | 402 | 12 | # This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/spec... |
7cf7ebf16f3d523a553514736432e8d6e0cfee52f210e0f9bac68d582e294c2a | R | 409 | 12 | library(data.table)
covar = fread("data/adc/adc_np.covar")
pheno = fread("data/adc/adc_np_ord.txt", na.strings = "-1")
covar = merge(covar, pheno[, .(IID, cerad)], "IID")
covar = covar[!is.na(cerad)]
covar[, cerad1 := ifelse(cerad == 1, 1, 0)]
covar[, cerad2 := ifelse(cerad == 2, 1, 0)]
covar[, cerad3 := ifelse(cerad... |
0a56435b6c38c69da22568c120996b1a67215842afda41a451eee2b52cdd0047 | R | 412 | 15 | # install_packages.R
options(repos = c(CRAN = "https://cran.rstudio.com/"))
# Function to install a package if it's not already installed
install_if_missing <- function(package) {
if (!require(package, character.only = TRUE)) {
install.packages(package)
}
}
# Install each package individually
install.packages... |
7106f825a8deaa4c1375f2d762ac337b87a4038891f70a7dc64ade5526015b84 | R | 418 | 14 | #===================================
# write text files of POLMM results
#===================================
library(data.table)
library(argparse)
parser <- ArgumentParser()
parser$add_argument("-r", "--rds", help = "results .Rds file")
parser$add_argument("-o", "--out", help = "output file name")
args <- parser$par... |
231c359a503b57ed80a1adae161986ca429939c4ef3c4a117420ab9965789e0d | R | 422 | 10 | library(data.table)
library(ggplot2)
gwas = readRDS("output/coloc/meta/caa_apoe/GWAS/gwas_rs7247551.Rds")
cg13 = readRDS("output/coloc/meta/caa_apoe/ROSMAP/Brain_Prefrontal_Cortex_cg13119609_rs7247551.Rds")
cg13_pdata = merge(gwas$dataset, cg13$dataset, by.x = "rsID", by.y = "snp")
cg13_pdata[, ggplot(.SD, aes(-log10(... |
1306d978472320c1e614926033a7b1fe4227039ec0fbcac9c4ba6b970cef98b8 | R | 423 | 24 | #!../r
# This should dynamically load stats
cat("Is stats loaded?\n");
cat("search: ",search(),"\n");
if(!("package:stats" %in% search())){
cat("Nope!\n");
}
cat("Calling ts(1:10)\n");
cat(ts(1:10),"\n");
cat("Now stats is loaded!\n");
cat("search: ",search(),"\n");
if(!("package:utils" %in% search())){
cat("N... |
090303a2521ca4f96fde75c8a7f2c97ce39330d935bf0a75166d4a2fd659e4b1 | R | 426 | 12 | get_nodelabel_tips <- function(data_plot, node_label) {
#' returns vector of tips descendants for a node label
#' @param data_plot plot$data
#' @param node_label the label of node, not node number
#' Note: descendants_tips_from_node computed previously
# get_nodelabel_tips(tp1$data, "N186")
data_plot %>%
... |
f3a338393ac57503339932828308b9df3e0761f6e5cf18f32c66d9184b7f3bae | R | 428 | 16 | # restore_environment.R
# Read the CSV file into a data frame
package_info <- read.csv("R_environment.csv", stringsAsFactors = FALSE)
# Install packages from the data frame
for (row in 1:nrow(package_info)) {
install.packages(
package_info[row, "Package"],
version = package_info[row, "Version"],
depend... |
b5ffc001248862765f4f1dab985a4038881592b063f6078a7dbb92a1f28f4e26 | R | 437 | 18 | library('NuPoP')
nupop_input_dir <- '../nupop_input_temp/'
# list all files in the input directory
files <- list.files(nupop_input_dir, pattern = "*.seq")
# for loop to run NuPoP on each file
for (file in files) {
file_ = paste0(nupop_input_dir,file)
# run predNuPoP on each file
predNuPoP(file_,species=1,mo... |
272ee6c6db37f177e9459cae0a809d16793f248ab619d678742e8ba9e0c6b933 | R | 445 | 20 |
setClass("ora_result", representation(
gene = "character",
database = "data.table",
pAdjustMethod = "character",
output = "data.table"
)
)
setClass("userdata", representation(
raw = "data.table",
main = "data.table",
rawidentifiers = ... |
fd35febdac3058ea8b9fe3c474fc237b0bc1ee0967992be23ed62a7d9029a6fc | R | 461 | 17 | ## Author: Jonathan Rosenblatt and Jason Stein
## Suggest default step size
defaultStepSize <-function(list1, list2){
n1<- dim(list1)[1]
n2<- dim(list2)[1]
result <- ceiling(min(sqrt(c(n1,n2))))
return(result)
}
### Testing:
## list.length <- 100
## list.names <- paste('Gene',1:list.length, sep='')
## gene.... |
1b07e028964cd88b72daab5ff3c60f7bf85dd8ac5f746a104966e7761390cb00 | R | 464 | 18 |
#source('AnalyseExperiment.R')
source('AnalyseExperimentShort.R')
knn = 10
folder<-'D:/CA1SR'
resfolder<-paste(folder,'/Res/', sep="")
dir.create(resfolder)
dataname <-'Day1CA1SRPCF'
pb<-read.csv(paste(folder,'/',dataname,'.csv',sep=""), col.names = c("x", "y", "z"))
png(paste(resfolder,'/',dataname, '... |
0344cbf33d90eb965d832fe8202278d749d0b1b8b0b65ca6bdbbee24b4ab44cb | R | 466 | 12 | # ============================================================================
# This code prepares internal datasets
# ============================================================================
# Dataset `fluNA` ------------------------------------------------------------
fluNA <- hyperSpec::flu
fluNA[[2, ]] <- NA
... |
73d1c457a107cfdcd6857fa11484a75f6e901c9ad820afa66e96f931a3e281a8 | R | 466 | 12 | #' Vectorized version of get_label_from_node function
#'
#' This function vectorizes the get_label_from_node function, allowing it to accept
#' a vector of node numbers as input and return a vector of corresponding labels.
#'
#' @param node_number A vector of node numbers.
#'
#' @return A vector of node labels correspo... |
0943dc930ea64463261361b5b72a00db3cbe2ec67de2bd5cf44de048e0d0412e | R | 473 | 11 | ## This script converts Rdata files to txt format
library(GenomicRanges)
inputDir="/data/clusterfs/lag/users/gokala/beat-dyslexiaevol/results/gSEM/"
for (i in list.files(inputDir, pattern="multivarGWAS_dys_rhyimp_v2.RData", all.files=F, full.names=F)) {
tmp_dir=gsub(" ","", paste(inputDir,i), fixed=T)
print(... |
fd450e7a330d88c39741932539104b33ca3788c3fce605352c0d1b94afdc868c | R | 473 | 20 | compsplit <- function(x, split) {
if (split %in% gs("special.characters"))
split <- paste0("\\", split)
res <- strsplit(x, split)
if (is.list(res)) {
withspace <- any(unlist(lapply(res, grepl, pattern = "^\\s+|\\s+$")))
res <- lapply(res, gsub, pattern = "^\\s+|\\s+$", replacement = "")
}
els... |
38d9d1b20a3d739f13a492d2c51ef80d9e7af6104af160da27bb4c854d985362 | R | 477 | 45 | #
# (1) Make R packages available
#
library("devtools")
library("roxygen2")
#
# (2) Create documentation file(s)
#
document()
#
# (3) Build R package and PDF file with help pages
#
build(args = "--compact-vignettes=both")
build_manual()
#
# (4) Install R package
#
install(build_vignettes = TRUE)
#
# (5) Che... |
beb1813d2c7a1f9fb68e2f96604527e4b5004df9c9190dd9249cc505e40a038d | R | 480 | 17 |
#' mochims__fraction_bound
#'
#' Calculate fraction bound in 3-state model.
#'
#' @param folding_energy folding energies for 3-state model (required)
#' @param binding_energy binding energies for 3-state model (required)
#' @param RT constant (default:0.001987*(273+24))
#'
#' @return Fraction bound
#' @export
mochims_... |
a2b2c24337a4a6afac70f587b1cc6d77c509af1a83b61262a81ba27fb559c481 | R | 483 | 18 |
#------------------------------------------------
# list of ROSMAP IDs with age of death available
#------------------------------------------------
library(data.table)
library(readxl)
rosmap <- as.data.table(read_excel(
"/data_global/ROSMAP/greg_20200109/dataset_843_basic_01-09-2020.xlsx"))
rosmap <- rosmap[!(... |
397d4b00c702124f7ba53ca146e2a8866ec64909b39855f9d63ff79d5f319f72 | R | 485 | 21 | #!/usr/bin/env Rscript
args <- (commandArgs(TRUE))
cov <- read.table(args[1])
c_min <- min(cov$V2)
c_max <- max(cov$V2)
c_max <- c_max+floor((c_max/10))
jpeg(file="insert.jpg", height=400, width=1300, pointsize = 25)
par(mar=c(4,4,1,1))
plot(cov$V1,cov$V2,type="l",col="blue",xlab="",ylab="",ylim=c(c_min,c_max),bt... |
8872fcc074a3027c8ce5dae405479377646c229b5cd7360f6786269b102cd461 | R | 489 | 17 | kenwardroger <- function(w.random) {
#
# Kenward-Roger method for meta-analysis
# (Partlett & Riley, 2017, Stat Med)
#
w1p <- sum(w.random)
w2p <- sum(w.random^2)
w3p <- sum(w.random^3)
#
IE <- w2p * 0.5 - w3p / w1p + 0.5 * (w2p / w1p)^2
var <- (1 + 2 * (w3p / w1p - (w2p / w1p)^2) / IE) / w1p
df <... |
29adbe371e9f15a557ef41e7f02d5bb9b5803b2226e3bded7859d6291c401199 | R | 491 | 18 | # Interpolation functions
spd.interpolate.euclidean <- function(x, y, t, ...){
return((1-t)*x + t*y)
}
spd.interpolate.logeuclidean <- function(x, y, t, ...){
return(expm2((1-t)*logm2(x) + t*logm2(y)))
}
spd.interpolate.riemannian <- function(x, y, t, ...){
yt <- spd.logmap(y, p = x)
return(spd.expma... |
94dbe685913ea3eaf8eb65d64d5977011139705657cc22bd9acc3a8ad880aac9 | R | 494 | 16 | #' FMRI BOLD data
#'
#' Dataset contains fMRI BOLD data from from five subjects in each of five
#' resting-state conditions. Object is a data frame with the following fields:
#' \itemize{
#' \item{"Subject"} Subject ID
#' \item{"Condition"} Condition label
#' \item{"Data"} A 150 x 5 matrix containing the standard... |
197b2447b458835272c560b919770e26fd5e14c70e22d373fdc4663372f24655 | R | 503 | 19 | # load libraries
install.packages("psych")
install.packages("tidyverse")
install.packages("dplyr")
install.packages("Rcmdr")
install.packages("reshape2")
install.packages("viridis")
install.packages("hrbrthemes")
install.packages("ggpmisc")
install.packages("cowplot")
install.packages("ggpubr")
install.packages("lavaan... |
e5877f8a37fb11975d271ab909d81b08e57c734ab1dbdd60950e6effda2ecbb0 | R | 509 | 24 | #!/usr/bin/env Rscript
library(caret)
library(waveslim)
library(gtools)
args <- commandArgs(trailingOnly = TRUE)
outdir <- args[1]
observations <- as.integer(args[2])
Level=1
for (i in 0:(observations-1))
{
M <- read.csv(paste0(outdir,"/VCF/output_",i,".csv"), header = TRUE, row.names = NULL)
wS<-dwt.2d(as... |
53f55c99dd227f708c9aaa00fdc4b34a60103c95ef2f0575a5bbd59810875009 | R | 511 | 16 | #===========================================
# create list of duplicate IIDs to remove
#===========================================
pacman::p_load(data.table, magrittr, stringi)
psam <- fread("tmp/adc_no_naccid_dups.psam")
naccids <- psam[, `#IID` :=
stri_replace_first_regex(`#IID`, ".*_", "")]
na... |
2306a2d3890693c0c10025f49fbc547d20cf2c580a59e84c0351068dccdd6863 | R | 519 | 16 |
library(tidyverse)
df <- read.csv('/data/project//ukb_reliability_in_prediction/text_files/increase_rel_HGS.csv')
plt <- ggplot(df, aes(Reliability,test_R2,colour=Beh)) +
geom_point() +
geom_line() +
geom_text(aes(label = Time_point), colour = 'black', nudge_y = -0.002, nudge_x = 0.004) +
theme_classic() +
... |
517e0ab40c89070c3f93f4c83d3d383d81cef11b75b45e6a4dd4d66c708d3e22 | R | 524 | 22 | #' Paracetamol spectrum
#'
#' A Raman spectrum of a paracetamol tablet.
#'
#' @name paracetamol
#' @docType data
#' @format The spectrum was acquired with a Renishaw InVia spectrometer from
#' 100 to 3200 cm^-1 in step scan mode. Thus the spectrum has several
#' overlapping wavelength regions.
#' @author C. Beleite... |
3d363fb882097838659e2aa1f3ba27f8873c2611036c438e4c120b674bee89af | R | 528 | 17 | library(SCopeLoomR)
library(xlsx)
#Read counts data from loom file
loom_path <- file.path('s_fca_biohub_head_10x.loom')
loom <- open_loom(loom_path, mode="r+")
dgem <- get_dgem(loom)
close_loom(loom)
#filter Lk and CrzR coexpressed cell and process
cell <- dgem[,which(dgem['Lk',]!=0 & dgem['CrzR',]!=0)]
ce... |
9a1b5d446d9debcf5f094c0ad3e91fd1ad6a2a25f27be70c0c339b2003cc3bf4 | R | 541 | 21 | #!/usr/bin/env Rscript
args <- (commandArgs(TRUE))
ent <- read.table(args[1])
len <- max(ent$V1)
jpeg(file="entropy.jpg", height=400, width=1300, pointsize = 25)
par(mar=c(4,4,1,0))
plot(ent$V1,ent$V2, type="l",col="red",xaxt="n",yaxt="n",xlab="",ylab="",ylim=c(0,2),bty="n",lwd=1, main="Entropy of the reads")
axis... |
fc91d3a5f6360f216db98468297ee88a9d20b92cf65679feede0d1434a184559 | R | 546 | 13 | source('./scripts/01_Setup.R')
datax <- read.table("./data/processed/txt/MSA_PANTHER_BP_GOslim.txt", sep = "\t", header=T, skip=11,
quote = "", stringsAsFactors = FALSE)
datax2= datax[,c(1,7)]
delimiters = "\\(G"
aa2= strsplit(datax2[,1], delimiters, perl = TRUE)
aa3= sapply(aa2, f... |
2dbb6a70b342e537cfd38bf9a14f6e8beac9826fc8778c23528fbb78f2533e8d | R | 549 | 18 | #' get_node_from_label
#'
#' Helper function for tree manipulation: get the node number from a node label.
#'
#' @param tree A phylo object with node labels.
#' @param node_label The node label from which we want to return the node number.
#'
#' @return The node number corresponding to the given node label.
#' @require... |
03d3371ed0c60b5180936be1a99d00f55522b6903a97c9562698a3dce8c44b59 | R | 551 | 22 | addvars2long <- function(x) {
levs <- NULL
fac <- is.factor(x$var1) | is.factor(x$var2)
#
if (!(is.numeric(x$var1) & is.numeric(x$var2))) {
levs <- unique(c(x$var1, x$var2))
x$var1 <- as.numeric(factor(x$var1, levels = levs))
x$var2 <- as.numeric(factor(x$var2, levels = levs))
}
#
res <-
t... |
2b892474b3cfcb5e51827f6812bbc024314ab7f621b9585cbd1eb1f09d9b168c | R | 553 | 13 | #=================================
# fix NACC IIDs
#=================================
pacman::p_load(data.table, magrittr, stringi)
fam <- fread("data/plink/adc_original_iid.fam")
fam[, V2 := stri_replace_first_regex(V2, "[:alnum:]*_", "")]
fam[, V2 := stri_replace_first_regex(V2, "[:alnum:]*:", "")]
fam[, V2 := stri... |
a7ea919d9c7bf587bd5bac18d09c7bf9877a71ab49e8c87b79115b23d46ec9ea | R | 556 | 19 | #!/usr/bin/env Rscript
args <- (commandArgs(TRUE))
map <- read.table(args[1])
map_max <- max(map$V2)
map_max=map_max + (map_max/10)
mapped=head(map$V2,1); unmapped=tail(head(map$V2,2),1)
map_per=round((mapped/(mapped+unmapped))*100)
unmap_per=round((unmapped/(mapped+unmapped))*100)
jpeg(file="map.jpg", height=300, ... |
47a9914b7e61319b5c32c09620f25f7893e8c20c39bf3897d57d10fc64c63995 | R | 561 | 15 | # merge phenotype files for NACC, ROSMAP, and ACT
library(data.table)
nacc_ord = fread("shared/adc_np_ord.txt", na.strings = "-1")
nacc_bin = fread("shared/adc_np_bin.txt", na.strings = "-1")
rosmap = fread("shared/rosmap_np.pheno", na.strings = "-1")
act = fread("data/act/act_np.pheno", na.strings = "-1")
# merge na... |
048d453969737f8fea6858f2e7cce6a4de2ba225e447404d64dae30ed31f362d | R | 566 | 16 | # color identification --------------------------------------------------------
#
ColorForGroup <- function(){
# obtain the color representations of two group of subjects
isfahan <- MetBrewer::met.brewer("Isfahan1")
length(isfahan)
isfahan[1]
hc_color <- colorspace::lighten(isfahan[2], 0.35)
mdd... |
3f7bad6cd77304233b90f1535b4f670df1aa6b788ea71d9a3d6b29194071b81b | R | 567 | 19 | #===========================================
# create list of duplicate IIDs to remove
#===========================================
pacman::p_load(data.table, magrittr, stringi)
psam <- fread("tmp/adc_no_dup.psam", check.names = T)
psam[, IID := stri_replace_first_regex(X.IID, "[[:digit:]]*_", "")]
psam[, IID := str... |
7bb88ef841bc2465acb6bf8ddd23b72d83ded7d5eaed6d3b09bc35165bc5115d | R | 573 | 19 | # Load data to be used inside package
human_tfs <- read.csv("datasets/humanTFs.txt", header = FALSE)[, 1]
human_tfs_v2 <- read.csv("datasets/humanTFs_v2.txt", header = FALSE)[, 1]
human_tfs_v3 <- read.csv("datasets/humanTFs_v3.txt", header = FALSE)[, 1]
human_kinases <- read.csv("datasets/humanKinases.txt", header = F... |
e24d102c9423a573f6838be86d4210a3ccb436122ac63f2f9399a62c2747a5b2 | R | 579 | 30 | # To manage the packages
# library(renv) # renv.log should be able to reproduce the whole environment
# R packages on CRAN
library(tidyverse)
library(rlist)
library(xlsx)
library(glue)
#library(ggplot2) loaded with tidyverse
library(ggnewscale)
library(scales)
library(qualpalr)
library(RColorBrewer)
library(ggplotif... |
389e739d47d1b543a36d65c5484ec726eeb183015a51dc24568167773dbdecc1 | R | 581 | 17 | library(Seurat)
library(dplyr)
library(SeuratDisk)
args<-commandArgs(T)
scrna_path = args[1]
spatial_path = args[2]
celltype_final = args[3]
output_path = args[4]
sc_rna <- LoadH5Seurat(scrna_path)
sc_rna <- SCTransform(sc_rna)
spatial <- LoadH5Seurat(spatial_path)
spatial <- SCTransform(spatial)
anchors <- FindTrans... |
a323973985139977aa39b9999d34917feb351f28eacbb0e1267a64bb48861a5f | R | 581 | 24 | test_that("constant genes are discarded correctly", {
expression <- rbind(
rep.int(1, 100),
matrix(rnorm(500), nrow = 5),
rep.int(0.5, 100),
rnorm(100)
)
genesymbols <- c("T1", "T2", "T3", "T4", "T5", "T6", "R1", "R2")
is_regulator <- c(0, 0, 0, 0, 0, 0, 1, 1)
fit <- scregclust(
expressi... |
cd71417e20f38b1c17e18e5d579225f17e3cd927337692870dbdd88d31faf55d | R | 582 | 18 | #' @name extract_earliest_crop
#' @title Extract earliest date for a crop by province
#'
#' @description `extract_earliest_crop()` extracts the sample with the earliest date for a crop by province.
#'
#' @param database A data.frame containing the crop database.
#' @return A tibble that contains the earliest date for e... |
03ec435dd41592038d74dd8d3097b1dc579caa93fdf2796112d8c5cfac144f6a | R | 584 | 15 | library(gplots)
x=read.delim(gzfile("57epigenomes.RPKM.pc.gz"), row.names=1)
x$E000=NULL
names=read.delim("EG.name.txt",F)
colnames(x)=paste(colnames(x), gsub("_", " ", as.character(unlist(sapply(colnames(x), function(x) names[names$V1==x, "V2"])))))
y=as.matrix(cor(x, method='spearman'))
colnames(y)=colnames... |
a155f5baac28e1988191cc2fbea11f770da7b16c2dc65fc3a674ad9c7cf475ed | R | 587 | 20 | #' get_label_from_node
#' Helper for tree manipulation: get the node label from a given node number.
#'
#' @param tree A phylo object with node labels.
#' @param node_number The node number for which to retrieve the label.
#'
#' @return The label of the specified node.
#'
#' @examples
#' tree <- read.tree("tree.nwk")
#... |
73646882b2fb0846cd379b2d41b29717813861a174cb46482adc09b4c7e9ff1c | R | 591 | 21 | source('./scripts/01_Setup.R')
datax <- read.table("./data/processed/txt/Control_PANTHER_BP_GOslim.txt", sep = "\t", header=T, skip=11, quote = "", stringsAsFactors = FALSE)
head(datax)
dim(datax)
# 83 7
datax2= datax[,c(1,7)]
head(datax2)
delimiters = "\\(G"
aa2= strsplit(datax2[,1], delimiters, perl = TR... |
15816e2d42914ba95c1c35e80c89eee6a58b5140778fd298c358d738559a5af8 | R | 596 | 24 | #' Quinine fluorescence spectra
#'
#' Fluorescence spectra of different dilutions of quinine forming a
#' calibration set.
#'
#' See the vignette: `vignette("flu", package = "hyperSpec")`
#'
#' @name flu
#' @docType data
#' @format The data set has 6 fluorescence emission spectra measured on
#' quinine concentrations... |
d5e28143484defb028a6b05e9ee480f41a41c91f73742429ee53f2a730062c4c | R | 600 | 18 | #-------------------------
# Check heterozygosty
#-------------------------
library(data.table)
het <- fread("tmp/rosmap_1c.het")
# (total number genotypes - number homozygous) / total number genotypes
het[, het.rate := (`N(NM)` - `O(HOM)`) / `N(NM)`]
# 3SD threshold for failure
het.fail <- het[het.rate < mean(het.... |
66632fd443e2f24e9c555f91d3ca6702b6875a4ad46dd7c8c0cd3d373a952b01 | R | 601 | 29 | pkgs <- installed.packages()
vers <- pkgs[, "Version"]
data.frame(names(vers),vers)
# To cite the R package 'cluster' in publications use:
citation("readxl")
citation('org.Hs.eg.db')
citation('data.table')
citation('scales')
citation('DNAcopy')
citation('RColorBrewer')
citation('DNAcopy')... |
12ee326b6d8ac68218754aec9e75443aac0850a1768a5df820b0e2f1e749646a | R | 609 | 28 | ---
#title: "Workflow in R package meta"
#author: "Guido Schwarzer"
output:
rmarkdown::pdf_document:
number_sections: true
rmarkdown::html_vignette:
toc: false
number_sections: true
vignette: >
%\VignetteIndexEntry{meta: General Package for Meta-Analysis - Workflow}
%\VignetteEngine{knitr::rmarkdown}
... |
26474418db048d75b7bdaebc7e170a96921e55d020e38d533610da252d2b6a8c | R | 610 | 27 | logm2 <- function(x){
#lx <- logm(x)
e <- eigen(x)
lx <- e$vectors %*% diag(log(e$values)) %*% t(e$vectors)
return((lx + t(lx))/2)
}
expm2 <- function(x){
#ex <- expm(x)
e <- eigen(x)
ex <- e$vectors %*% diag(exp(e$values)) %*% t(e$vectors)
return((ex + t(ex))/2)
}
sqrtm2 <- function... |
7b1c42088f1d17c6c00dd13aca815d2d7aa2f0b6af9c725b7b3056110c2f09c0 | R | 610 | 35 |
# packages
library(tidyverse)
library(data.table)
library(patchwork)
library(magrittr)
library(ggrepel)
# visualization
theme_set(
theme_classic() +
theme(strip.background = element_rect(color = NA)
)
)
# inverse PCA
inv_pca <- function(dat, pca){
.rot <- pca$rotation
.scale <- pca$scale
.mean <-... |
fb3bae9ab3322e890672a8dfdbd14684e32af816a36fdc19708907cc8562754a | R | 612 | 17 | #' get_descendants_from_node
#' Helper function for tree manipulation.
#' Get the labels of both tips and nodes descendants from
#' a given node number in a phylogenetic tree.
#'
#' @param tree A phylogenetic tree object.
#' @param node_number The node number from which to retrieve the descendants.
#' @return A vect... |
5bc86da3890f15e1f1451e6497d29f8dcb4a7261038e0bf69089e0cacca6756d | R | 613 | 20 | library(ggplot2)
library(plyr)
d<-read.csv("boxplot_gamma.csv", header = TRUE, sep = ",", dec = ".")
attach(d)
names(d)
mydata <- within(data.frame(x=Groupe), {
y<-Median.Gamma})
## Dot plot over boxplot
gp = ggplot(mydata, aes(x, y, col =x)) + geom_boxplot(outlier.size=0, outlier.stroke=0) + labs(title= "Di... |
4610554fc91cd1cfb2188628d2e3ec9f5e1b83210edc679bb20eae448d8d2a11 | R | 615 | 19 | #===========================================
# create list of duplicate IIDs to remove
#===========================================
pacman::p_load(data.table, magrittr, stringi)
psam <- fread("tmp/adc_no_naccid_dups.psam")
naccids <- psam[, `#IID` :=
stri_replace_first_regex(`#IID`, ".*_", "")]
na... |
0d3db266cf2df4165aa184cf60c6174836551c1d84a4f6a20effa8eff680ed13 | R | 616 | 22 |
#' mochims__format_dir
#'
#' Plot fitness versus growth rate.
#'
#' @param dir_suffix directory suffix (required)
#' @param stagenum stage number (required)
#' @param base_dir base directory (required)
#' @param no_digits number of digits to use for stage number
#'
#' @return Absolute directory character string
#' @ex... |
9b384e6f84f3a72ad066972632ea97862834e51e8e548c313e8f3af6963b2c73 | R | 618 | 16 | source('./scripts/01_Setup.R')
datax <- read.table("./data/processed/txt/MSA_PANTHER_CC_GOslim.txt", sep = "\t", header=T, skip=11, quote = "", stringsAsFactors = FALSE)
datax2= datax[,c(1,7)]
aa= grep('Unclassified', datax2[,1],value = T)
datax2= datax2[!datax2[,1]%in%aa,]
delimiters = "\\(G"
aa2= strsplit(da... |
3cb8f48799bea0acccd161b5ea9247d6644783e6990d3f9d34e177a977a0ce40 | R | 619 | 23 | # Plots FreeSurfer-labeled brain regions that were related to chronic inflammation estimates using the ggseg package.
# For questions: theodore_turesky@gse.harvard.edu
library(ggseg)
# Subcortical
someData = data.frame(
region = c("putamen"),
p = c(1), stringsAsFactors = FALSE);
#someData$hemi = "left"
ggseg(... |
6ca538047e774780b95ca46317d2167db04fa5395d3391583e2308b0f00eb3d5 | R | 619 | 20 | setwd()
set.seed(42)
library(dplyr)
# import raw
raw_counts_mat = read.delim("../99.processed/counts_mat.txt", sep = '\t', check.names = F)
# cleaning
counts_mat = as.matrix(counts_mat)
# extract metadata
meta = data.frame(orig.ident = colnames(counts_mat), stringsAsFactors = F)
meta$CellLine = gsub("MgEtOH", "", m... |
45d4855ba0eb0fcd14809a9f3b43708988b5311dd81571169418ec6094e9624c | R | 623 | 23 | #### Markos et al
#### Conversion of integrated SingleCellExperiment object to h5ad for analysis with python
#### Can be run from bash e.g. by `Rscript 02_Convert_to_anndata.R`
# uncomment and set working directory to repository path if run within RStudio:
# setwd('path/to/downloaded/repository')
# Convert integrated... |
a83e13d214fef30cb0ed0da2405c6996ca260d85739409aa5762f37c82a2c25c | R | 636 | 20 | #! /usr/bin/Rscript --vanilla
#-------------------------
# Check heterozygosty
#-------------------------
library(data.table)
het <- fread("tmp/adc_qc1_het.tmp.het")
# (total number genotypes - number homozygous) / total number genotypes
het[, het.rate := (`OBS_CT` - `O(HOM)`) / `OBS_CT`]
# 3SD threshold for failu... |
e885970fd646d40f477e6f67f0875da065bbcf80e385ca75b1b5b5604c17fff2 | R | 644 | 28 | library(data.table)
library(magrittr)
library(POLMM)
bfile <- "tmp/mega_np_prune"
n_parts_grm <- 14
chrs <- 1:22
tmp_dir <- "tmp/"
for (chr in chrs) {
for (part in 1:n_parts_grm) {
getSparseGRMParallel(chr, part, n_parts_grm, bfile,
tempDir = tmp_dir,
threadNum ... |
fb80a68f40997656b4681aa1845c6d97f04d5c7cc13d2899bf3d881f5c4f623d | R | 644 | 21 | context("spd-mean")
# Positive definite matrixTesting data
x <- lapply(1:10, function(i) cov(matrix(rnorm(100), ncol = 5)))
test_that("All mean methods run without error", {
expect_error(spd.mean(x, method = 'euclidean'), NA)
expect_error(spd.mean(x, method = 'logeuclidean'), NA)
expect_error(spd.mean(x,... |
4295ae3307b8007209d5e85c4536532f868c2a5b0f235649b8c702ac5905e866 | R | 645 | 15 | data <- read.csv('data/axis_expression_data.csv')
data <- ddply(data, c('Mot', 'Hem', 'Axis'), summarize,
'r' = cor(LearningRate, AxisIncrease))
data$id <- paste(data$Hem, data$Mot)
data$id <- factor(data$id, c('LH SomMotB', 'LH SomMotA', 'RH SomMotA', 'RH SomMotB'))
data$Axis <- factor(data$Axis, c('Exp... |
a6ffb95be5a24dc49b5d7f71c2e2b98f41d3e7d3aed18ed8a7187ce1e34ab1b3 | R | 647 | 22 | context("spd-dist")
# Positive definite matrix Testing data
x <- cov(matrix(rnorm(100), ncol = 5))
y <- cov(matrix(rnorm(100), ncol = 5))
test_that("All distance methods run without error", {
expect_error(spd.dist(x, y, method = 'euclidean'), NA)
expect_error(spd.dist(x, y, method = 'logeuclidean'), NA)
... |
e8e05e35eb2822a9157476d6cb49740cc5f534e5a053b43231969e496f88a9a1 | R | 661 | 29 | # File: metric_funs.R
# Author: Kelly Chang
# Date: Oct 2017
# Version: 1.0
#
# Description: Helper R functions to find various points in a trace.
#
find_dxdtMax<-function(t, x){
dxdt<-diff(x) / diff(t)
i_max<-which.max(dxdt)[1]
t_max<-t[i_max]
up_max<-dxdt[i_max]
list(... |
01f84fcd32a65fb716c785185c4431e1cb73cdcf7e830086876777baadd16759 | R | 667 | 25 | # prep SAIGE 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("--rm_alleles_rsid", default = "FALSE")
parser$add_argument("-o", "-... |
81143d7877fa184565d192c1837143c210c0063acebee3606c1db07677fb1f4f | R | 667 | 15 | rm(list=ls(all=TRUE))
#path where all folds results are stored + beginning of filename
path='/Users/jheitz/git/dslab/new_data/val_predictions/20181110_14-15-08_new_data3__fold'
data=data.frame()
for (fold in 0:9){
data=rbind(data,read.csv(paste(path,fold,'.csv',sep="")))
}
data$error=abs(data$label-data$prediction)
... |
db9d5db5d7d5540044f86e914fef97f58a6c96ba64988e708a872c2c64d42dfe | R | 669 | 14 | source('./scripts/01_Setup.R')
datax <- read.table("./data/processed/txt/MSA_PANTHER_MF_GOslim.txt", sep = "\t", header=T, skip=11, quote = "", stringsAsFactors = FALSE)
datax2= datax[,c(1,7)]
aa= grep('Unclassified', datax2$PANTHER.GO.Slim.Molecular.Function,value = T)
datax2= datax2[!datax2$PANTHER.GO.Slim.Molecular... |
bcbf110520fbcbb01f3d328112ae8e096297e13b18722e02d2404d7f8ca96669 | R | 671 | 23 | ## Adapted from https://gist.github.com/slowkow/ c6ab0348747f86e2748b#file-counts_to_tpm-r-L44
tpm <- function(counts, lengths) {
rate <- counts / lengths
rate / sum(rate) * 1e6
}
##
## read table from featureCounts output
args <- commandArgs(T)
tag <- tools::file_path_sans_ext(args[1])
ftr.cnt <- read.tabl... |
9d9feb4182511ce24b5f16ddc64ad74fef822884b0821c138f89abd25073a077 | R | 672 | 24 | # Mean functions
spd.mean.euclidean <- function(x, ...){
Reduce(`+`, x)/length(x)
}
spd.mean.logeuclidean <- function(x, ...){
expm2(Reduce(`+`, lapply(x, logm2))/length(x))
}
spd.mean.riemannian <- function(x, p = 0, tol = .01, max.iter = 50){
if (p < -1 | p > 1){
stop('p must lie in the interva... |
0ac6b5959da890c2fa91f826e559ef12d4a0203f5cb17e167cb58b52e5b06213 | R | 676 | 26 | source('./scripts/01_Setup.R')
datax <- read.table("./data/processed/txt/Control_PANTHER_CC_GOslim.txt", sep = "\t", header=T, skip=11, quote = "", stringsAsFactors = FALSE)
head(datax)
dim(datax)
# 20 7
datax2= datax[,c(1,7)]
head(datax2)
aa= grep('Unclassified', datax2[,1],value = T)
datax2= datax2[!datax2[,1]%i... |
570de9325c5f53227620c2c442c9bf09d82645a20f37ac72a25a8e28c42f9a5d | R | 678 | 22 | #' break character strings into words
#'
#' @description Separates a character string into individual words. Wraps stringr package str_split.
#' @usage tokenize(x)
#' @param x length 1 character vector
#' @return words character vector of tokenized words
#' @seealso \code{\link{str_split}} \code{\link{boundary}}
#' @ex... |
beee1bed90c2323df8db79f5501e6bc869011680a7a25e19f6532f621923ac34 | R | 680 | 19 | 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)
all.1000genomes = read.table(paste(argv[1], "/ALL.1000genemes.... |
fa16eb50ee4dd99660b23222230c94ff09019a87e7ec6ac1b9fc9c6fd8474ccc | R | 680 | 20 | #-----------------------------------
# creates list of IDs +-3SD of mean
# heterozygosity in PLINK .het file
#-----------------------------------
library(data.table)
cargs <- commandArgs(trailingOnly = TRUE)
het <- fread(cargs[1])
# (total number genotypes - number homozygous) / total number genotypes
het[, het.rate... |
260f3f7f9eafe45528e23f795c7e216e20fab2756623880a3aa5258112afb917 | R | 685 | 22 | # Edit `one_over_f` function from `primer` package to control variance (Stevens, 2009).
# Original function is available on [GitHub](https://github.com/HankStevens/primer).
# Copyright Hank Stevens.
one_over_f <- function(gamma = 1, N = 200, outvar = 1){
N.2 <- N/2
sine.waves <- matrix(NA, nrow = N, ncol = N.2)
... |
47a78a6d8bee0c0c84f71508e17f8dab3d8333b7650725b78b9e752fd96da536 | R | 687 | 20 | # TODO Find a way to make it functional ! with a geom
#' modifies in place the plot data to be able to plot geom_facet directly
#' without creating intermediate datasets
#' @param data the plot data
#' @param nested_col The name of the column containing the nested variable.
#' @param var The name of the nested varia... |
69a25b16afbe9a589fc76d81eaea6afe6e024498ffd7b682116316495e944c77 | R | 694 | 29 | #' @importFrom geigen geigen
# Distance functions
spd.dist.euclidean <- function(x,y,...){
norm(x - y, type = 'F')
}
spd.dist.logeuclidean <- function(x,y,...){
norm(logm2(x) - logm2(y), type = 'F')
}
spd.dist.cholesky <- function(x,y){
norm(chol(x) - chol(y), type = 'F')
}
spd.dist.riemannian <- funct... |
f37ecc844d4e80f2d0d2ed716ec4725aca0f88a276660cf5d8eacfd476395c5b | R | 695 | 24 | spd.transport.pt <- function(x, from, to, nsteps) {
# Generate discrete geodesic from source to target
geod <- lapply(seq(0, 1, length.out = nsteps+1)[-1], function(i) {
spd.interpolate(from, to, t = i, method = 'riemannian')
})
# Iterate over rungs
trans <- spd.expmap(x, from)
source ... |
238d00d1e815f73538826771f62c993e9eae6cb20414ae5e08a1a8ba0ce3c664 | R | 698 | 16 | source('./scripts/01_Setup.R')
Pico <- readRDS("./results/article_figures/Pico_Segment_Median.rds")
PTA <- readRDS("./results/article_figures/PTA_Segment_Median.rds")
aahist2= ggarrange(Pico, PTA, labels = c('A','B'))
ggsave(aahist2, filename = './results/PTA_Pico_segmentvalue.png',
unit = 'cm', width = 20, h... |
dca0b9f626ca02d12abcbd0f3606556edcae6015bd1968a04b042601760e0d5f | R | 698 | 26 | #' Projection onto the tangent space
#'
#' Function projects an SPD matrix x onto the tangent space at a point p
#'
#' @param x A symmetric positive definite matrix
#' @param p The point on whose tangent space to project x
#' @return A symmetric matrix.
#' @export
spd.logmap <- function(x, p = NULL){
if (!'spd.ma... |
a35eba04abebe09d82ee7c698bed7ac22cd6b86406506a02dd2b0e6ec39e3358 | R | 700 | 30 | #' Ensure that the spectra matrix has the wavelengths in column names
#'
#' @param spc `hyperSpec` object.
#'
#' @return `hyperSpec` object with wavelengths in column names of `$spc`.
#'
#' @concept manipulation
#'
#' @export
#'
.spc_fix_colnames <- function(spc) {
colnames(spc@data$spc) <- signif(spc@wavelength, dig... |
957359cb7be0d69f3551a2d697e2ec4538e9f8ec4345e46dba1dd57c0ca85294 | R | 701 | 19 | #' Readjust the pannels from the ggtree plot and reexport as ggplot object
#'
#' @param plot_object a ggtree plot object panneled
#' @param width_mult a vector of values to multiply the original width of each panel.
#' Note that the tree counts as a pannel.
grop_redraw <- function(plot_object, width_mult = c(1, .... |
add92026ae4c81f29d8f1463d72b60d81c04ac8caf1120ba2d3abc551a272d33 | R | 701 | 13 |
lava_results = read.table("/data/workspaces/lag/workspaces/lg-genlang/Working/23andMe/Dyslexia2/Evolution/dys_rhy_pleiotropy/results/LAVA/D-RI_vs_wmTract_fromYasmina.txt",
header = T, sep = "\t")
##########################################################
# FDR
# remove duplicate rows (if ther... |
b742ba9fe4d5d622c639ac7b4d0a833e52a0aea1990c72a870f0b1e18ad34d7e | R | 704 | 20 | #' @name extract_GDD
#' @title Extract growing degree days
#'
#' @description `extract_GDD()` extracts growing degree days from a user provided GDD raster dataset at site locations.
#'
#' @param sites A data.frame with an ID and sfc_Point geometry containing site locations.
#' @param gdd_raster A raster containing grow... |
21fddcabcbc07ad25dbc021dc27b3e271d4e715f5a90696771a4cd335c4df11e | R | 708 | 21 | #' counts the frequency of unique tokens
#'
#' @description Call word tokenizer, then count the frequency of each unique word.
#' @usage count_tokens(x)
#' @param x length 1 character vector
#' @return A table of word frequencies
#' @seealso \code{\link{str_split}} \code{\link{boundary}} \code{\link{tokenize}}
#' @exam... |
2c72e2e6e89bcb781d84c9117212e9cfdc6b7364f8cc725fc0f0395e9ebbf126 | R | 711 | 20 | library(GenomicRanges)
# Get HAR SNC Overlap Information
SNC_df = read.delim('../../SNC_MAGGIE/SNCs_hg38_995-matched.txt', sep='\t')
SNC_df = SNC_df[, c('hg38_chr', 'hg38_start', 'hg38_end', 'hg38_name', 'hg38_Ref', 'Anc')]
colnames(SNC_df) = c('chr', 'start', 'end', 'Name', 'Ref', 'Anc')
SNCs = GRanges(SNC_df)
length... |
e5d39047acf172c1d5fba32cbd62d2bca8a95a93a265eb72b13ea72b83cde231 | R | 712 | 29 | library(reticulate)
use_virtualenv("causal")
# Define the Python function in R
py_run_string("
import pandas as pd
import dodiscover as dod
def kernelcdtest(Y, T, X, R=1000, ncores=1):
df_dict = {'Group': [int(ti) for ti in T]}
yvars = []
for i in range(0, Y.shape[1]):
yvar = 'Y{:d}'.format(i)
... |
0f3b7c7719db5c17b1ecba64bd151112d3c690c94a959daf8087e390179d5d3d | R | 721 | 52 | ---
title: "ChiSquareTest"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
```{r}
install.packages("readxl")
```
```{r}
#install.packages("dplyr")
#install.packages("tidyr")
#install.packages("knitr")
```
```{r}
library(dplyr)
library(tidyr)
```
```{r}
l... |
904d1f68a9e78d75b07836b33ca70997e9a7f3f66df2755449b152190d70c5e0 | R | 721 | 24 | #===================================================
# merge .pheno and .covar files for SAIGE analysis
#===================================================
library(data.table)
library(argparse)
parser <- ArgumentParser()
parser$add_argument("--pheno", "-p", help = "phenotype file")
parser$add_argument("--covar", "-c... |
6710f77388bdb3d374269dcbe301eda39b33125d124473c6915c9b6119270fea | R | 722 | 34 |
library(lme4)
library(sjPlot)
library(performance)
library(ggplot2)
library(lmerTest)
library(multcomp)
library(effects)
library(jtools)
library(lsmeans)
library(interactions)
library(emmeans)
library(car)
############## MODELLING #####################################################
df = read.csv("dat... |
b6f6ae7f01f0014b02d38133aee02f9f426b9a64b73403ca0d220b213a18b17b | R | 726 | 22 | args <- commandArgs(trailingOnly = T)
filenamex=as.character(args[[1]])
options(scipen=999)
outpath= "./data/processed/preseq"
source('./scripts/01_Setup.R')
if (file.exists(file.path(outpath, filenamex))) {
setwd(file.path(outpath, filenamex))
samples= list.files()
xx=c()
for (i in 1:length(samples)){
# print(i)
... |
b7642738df3af157a75abfdca9cf4915a97e53b2a22972934af6ad6a2ad19c54 | R | 728 | 16 | #' get_tips_descendants_from_node
#' Helper function for tree manipulation.
#' Get the labels of tips (not nodes) descendants from a given node number in a tree.
#'
#' @param tree The input tree object.
#' @param node_number The number of the node from which to retrieve the tips descendants.
#' @return A character vect... |
116ec3f93760b1dfda715c447c2877ed072cc92f2693e45c8bf8e47905020f32 | R | 732 | 26 | #' Projection from the tangent space
#'
#' Function projects a tangent vector x (a symmetric matrix) at a point p
#' onto the space of SPD matrices.
#'
#' @param x A symmetric matrix
#' @param p The point to whose tangent space x belongs
#' @return A symmetric, positive-definite matrix.
#' @export
spd.expmap <- functi... |
459ffdb950ec305a2c157a78beedbb9c88658bf2acb69dff4384bfc992cf5e21 | R | 734 | 21 | source('./scripts/01_Setup.R')
setwd("./data/processed/rds")
aa= grep("MAD",list.files(), val=T)
aa2= grep('500kb.rds', aa, val=T)
aa2=aa2[!(aa2%in%c("MAD_500kb.rds","MAD_ConfScore_500kb.rds"))]
for (i in 1:length(aa2)){
fname = file.path('./data/processed/rds/',aa2[i])
readRDS(fname)}
all = lapply(aa2... |
16b3b7c138cb18c8f4d1963fb990ab67f99b854b36d92b529c6e8dec25978f73 | R | 738 | 29 | #' Mark peak
#'
#' Marks location of the *first* spectrum at the data point closest to the
#' specified position on the current plot.
#'
#' @param spc the `hyperSpec` object
#' @param xpos position of the peak(s) in current x-axis units
#' @param col color of the markers and text
#'
#'
#' @author R. Kiselev
#'
#' @conc... |
ba4bfc3950b960b9f321e50e0e4e177a873c869fe64d7c473c12707a633b99bf | R | 743 | 21 | context("spd-transport")
# Positive definite matrixTesting data
from <- cov(matrix(rnorm(300), ncol = 3))
to <- cov(matrix(rnorm(300), ncol = 3))
x <- .8 * from + .2 * cov(matrix(rnorm(300), ncol = 3))
x <- spd.logmap(x, p = from)
y1.pt <- spd.transport(x, from = from, to = to, method = 'pt', nsteps = 10)
y... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.