Entering edit mode
4.4 years ago
DBScan
▴
450
I am trying to filter GTEx for liver tissue. I was able to extract the sample names from the "SamplesAtrributesDS.txt" file and find the corresponding column number in the "transcript_expected_count.gct" file for each sample. I then want to use awk to extract the counts from the column number, but I always get this error:
awk: fatal: cannot open file `{print $myvar}' for reading (No such file or directory)
I use the following code:
#!/bin/bash
Genes=$(awk -F "\t" '{if ($6=="Liver") print $1}' GTEx_Analysis_v8_Annotations_SampleAttributesDS.txt)
for gene in $Genes
do
colnr=$(head -n 3 GTEx_Analysis_2017-06-05_v8_RSEMv1.3.0_transcript_expected_count.gct | tail -n 1 | cut -f3- | tr '\t' '\n' | cat -n | grep $gene | cut -f 1)
echo $colnr
if [ -z "$colnr" ]
then
echo "\$colnr is empty"
else
echo $colnr
awk -v myvar=$colnr '{print $myvar}' GTEx_Analysis_2017-06-05_v8_RSEMv1.3.0_transcript_expected_count.gct
fi
done
I would be glad if someone can point out what I am doing wrong.
what is the output of
before the error ? Furthermore, can you please use
echo "($colnr)"
to show if there is any space.
The output of echo "($colnr)" is
Why is it that way?
because
cat -n |
insert some spaces before the line number.So the command :
becomes:
where myvar is empty , 281 is the awk script and '{print $myvar}' and file are the filenames.
Remove
$
, try:no I think OP wants to print the myvar-th column