I got an error as blow:
In gzfile(file, "rb") :
cannot open compressed file 'my_work_dir/step8Calder/intermediate_data/sub_compartments/40kb/chr2_intermediate_data.Rds', probable reason 'No such file or directory'
The real file is 'my_work_dir/step8Calder/intermediate_data/sub_compartments/40kb/chrchr2_intermediate_data.Rds'.
I think the command "compartments_bed_file = paste0(save_dir, '/chr', chr, '_sub_compartments.bed')" should be "compartments_bed_file = paste0(save_dir, '/chr', chr_num, '_sub_compartments.bed')"