I have a bunch of genotype files genotype-HA1_1, ..., genotype-HA1_27. Rows are SNPs and columns are individuals.Number of individuals (i.e., columns) differs in each genotype file.Here are 2 examples of how they look like:
head genotype-HA1_1
A A A A A A A A A A
C C C C C C C N C C
N K K K T K K N G N
N A A A R A A A A A
Y Y T Y C T Y T T Y
and
head genotype-HA1_11
A A W A A W A A A N A
C C C C C C C N C C C
G G K G N K K N G G G
A A A A N A A N A A A
I want to count the total number of character "N" for each SNP and divide it to the number of individuals (i.e., columns) in each file over a loop.
my desired output
count-genotype-HA1_1
0
0.1
0.3
0.1
0
I am using something like this
for cfile in genotype-HA1_*; do
awk -F\N '{print NF-1/NF}' "$cfile" > count-"${cfile##*.}"; done
part of the code that counts the number of "N" works perfectly fine, I just do not know how to divid it into the number of columns in each file.