如何在指定Shell脚本中添加修改heatmap宽度的自定义选项?
为热图脚本添加宽度配置选项的实现位置
核心修改位置
要实现热图宽度自定义,需在两个关键位置修改脚本:
1. 新增用户交互配置(脚本开头)
在读取输出目录的逻辑之后,添加热图宽度的输入环节,同时设置默认值(避免用户每次都手动输入)。
2. 调整plotHeatmap命令(脚本末尾)
在调用plotHeatmap的提示语句和实际执行命令中,加入--heatmapWidth参数,绑定用户输入的宽度变量。
修改后的完整脚本示例
echo echo "Please enter the directory you would like the heatmap in: " read directory # 新增:添加热图宽度配置输入,默认值设为20 echo "Please enter the heatmap width (default: 20): " read heatmap_width heatmap_width=${heatmap_width:-20} echo ${#mutants[@]} matrix_string= heatmap_string= if [[ ${num_controls} -gt ${num_mutants} ]] then for i in "${!controls[@]}" do matrix_string="${matrix_string} ${controls[$i]}" heatmap_string="${heatmap_string} ${modification}_ctrl" if [[ i -lt ${#mutants[@]} ]] then matrix_string="${matrix_string} ${mutants[$i]}" heatmap_string="${heatmap_string} ${modification}_mut" fi done else for i in "${!mutants[@]}" do if [[ i -lt ${#controls[@]} ]] then matrix_string="${matrix_string} ${controls[$i]}" heatmap_string="${heatmap_string} ${modification}_ctrl" fi matrix_string="${matrix_string} ${mutants[$i]}" heatmap_string="${heatmap_string} ${modification}_mut" done fi echo "creating matrix: computeMatrix reference-point --referencePoint center -R ${bedFile} -S${matrix_string} -a 1500 -b 1500 -o ${directory}matrix_${modification}.gz --missingDataAsZero" computeMatrix reference-point --referencePoint center -R ${bedFile} -S ${matrix_string} -a 2000 -b 2000 -o ${directory}matrix_${modification}.gz --missingDataAsZero # 修改:在提示语句中加入宽度参数 echo "plotting heatmap: plotHeatmap -m ${directory}matrix_${modification}.gz --samplesLabel ${heatmap_string} --heatmapHeight 16 --heatmapWidth ${heatmap_width} -out ${directory}${modification}.png" # 修改:在实际执行命令中加入宽度参数 plotHeatmap -m ${directory}matrix_${modification}.gz --heatmapHeight 16 --samplesLabel ${heatmap_string} --heatmapWidth ${heatmap_width} -out ${directory}${modification}.png
关键细节说明
--heatmapWidth是plotHeatmap工具的官方参数,单位为英寸,可根据需求调整默认值。heatmap_width=${heatmap_width:-20}的作用是:若用户未输入宽度值,自动使用20作为默认宽度,提升脚本易用性。
内容的提问来源于stack exchange,提问作者Leya Ledvin
相关产品推荐
相关产品推荐

