This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PheCode analysis with NB regression and edgeR | |
library(MASS) | |
# Analysis of 1 phenotype | |
######################### | |
# number of individuals | |
n = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gabriel Hoffman | |
# Feb 2 , 2021 | |
# | |
# Combine GREx and cell culture scores into 1 set of scores | |
library(ggrepel) | |
library(ggplot2) | |
df = read.csv("shRNA.All.fdr.EpiXcan.vs.TWAS_joint_statistic_all.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gabriel Hoffman | |
# Feb 11, 2021 | |
# Plot and compare two curves | |
library(data.table) | |
library(ggplot2) | |
# simulate data | |
set.seed(1) | |
n = 10000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gabriel Hoffman | |
# Feb 17, 2021 | |
# | |
# Accelerating loading large results files in R | |
# Using data.table::fread() with a commandline pipe | |
# and awk to filter rows is the fastest and uses least memory | |
# Here are empirical results for 1.4 Gb gzip'd eQTL results file | |
# Performance will depend on filtering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modules based on https://github.com/genomely/RAPiD-nf/blob/85fa4c1e4e3ffb8d2e7bdce368318b5c688f415b/config/chimera.config#L276 | |
# versions based on https://github.com/genomely/RAPiD-nf/blob/85fa4c1e4e3ffb8d2e7bdce368318b5c688f415b/config/chimera.config#L70 | |
ml python/2.7.17 samtools/1.11 bcftools/1.10.2 | |
# Set variable | |
export NGSCHECKMATE=/sc/arion/projects/H_PBG/scripts/NGSCheckMate | |
# move to temp directory | |
cd /hpc/users/hoffmg01/work/test/ngs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 95% confidence intervals for fractions | |
library(binom) | |
Same = 95 | |
Total = 100 | |
res = binom.confint(Same, Total, method="exact") | |
res[,c('n','mean', 'lower', 'upper')] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create regression coefficents and standard errors | |
beta1 = .5 | |
se1 = .1 | |
beta2 = .2 | |
se2 = .09 | |
# t-statistic for comparing the beta values | |
# Since beta1 and beta2 are independent, | |
# var(beta1 - beta2) = var(beta1) + var(beta2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(variancePartition) | |
library(Rfast) | |
library(Matrix) | |
final.everything <- readRDS("/sc/arion/projects/psychgen2/lbp/data/RAW/rna/bulk/fromSema4/CompiledData/lbp_allBatches_RAPiD_Metadata_21JUL2021.RDS") | |
metadata <- final.everything$covariates | |
# Simulate 10 genes | |
set.seed(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
R loads packages from paths: .libPaths() | |
R tries to install packages into .libPaths()[1]. If you dont have access to this path, the install will fail. | |
You need to create a local folder to install packages to, and make it first in the search path. Add the following to your ~/.bash_profile file: | |
# specify a local library | |
R_LIBS_USER=/hpc/users/${USER}/.Rlib/R_libs/ | |
# Make the local library first in the search path | |
R_LIBS=$R_LIBS_USER:$R_LIBS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Need new version | |
if( packageVersion("zellkonverter") < 1.2 ){ | |
stop("Need newer version") | |
} | |
# Reading snRNA-seq data into R with low memory usage | |
library(SingleCellExperiment) | |
library(zellkonverter) | |
# path to h5ad file |