Skip to content

Instantly share code, notes, and snippets.

@cheuerde
cheuerde / slide_GWAS.r
Last active October 13, 2015 16:44
GWAS using sliding windows and likelihood ratio test
# Claas Heuer, September 2015
#####################################################
### Likelihood ratio test for multiple regression ###
#####################################################
slide_GWAS <- function(y, M, X = NULL, verbose = TRUE, sliding_window=TRUE, window_size = 10) {
library(lmtest)
@cheuerde
cheuerde / compile_r_devel.sh
Last active September 14, 2015 16:23
Compile R-devel
# Claas Heuer, September 2015
# set default installation directory:
INSTDIR=$HOME/opt
# place to store the source packages
SOURCES=$HOME/sourcebuilds
###################
### Compiling R ###
@cheuerde
cheuerde / package_submit_cran.sh
Last active September 14, 2015 16:28
Submit R package to Cran
# Claas Heuer, September 2015
#
# First check your package on your machine ('cpgen' is the package folder)
R CMD check --as-cran cpgen
# Nothing is allowed, not even 'NOTES' (but probably depends, one or two notes might be ok)
# then check again using 'devtools'
@cheuerde
cheuerde / mixture.r
Last active September 8, 2015 16:04
Mixture models in R using mixtools
# Claas Heuer, September 2015
#
# Extremely good vignette for mixtools: https://cran.r-project.org/web/packages/mixtools/vignettes/mixtools.pdf
library(mixtools)
library(ks)
########################
### Gaussian Mixture ###
########################
@cheuerde
cheuerde / ggplot2_grid.r
Created September 3, 2015 16:25
ggplot2 - arrange plots in grid
library(ggplot2)
library(reshape2)
library(gridExtra)
dat <- read.csv("dat.csv",header=TRUE,stringsAsFactors=FALSE)
# make flat file
D <- melt(dat, id.vars=c("Reg.No.Id"),measure.vars=c("Tpi","Pl","Dpr"))
# make the graphs
@cheuerde
cheuerde / xlsx_to_csv.sh
Created September 2, 2015 18:10
convert excel xlsx to csv
# using libreoffice's 'unoconv'
unoconv -f csv filename.xlsx
# using ssconvert
ssconvert file.xlsx > file.csv
@cheuerde
cheuerde / awk_stuff.sh
Last active April 12, 2016 14:21
AWK and GREP stuff
# Claas Heuer, Spetember 2015
#
# helpful:
# http://www.grymoire.com/Unix/Awk.html#uh-1
# http://www.shellhacks.com/en/Using-BASH-Grep-OR-Grep-AND-Grep-NOT-Operators
# count number of lines
awk -F',' 'END{print NR;}' test.csv
@cheuerde
cheuerde / win_unix.sh
Created September 1, 2015 15:21
Windows File to Unix
# first remove all carriage returns (https://kb.iu.edu/d/acux)
#dos2unix Report.txt Report_unix.txt
awk '{ sub("\r$", ""); print }' Report.txt > Report_unix.txt
@cheuerde
cheuerde / glibc_install.sh
Last active April 24, 2024 08:06
Install GNU libc version parallel to existing system
# Claas Heuer, August 2015
#
# urls:
# http://stackoverflow.com/questions/847179/multiple-glibc-libraries-on-a-single-host
# http://www.gnu.org/software/libc/download.html
cd $HOME
mkdir glibc_update
cd glibc_update
@cheuerde
cheuerde / mysql_dump.r
Last active August 29, 2015 14:28
Access SQL dump database in R
# Claas Heuer, August 2015
#
# links:
# http://www.rackspace.com/knowledge_center/article/installing-mysql-server-on-debian
# http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/
# https://mkmanu.wordpress.com/2014/07/24/r-and-mysql-a-tutorial-for-beginners/
# http://stackoverflow.com/questions/15420999/rodbc-odbcdriverconnect-connection-error
# http://www.w3schools.com/sql/sql_join.asp