I have a dataset like this:
AAACCTGCAAGCGAGT-1,ENSG00000000419,DPM1,2
AAACCTGCAAGCGAGT-1,ENSG00000001497,LAS1L,1
AAACCTGCAAGCGAGT-1,ENSG00000002330,BAD,1
AAACCTGCAAGCGAGT-1,ENSG00000002549,MT-CO3,2
AAACCTGCAAGCGAGT-1,ENSG00000002586,CD99,5
AAACCTGCAAGCGAGT-1,ENSG00000002834,LASP1,1
AAACCTGCAAGCGAGT-1,ENSG00000003056,M6PR,1
AAACCTGCAAGCGAGT-1,ENSG00000003402,MT-CYB,2
AAACCTGCAAGCGAGT-1,ENSG00000004059,ARF5,2
AAACCTGCAAGCGAGT-1,ENSG00000004455,AK2,1
AAACCTGCAAGCGAGT-1,ENSG00000004468,CD38,8
AAACCTGCAAGCGAGT-1,ENSG00000004779,NDUFAB1,3
AAACCTGCAAGCGAGT-1,ENSG00000004975,DVL2,1
AAACCTGCAAGCGAGT-1,ENSG00000005022,SLC25A5,6
I want to get the data that third columns contains mitocondrial genes which is have pattern "MT-", for example, the dataset above, I would like to extract:
AAACCTGCAAGCGAGT-1,ENSG00000002549,MT-CO3,2
AAACCTGCAAGCGAGT-1,ENSG00000003402,MT-CYB,2
I use this command:
awk '$3 ~/^MT-/ {print $1, $2, $3, $4} final_matrix.csv
But it didn't work.
awk
is a space. Your data uses a comma as the field separator. Refer to theawk
man page, particularly the-F
option.