Hello everyone,
I have created a 012 genotype matrix by using --012 command in vcf tools which give individuals in row and SNPs in columns.
I want to run smartpca and and need to convert rows to columns. Means get SNPs in rows and individuals in columns.
I have tried some shel commands like this but seems it does not work.
awk ' {
for (i=1; i<=NF; i++) {
a[NR,i] = $i
} } NF>p { p = NF } END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
} }'
I wonder if anyone has any idea how to do that?
Is there any way to do this manipulation in R? but R cannot read my output genotype matrix!
Thanks
Please provide a few lines of your matrix (with headers). Try datamash (GNU tool available in most of the linux repos) to transpose data easy. input:
output: