Skip to content

Unix III: Warm up exercises

Bioinformatics Core Facility Gothenburg edited this page Jan 22, 2019 · 9 revisions

Course: HT17 Unix with applications to next generation sequencing data (SC00025)


Let's warm up!!

It is common that programs use a quite specific input file format. And most of the time, we need to reformat our files.

1) Convert the file from BED to CSV format

Copy refGene.bed from /home/marcela/unix/files/. Reformat the file so that:

  • there are only genes located within canonical chromosomes
  • genes are sorted by position and
  • the chromosome name should read as 13 instead of chr13
  • and the columns should be separated by comma rather than a tab

For example, the original file looks like:

 chr13   50571142        50592603        NM_213590
 chr19   50180408        50191707        NM_198318
 chr6    90341942        90348474        NM_020466
 chr16   58497548        58547523        NM_020465
 chr5    180581942       180582890       NM_206880
 chr6    138743180       138893668       NM_020464

and your output should look like:

1,11873,14409,NR_046018
1,14361,29370,NR_024540
1,34610,36081,NR_026818
1,34610,36081,NR_026820
1,69090,70008,NM_001005484
1,134772,140566,NR_039983
1,323891,328581,NR_028322

2) Create a table from a VCF file

Copy ADK.snp.vcf from from /home/marcela/unix/files/. This file format contains a list of SNPs and it is somehow difficult to read. So to make it easier, we will reformat the list so we have only the following columns:

 CHR     POS             ID            REF     ALT       GT       DP 
 chr10   74015787        rs78186808      T       C       1/1      6 
 chr10   74019676        rs3998474       A       C       1/1      4 
 chr10   74034179        .               G       A       0/1     10 
 chr10   74056770        rs118045036     A       G       1/1      4 
 chr10   74058471        rs10762507      C       G       1/1      4 

3) Filter and reformat a TSV file

Copy occurrenceTable.txt from from /home/marcela/unix/files/. This table contains mutation counts for different samples. Filter and reformat the file so we display a table with mutations that:

  • are from the CDR1 region (look at the column names and reformat)
  • have an aminoacid change (look at the data from the first column and reformat)
  • have at least one count in any of the samples

so it looks like:

 Mutation VH5_IgG1_CDR1  VH5_IgG3_CDR1   VH5_IgG8_CDR1   VH5_IgM1_CDR1   VH5_IgM3_CDR1   VH5_IgM8_CDR1
 S35>H   1       0       0       0       0       0
 S35>P   0       0       1       1       0       0
 S35>R   0       0       1       0       0       1
 S35>A   0       0       0       1       0       0
 S35>G   1       0       0       0       4       0
 S35>V   1       0       0       0       0       0
 S35>C   0       1       1       0       0       0
 S36>H   0       0       0       0       1       0
 S36>R   0       1       3       0       0       0
 S36>A   0       0       0       1       0       0

4) Summarizing data

Copy targetRegions.txt from /home/marcela/unix/files/. These are the positions that were targeted for sequencing in a research project. How many regions per chromosome were targeted? Make sure to order the data showing the chromosome with more regions on the top, like:

 8       chr1
 7       chr4
 6       chr3
 5       chr7
 5       chr22
 4       chrX
 4       chr5


Created by Marcela Dávila

Clone this wiki locally