Skip to content

Instantly share code, notes, and snippets.

@ggirelli
Last active March 2, 2021 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggirelli/79e55dee26730e396c3c34c3bf29bd40 to your computer and use it in GitHub Desktop.
Save ggirelli/79e55dee26730e396c3c34c3bf29bd40 to your computer and use it in GitHub Desktop.
Quickly check chromosome sizes in hic file
#!/usr/bin/env bash
# As hic files contain sparse matrices, the matrix size is usually smaller than the expected (especially at high resolutions)
# This needs straw to be installed, see here: https://github.com/aidenlab/straw
hic_file="SRR2184278-93.hic"
resolution=100000
chromosomes=($(seq 1 22) X Y)
if [ -f "$hic_file.chrom_size.tsv" ]; then
rm "$hic_file.chrom_size.tsv"
touch "$hic_file.chrom_size.tsv"
fi
for i in ${chromosomes[@]}; do
size=$(straw observed KR $hic_file "$i" "$i" BP $resolution | tail -n 1 | cut -f 1)
echo -e "$i\t$size" >> $hic_file.$resolution.chrom_size.tsv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment