Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save timrandg/4680022 to your computer and use it in GitHub Desktop.

Select an option

Save timrandg/4680022 to your computer and use it in GitHub Desktop.
1. go to http://www.genenames.org/cgi-bin/hgnc_downloads.cgi and create a text
output of the currated hgnc files.
% head hgnc.cleaned.txt
A12M1~withdrawn
A12M2~withdrawn
A12M3~withdrawn
A12M4~withdrawn
A1BG ENSG00000121410
A1S9T~withdrawn
A2M ENSG00000175899
A2MP1 ENSG00000256069
A2MR~withdrawn
A2MRAP~withdrawn
2. remove useless gene names (those lacking ENSEMBL IDs).
% grep ENS hngc.txt > outfil.txt && head outfile.txt
A1BG ENSG00000121410
A2M ENSG00000175899
A2MP1 ENSG00000256069
AACP ENSG00000253937
SERPINA3 ENSG00000196136
AADAC ENSG00000114771
AAMP ENSG00000127837
AANAT ENSG00000129673
AARS ENSG00000090861
AATK ENSG00000181409
2. for convenience flip the columns around.
% awk '{print $2,$1}' outfile.txt > hgnc.gn.txt
% head hgnc.gn.txt
ENSG00000121410 A1BG
ENSG00000175899 A2M
ENSG00000256069 A2MP1
ENSG00000253937 AACP
ENSG00000196136 SERPINA3
ENSG00000114771 AADAC
ENSG00000127837 AAMP
ENSG00000129673 AANAT
ENSG00000090861 AARS
ENSG00000181409 AATK
3. Here is the RNA seq file after data wrangling.
% head cleaned_combined.sum.csv
ENSG00000000003 258 1183 581
ENSG00000000005 4 16 17
ENSG00000000419 16 99 137
ENSG00000000457 35 41 42
ENSG00000000460 109 262 198
ENSG00000000938 8 7 4
ENSG00000000971 1 0 1
ENSG00000001036 157 306 246
ENSG00000001084 47 167 236
ENSG00000001167 398 439 397
3. To get the two files joined together, we can use join (with a bunch of
options to keep the program from throwing out rows that don't join--no loss of data).
Note that join requires the files be sorted. -k1 option means sort using column 1.
% join -1 1 -2 1 -a1 -e '--' -o '1.1,1.2,1.3,1.4,2.2' <(sort -k1 cleaned_combined.sum.csv) <(sort -k1 hgnc.gn.txt)
-1 1 flag means join using the first column in file one.
-2 1 flag means join using the second column in file two.
-a1 means don't throw out non-matched entries from file 1 (our data).
-e '--' -o '1.1,1.2,1.3,1.4,2.2' means in the case of a missing data use '--' as a
data place holder.
-o '1.1,1.2,1.3,1.4,2.2' is necessary for -e to work it is a formatting option that
says use file1 col1,col2,col3,col4, file2 col2. Since our data from RNAseq is completely
filled in we will only see '--' present in the place of unavailable name data.
% head temp_out.txtENSG00000000003 258 1183 581 TSPAN6
ENSG00000000005 4 16 17 TNMD
ENSG00000000419 16 99 137 DPM1
ENSG00000000457 35 41 42 SCYL3
ENSG00000000460 109 262 198 C1orf112
ENSG00000000938 8 7 4 FGR
ENSG00000000971 1 0 1 CFH
ENSG00000001036 157 306 246 FUCA2
ENSG00000001084 47 167 236 --
ENSG00000001167 398 439 397 NFYA
4. If you don't like having the names at the end, it is a quick fix to move it.
Just change the -o formatter to move the data.
% join -1 1 -2 1 -a1 -e '--' -o '1.1,2.2,1.2,1.3,1.4' <(sort -k1 cleaned_combined.sum.csv) <(sort -k1 hgnc.gn.txt) > temp_out2.txt
% head temp_out2.txt
ENSG00000000003 TSPAN6 258 1183 581
ENSG00000000005 TNMD 4 16 17
ENSG00000000419 DPM1 16 99 137
ENSG00000000457 SCYL3 35 41 42
ENSG00000000460 C1orf112 109 262 198
ENSG00000000938 FGR 8 7 4
ENSG00000000971 CFH 1 0 1
ENSG00000001036 FUCA2 157 306 246
ENSG00000001084 -- 47 167 236
ENSG00000001167 NFYA 398 439 397
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment