Last active
March 2, 2021 11:54
-
-
Save ggirelli/79e55dee26730e396c3c34c3bf29bd40 to your computer and use it in GitHub Desktop.
Quickly check chromosome sizes in hic file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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