Unix tar compress and decompress tar.gz files or folder

Compress multiple files:

tar -czvf name-of-archive.tar.gz file1 file2 folder1 folder2 

Compress folder:

tar -czvf name-of-archive.tar.gz /path/to/directory-or-file

Compress a folder while excluding some files:

tar -czvf archive.tar.gz /home/ubuntu --exclude=*.mp4

Decompress tar.gz file:

tar -xzvf archive.tar.gz
tar -xzvf archive.tar.gz -C targetDir
tar -xzvf archive.tar.gz -directory targetDir


Liftover bigwig files

There are two ways to lift-over bigwig files from one genome build to another. One is using CrossMap or step by step as below. (CrossMap is almost the same to the break down steps)

CrossMap method: (taking from hg19 to hg38 as example)

pip install CrossMap

CrossMap.py bigwig hg19ToHg38.over.chain input.bw output.bw

genome liftover chain files can be downloaded here: http://hgdownload.cse.ucsc.edu/goldenpath/hg19/liftOver/ (change according to your needs)

Step by step method: (bw –> bedGraph –> liftover –> bw)

bigWigToBedGraph input.bw input.bedGraph

liftOver input.bedGraph hg19ToHg38.over.chain input_hg38.bedgraph unMapped

fetchChromSizes hg38 > hg38.chrom.sizes

LC_COLLATE=C sort -k1,1 -k2,2n input_hg38.bedgraph > input_hg38.sorted.bedgraph

bedGraphToBigWig input_hg38.sorted.bedgraph hg38.chrom.sizes output.bw

bigWigToBedGraph, liftOver, fetchChromSizes, bedGraphToBigWig are all UCSC utilities which can be installed from here: http://hgdownload.soe.ucsc.edu/downloads.html#utilities_downloads