Saturday, July 10, 2010

Shell command to convert PLINK output

PLINK results are sepecrated by multiple spaces for nice print-out: a variable number of spaces actually, which is not convenient for programming.
1) convert to tab separated file: first remove spaces in the beginning of every line, then replace other spaces to tab
sed -r 's/^\s+//g' plink.assoc | sed -r 's/\s+/\t/g' > plink.tab
2) extract certain columns: cut uses tab as delimiter for default
sed -r 's/^\s+//g' plink.assoc | sed -r 's/\s+/\t/g' | cut -f 2 > SNPlist
If the file is separated by space, like fam file, use this:
cut -d " " -f 2

No comments:

Post a Comment