UNIX is the second largest computer operating system (next to Microsoftís OSís). It is used by MacOS and several versions of Linux but is also distributed freely (e.g. Ubuntu, openSUSE) , for use by those with PCs. There are many different flavors of UNIX, but the basics are shared between them all. Most researchers needing to do computer intensive tasks and/or programming use UNIX because it is more stable and faster than Microsoft OSís and it has many tools (e.g., grep, awk, sed) useful for such tasks.

I include a page on UNIX here because many things that can be done in R can be done using UNIX more quickly. This page just has a few snippets of code for my own use and for members of my lab. These commands can often be done from within R using the system() command, which I demonstrate after each UNIX command


#To take the 1st, 3rd, and 7th column and put it into a new file
awk '{print $1,$3,$7}' ~/Downloads/genotypes_chr5_CEU_r27_nr.b36_fwd.txt > pos.chr5
R> system(paste("awk '{print $1,$3,$7}' ~/Downloads/genotypes_chr",i,"_CEU_r27_nr.b36_fwd.txt > pos.chr",i,sep=''))


#get a list of every element of the 2nd column where the 5th column is greater than .1
awk '{if($5 < .1) print $2;}' maf.chr.5.frq > maf.5
R> paste("awk '{if($5 < .1) print $2;}' maf.chr.",i,".frq > maf.",i,sep="")


#to write a bash script that loops through chromosomes
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
   cbatch "plink --bfile /home/GWAS/GeneralRelease/Imputed/Release3/CleanPlink/GRclean${i} --extract  c${i}.keep1 --maf .05 --out GRclean2 --make-bed"


grep -A 1 'New Chomosome AFTER' log_POPNA_20Mb_neutral.out > ss.out #get lines after "new Cho.."
tail -n 600 ss.out > ss2.out #get last 600 lines
grep -v 'New Chomosome AFTER' ss2.out > ss3.out #get all lines BUT "New Chomo..."
grep -ve '--' ss3.out > ss4.out # e is necessary because "-" has special meaning in grep
grep -A 40 'Loop 99' log_POPNA_20Mb_neutral.out > s99.out #to check that new.hap lines up with pedigree file


Personal Links:

Julia movie

[Matthew C Keller's Home Page] [Biosketch] [Vita] [Publications] [Keller Lab] [Program Code] [R] [64 bit R on Mac] [Aquamacs] [Bioconductor] [Memory] [Parallelization] [UNIX] [Courses] [Links]